bazel syntax: lock down constructors of syntax nodes
Only the parser should create syntax nodes.
This is a preparatory step for having the parser provide file offsets of
important tokens to each node constructor, enabling more precise and compact
representation of location information.
A few nodes cannot be locked down yet because they are created directly by
tests in skyframe/serialization. Before fixing those, we must make move certain
checks from the parser to the validator (e.g. no for/def at toplevel, no **kwargs, etc).
Also:
- inline some trivial parser helpers (e.g. makeList) into Parser
- add some TODOs signposting next refactoring steps.
PiperOrigin-RevId: 262642915
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java b/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
index 4f499d6..6cb3e4b 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
@@ -85,7 +85,7 @@
@AutoCodec
public static final class Mandatory<V, T> extends Parameter<V, T> {
- public Mandatory(Identifier identifier) {
+ Mandatory(Identifier identifier) {
this(identifier, null);
}
@@ -111,7 +111,7 @@
public final V defaultValue;
- public Optional(Identifier identifier, @Nullable V defaultValue) {
+ Optional(Identifier identifier, @Nullable V defaultValue) {
this(identifier, null, defaultValue);
}
@@ -154,11 +154,11 @@
public static final class Star<V, T> extends Parameter<V, T> {
@AutoCodec.Instantiator
- public Star(@Nullable Identifier identifier, @Nullable T type) {
+ Star(@Nullable Identifier identifier, @Nullable T type) {
super(identifier, type);
}
- public Star(@Nullable Identifier identifier) {
+ Star(@Nullable Identifier identifier) {
this(identifier, null);
}
@@ -186,11 +186,11 @@
public static final class StarStar<V, T> extends Parameter<V, T> {
@AutoCodec.Instantiator
- public StarStar(Identifier identifier, @Nullable T type) {
+ StarStar(Identifier identifier, @Nullable T type) {
super(identifier, type);
}
- public StarStar(Identifier identifier) {
+ StarStar(Identifier identifier) {
this(identifier, null);
}