Fix the location of load statements in Skylark.
Previously, the closing parenthesis was not included in the location.
RELNOTES: none
PiperOrigin-RevId: 171527078
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
index 20ea5c0..858e0ca 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
@@ -555,6 +555,16 @@
assertExpressionLocationCorrect("not True");
}
+ @Test
+ public void testLoadStatementPosition() throws Exception {
+ String input = "load(':foo.bzl', 'bar')";
+ LoadStatement stmt = (LoadStatement) parseFile(input).get(0);
+ assertThat(getText(input, stmt)).isEqualTo(input);
+ // Also try it with another token at the end (newline), which broke the location in the past.
+ stmt = (LoadStatement) parseFile(input + "\n").get(0);
+ assertThat(getText(input, stmt)).isEqualTo(input);
+ }
+
private void assertExpressionLocationCorrect(String exprStr) {
Expression expr = parseExpression(exprStr);
assertThat(getText(exprStr, expr)).isEqualTo(exprStr);