commit | bd273e537cc52e41194a5e0c67c1673467bbe1eb | [log] [tgz] |
---|---|---|
author | Googler <brandjon@google.com> | Thu Oct 24 08:58:01 2024 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Thu Oct 24 08:59:16 2024 -0700 |
tree | ea617bcb30f826b157ba1db5f3e371185a8792a9 | |
parent | 68f94a1d6f2eede5552fd52986a74b6e9ecaa1b6 [diff] |
Refactor RuleVisibility validation and concatenation This CL simplifies RuleVisibility concatenation by inlining concatWithElement() into concatWithPackage(). The latter was the only caller of the former in production. The implementation no longer has to handle the case where the RHS is public or private -- something that was not needed in practice, but which was required in abstract for the deleted method's API to be correct. It also now doesn't need to parse an untrusted label, so there's no need to catch or throw EvalException. concatWithPackage() is also made non-static, which looks nicer at the call sites. The validate() method is renamed to checkForVisibilityMisspelling(), since that's the only thing it does now. (A previous CL removed its other job of detecting formerly illegal combinations of public/private visibility with other items in a list.) Added an equals() and hashCode() while we're at it, to avoid depending on singleton identity (I'm not sure whether @SerializationConstant lets us assume that). It's based on just getDeclaredLabels() since that should superset any information returned by getDependencyLabels(). Changed RuleVisibility from an interface to an abstract class too -- I would've made it `sealed`, but the singleton PUBLIC and PRIVATE anonymous subclasses prevent that and it's not worth making them named classes. MacroInstance.java - Implement the TODO. (I went with "getDefinitionPackage" over "getDefiningPackage" because the latter might be confused with the package that defines the macro *instance*.) MacroClass.java - Condense to if-expr form now that the else branch is more concise. RuleVisibilityTest.java - Add pkg() helper for concatenation() test case. - Remove assertEqual() now that we have a RuleVisibility#equals() method. - Rename "B" -> "B_PG" for clarity/contrast with "A" and "C". - Delete test cases for concatWithElement that are no longer applicable (where the RHS is public or private visibility) Work toward #23855. PiperOrigin-RevId: 689400241 Change-Id: I6b7a1c9f87c4b3c9e5cd99d5dc4d906b5d798d28
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
To report a security issue, please email security@bazel.build with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.
See CONTRIBUTING.md