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/main/java/com/google/devtools/build/lib/syntax/Parser.java b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
index 6d45726..e59f329 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
@@ -1053,10 +1053,10 @@
 
       parseLoadSymbol(symbols);
     }
-    expect(TokenKind.RPAREN);
 
     LoadStatement stmt = new LoadStatement(importString, symbols);
-    list.add(setLocation(stmt, start, token.left));
+    list.add(setLocation(stmt, start, token.right));
+    expect(TokenKind.RPAREN);
     expectAndRecover(TokenKind.NEWLINE);
   }
 
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);