Skip to content

Commit

Permalink
[23] Code completion for module imports
Browse files Browse the repository at this point in the history
Fix the replacement region

fixes eclipse-jdt#2823
  • Loading branch information
stephan-herrmann committed Aug 22, 2024
1 parent f08e389 commit 0841695
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ public void test001() throws JavaModelException {
public class X {}
""");

CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "java.";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
int nameStart = str.lastIndexOf(completeBehind);
int cursorLocation = nameStart + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
"[MODULE_REF]{java.base, java.base, null, null, null, " + DEFAULT_RELEVANCE + "}",
"[MODULE_REF]{java.base, java.base, null, null, null, ["+nameStart+", "+cursorLocation+"], "+DEFAULT_RELEVANCE + "}",
requestor.getResults());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,8 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po
if ((importReference.modifiers & ClassFileConstants.AccModule) != 0 && this.compilerOptions.enablePreviewFeatures) {
this.currentModule = this.unitScope.module(); // enable module-graph analysis for readability
this.completionToken = CharOperation.concatWithAll(importReference.tokens, '.');
this.tokenStart = importReference.sourceStart;
this.startPosition = importReference.sourceStart;
findModules(this.completionToken, true);
return;
}
Expand Down

0 comments on commit 0841695

Please sign in to comment.