Skip to content

Commit

Permalink
AnnotationPosition: avoid IOOBE on annotated var keyword usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Jan 26, 2022
1 parent fed46c5 commit 67e5934
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -167,7 +167,7 @@ private static List<ErrorProneToken> annotationTokens(
endPos = state.getEndPosition(methodTree);
}
} else if (tree instanceof JCVariableDecl) {
endPos = ((JCVariableDecl) tree).getType().getStartPosition();
endPos = state.getEndPosition(((JCVariableDecl) tree).getModifiers());
} else if (tree instanceof JCClassDecl) {
JCClassDecl classTree = (JCClassDecl) tree;
endPos =
Expand Down
Expand Up @@ -513,4 +513,20 @@ public void parameters_withInterspersedModifiers() {
"}")
.doTest(TEXT_MATCH);
}

@Test
public void varKeyword() {
refactoringHelper
.addInputLines(
"Test.java",
"import com.google.errorprone.annotations.Var;",
"class T {",
" void m() {",
" @Var var x = 1;",
" x = 2;",
" }",
"}")
.expectUnchanged()
.doTest(TEXT_MATCH);
}
}

0 comments on commit 67e5934

Please sign in to comment.