Refactor AST APIs
Added public visibility to some constructors/accessors, and made child LValue nodes explicitly constructed by the caller rather than hidden inside constructors. This makes it easier to treat nodes as uniform dumb values. Also added some helpers.
RELNOTES: None
PiperOrigin-RevId: 158761415
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
index b098ead..e13074c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
@@ -23,7 +23,7 @@
*/
public final class LoadStatement extends Statement {
- private final ImmutableMap<Identifier, String> symbols;
+ private final ImmutableMap<Identifier, String> symbolMap;
private final ImmutableList<Identifier> cachedSymbols; // to save time
private final StringLiteral imp;
@@ -34,10 +34,14 @@
* the bzl file that should be loaded. If aliasing is used, the value differs from its key's
* {@code symbol.getName()}. Otherwise, both values are identical.
*/
- LoadStatement(StringLiteral imp, Map<Identifier, String> symbols) {
+ public LoadStatement(StringLiteral imp, Map<Identifier, String> symbolMap) {
this.imp = imp;
- this.symbols = ImmutableMap.copyOf(symbols);
- this.cachedSymbols = ImmutableList.copyOf(symbols.keySet());
+ this.symbolMap = ImmutableMap.copyOf(symbolMap);
+ this.cachedSymbols = ImmutableList.copyOf(symbolMap.keySet());
+ }
+
+ public ImmutableMap<Identifier, String> getSymbolMap() {
+ return symbolMap;
}
public ImmutableList<Identifier> getSymbols() {
@@ -56,7 +60,7 @@
@Override
void doExec(Environment env) throws EvalException, InterruptedException {
- for (Map.Entry<Identifier, String> entry : symbols.entrySet()) {
+ for (Map.Entry<Identifier, String> entry : symbolMap.entrySet()) {
try {
Identifier name = entry.getKey();
Identifier declared = new Identifier(entry.getValue());