aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/Parser.java3
3 files changed, 11 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java
index 934c7f2003..181f4a5ae7 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java
@@ -98,7 +98,7 @@ public class BuildFileAST extends ASTNode {
ImmutableMap.Builder<String, SkylarkImport> imports = ImmutableBiMap.builder();
for (Statement stmt : stmts) {
if (stmt instanceof LoadStatement) {
- String str = ((LoadStatement) stmt).getImport();
+ String str = ((LoadStatement) stmt).getImport().getValue();
imports.put(
str,
Preconditions.checkNotNull(
@@ -125,7 +125,7 @@ public class BuildFileAST extends ASTNode {
boolean error = false;
for (Statement stmt : stmts) {
if (stmt instanceof LoadStatement) {
- String importString = ((LoadStatement) stmt).getImport();
+ String importString = ((LoadStatement) stmt).getImport().getValue();
try {
SkylarkImport imp = SkylarkImports.create(importString);
imports.put(importString, imp);
@@ -168,9 +168,8 @@ public class BuildFileAST extends ASTNode {
}
/** Returns a list of loads as strings in this BUILD file. */
- public synchronized ImmutableList<String> getRawImports() {
- ImmutableList.Builder<String> imports = ImmutableList.builder();
-
+ public ImmutableList<StringLiteral> getRawImports() {
+ ImmutableList.Builder<StringLiteral> imports = ImmutableList.builder();
for (Statement stmt : stmts) {
if (stmt instanceof LoadStatement) {
imports.add(((LoadStatement) stmt).getImport());
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 2a6e0fbcab..2254116bf2 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
@@ -17,14 +17,11 @@ import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.syntax.compiler.DebugInfo;
import com.google.devtools.build.lib.syntax.compiler.LoopLabels;
import com.google.devtools.build.lib.syntax.compiler.VariableScope;
-
-import net.bytebuddy.implementation.bytecode.ByteCodeAppender;
-
import java.util.Map;
+import net.bytebuddy.implementation.bytecode.ByteCodeAppender;
/**
* Syntax node for an import statement.
@@ -33,8 +30,7 @@ public final class LoadStatement extends Statement {
private final ImmutableMap<Identifier, String> symbols;
private final ImmutableList<Identifier> cachedSymbols; // to save time
- private final String imp;
- private final Location importLocation;
+ private final StringLiteral imp;
/**
* Constructs an import statement.
@@ -43,29 +39,24 @@ public final class LoadStatement extends Statement {
* 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(String imp, Location importLocation, Map<Identifier, String> symbols) {
+ LoadStatement(StringLiteral imp, Map<Identifier, String> symbols) {
this.imp = imp;
- this.importLocation = importLocation;
this.symbols = ImmutableMap.copyOf(symbols);
this.cachedSymbols = ImmutableList.copyOf(symbols.keySet());
}
- public Location getImportLocation() {
- return importLocation;
- }
-
public ImmutableList<Identifier> getSymbols() {
return cachedSymbols;
}
- public String getImport() {
+ public StringLiteral getImport() {
return imp;
}
@Override
public String toString() {
return String.format(
- "load(\"%s\", %s)", imp, Joiner.on(", ").join(cachedSymbols));
+ "load(\"%s\", %s)", imp.getValue(), Joiner.on(", ").join(cachedSymbols));
}
@Override
@@ -81,7 +72,7 @@ public final class LoadStatement extends Statement {
}
// The key is the original name that was used to define the symbol
// in the loaded bzl file.
- env.importSymbol(imp, name, declared.getName());
+ env.importSymbol(imp.getValue(), name, declared.getName());
} catch (Environment.LoadFailedException e) {
throw new EvalException(getLocation(), e.getMessage());
}
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
index 4d285a3e5b..41010629bc 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
@@ -1055,8 +1055,7 @@ public class Parser {
}
expect(TokenKind.RPAREN);
- LoadStatement stmt = new LoadStatement(
- importString.getValue(), importString.getLocation(), symbols);
+ LoadStatement stmt = new LoadStatement(importString, symbols);
list.add(setLocation(stmt, start, token.left));
}