Skip to content

Commit

Permalink
Improve attached import completion for type completions
Browse files Browse the repository at this point in the history
Only do it when the type isn't in the same class and use `null` instead
of a 0 length array

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Dec 9, 2024
1 parent b5f5d36 commit 376e448
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1456,10 +1456,10 @@ private CompletionProposal toProposal(IType type) {
}
res.setRelevance(relevance);
if (parentType != null) {
// propose importing the type
res.setRequiredProposals(new CompletionProposal[] { toImportProposal(simpleName, signature, type.getPackageFragment()) });
} else {
res.setRequiredProposals(new CompletionProposal[0]);
if (!this.modelUnit.equals(type.getCompilationUnit())) {
// propose importing the type
res.setRequiredProposals(new CompletionProposal[] { toImportProposal(simpleName, signature, type.getPackageFragment().getElementName().toCharArray()) });
}
}
return res;
}
Expand Down Expand Up @@ -1637,11 +1637,11 @@ private CompletionProposal toAnonymousConstructorProposal(ITypeBinding typeBindi
return res;
}

private CompletionProposal toImportProposal(char[] simpleName, char[] signature, IPackageFragment packageFragment) {
private CompletionProposal toImportProposal(char[] simpleName, char[] signature, char[] packageName) {
InternalCompletionProposal res = new InternalCompletionProposal(CompletionProposal.TYPE_IMPORT, this.offset);
res.setName(simpleName);
res.setSignature(signature);
res.setPackageName(packageFragment.getElementName().toCharArray());
res.setPackageName(packageName);
res.completionEngine = this.nestedEngine;
res.nameLookup = this.nameEnvironment.nameLookup;
return res;
Expand Down

0 comments on commit 376e448

Please sign in to comment.