Skip to content

Commit

Permalink
ArrayStoreException in SelectionParser.buildMoreCompletionContext (#2463
Browse files Browse the repository at this point in the history
)

* Fixes #2443
  • Loading branch information
srikanth-sankaran authored May 21, 2024
1 parent eddfb7d commit 75ade7e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1702,4 +1702,35 @@ public static void main(String[] args) {
elements
);
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2443
// ArrayStoreException in SelectionParser.buildMoreCompletionContext
public void testGH2443() throws JavaModelException {
this.wc = getWorkingCopy("/Resolve15/src/X.java",
"""
public class X {
public static void main(String[] args) {
for (String sourcePath : args) {
new X() {
public void foo(String file) {
file.hashCode();
}
};
}
}
}
""");
String str = this.wc.getSource();
String selection = "file";
int start = str.lastIndexOf(selection);
int length = selection.length();
IJavaElement[] elements = this.wc.codeSelect(start, length);
assertElementsEqual(
"Unexpected elements",
"file [in foo(String) [in <anonymous #1> [in main(String[]) [in X [in [Working copy] X.java [in <default> [in src [in Resolve15]]]]]]]]",
elements
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,7 @@ protected boolean restartRecovery() {
case K_INSIDE_EXPRESSION_SWITCH:
case K_INSIDE_IF:
case K_INSIDE_WHILE:
case K_INSIDE_FOR_EACH:
deferRestartOnLocalType = true;
break;
case K_TYPE_DELIMITER:
Expand Down

0 comments on commit 75ade7e

Please sign in to comment.