diff options
author | fzaiser <fzaiser@google.com> | 2017-08-28 17:05:54 +0200 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-08-28 17:36:01 +0200 |
commit | 37af5d531cdd052e5a0d313e2474c32c1c79b3d3 (patch) | |
tree | e1acff56e0952310147ad616269a5ea53f94a9d5 /src/main/java/com/google/devtools/build/lib/syntax | |
parent | f4e20e6cb2f8e4333460157b2dd28e9bf1822010 (diff) |
Change Identifier#boundNames to #boundIdentifiers.
RELNOTES: None
PiperOrigin-RevId: 166704851
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java | 4 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/LValue.java | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java b/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java index 5278c80aef..9c0b4959e6 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java @@ -291,8 +291,8 @@ public abstract class AbstractComprehension extends Expression { // Check if a loop variable conflicts with another local variable. LValue lvalue = clause.getLValue(); if (lvalue != null) { - for (String name : lvalue.boundNames()) { - env.removeLocalBinding(name); + for (Identifier ident : lvalue.boundIdentifiers()) { + env.removeLocalBinding(ident.getName()); } } } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/LValue.java b/src/main/java/com/google/devtools/build/lib/syntax/LValue.java index b964a2750f..6fbe08d652 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/LValue.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/LValue.java @@ -196,30 +196,32 @@ public final class LValue extends ASTNode { } /** - * Returns all names bound by this LValue. + * Returns all names bound by this LValue. * - * Examples: - * <ul> - * <li><{@code x = ...} binds x.</li> - * <li><{@code x, [y,z] = ..} binds x, y, z.</li> - * <li><{@code x[5] = ..} does not bind any names.</li> - * </ul> + * <p>Examples: + * + * <ul> + * <li><{@code x = ...} binds x. + * <li><{@code x, [y,z] = ..} binds x, y, z. + * <li><{@code x[5] = ..} does not bind any names. + * </ul> */ - public ImmutableSet<String> boundNames() { - ImmutableSet.Builder<String> result = ImmutableSet.builder(); - collectBoundNames(expr, result); + public ImmutableSet<Identifier> boundIdentifiers() { + ImmutableSet.Builder<Identifier> result = ImmutableSet.builder(); + collectBoundIdentifiers(expr, result); return result.build(); } - private static void collectBoundNames(Expression lhs, ImmutableSet.Builder<String> result) { + private static void collectBoundIdentifiers( + Expression lhs, ImmutableSet.Builder<Identifier> result) { if (lhs instanceof Identifier) { - result.add(((Identifier) lhs).getName()); + result.add((Identifier) lhs); return; } if (lhs instanceof ListLiteral) { ListLiteral variables = (ListLiteral) lhs; for (Expression expression : variables.getElements()) { - collectBoundNames(expression, result); + collectBoundIdentifiers(expression, result); } } } |