Skip to content

Commit

Permalink
[Sealed types] Completion fails within the body of a permitted class (e…
Browse files Browse the repository at this point in the history
…clipse-jdt#2568)

* Regression test for eclipse-jdt#2540
  • Loading branch information
srikanth-sankaran authored Jun 14, 2024
1 parent 1aebcfa commit 3eb741f
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,28 @@ public sealed interface SealedI p {
permits[RESTRICTED_IDENTIFIER]{permits, null, null, permits, null, 49}\
""", requestor.getResults());
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2540
// Completion fails within the body of a permitted class
public void testGH2540() throws JavaModelException {
this.workingCopies = new ICompilationUnit[2];
this.workingCopies[0] = getWorkingCopy("/Completion/src/Storage.java", """
public sealed class Storage permits SqlStorage {
}\
""");
this.workingCopies[1] = getWorkingCopy("/Completion/src/SqlStorage.java", """
public final class SqlStorage extends Storage {
/*here*/Sq
}\
""");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[1].getSource();
String completeBehind = "/*here*/Sq";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[1].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("""
Sq[POTENTIAL_METHOD_DECLARATION]{Sq, LSqlStorage;, ()V, Sq, null, 39}
SqlStorage[TYPE_REF]{SqlStorage, , LSqlStorage;, null, null, 52}\
""", requestor.getResults());
}
}

0 comments on commit 3eb741f

Please sign in to comment.