Skip to content

Commit

Permalink
Regression test for #860 (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran authored Nov 3, 2023
1 parent 23f552f commit 574f4bf
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1490,4 +1490,39 @@ void getTarget() {
elements
);
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/860
// Field assignment to anonymous type breaks selection
public void testGH860() throws JavaModelException {
this.wc = getWorkingCopy("/Resolve15/src/eclipse_bug/CurrentTextSelectionCannotBeOpened.java",
"""
package eclipse_bug;
public class CurrentTextSelectionCannotBeOpened {
public static class Super {
public boolean boolMethod(){return true;}
}
Object obj;
public boolean somecode(){
obj=new Object(){
public boolean somecode(){
Super sup=new Super();
return sup.boolMethod();
}
};
return false;
}
}
""");
String str = this.wc.getSource();
String selection = "boolMethod";
int start = str.lastIndexOf(selection);
int length = selection.length();
IJavaElement[] elements = this.wc.codeSelect(start, length);
assertElementsEqual(
"Unexpected elements",
"boolMethod() [in Super [in CurrentTextSelectionCannotBeOpened [in [Working copy] CurrentTextSelectionCannotBeOpened.java [in eclipse_bug [in src [in Resolve15]]]]]]",
elements
);
}
}

0 comments on commit 574f4bf

Please sign in to comment.