Skip to content

Commit

Permalink
Don't add import for java.lang
Browse files Browse the repository at this point in the history
When importing a type via completion,
don't add an import for the type if it's from `java.lang`

A part of #1024

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Dec 6, 2024
1 parent 0ba054e commit 7f5c20a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ private CompletionProposal toProposal(IType type) {
res.setRelevance(relevance);
if (parentType != null) {
// propose importing the type
res.setRequiredProposals(new CompletionProposal[] { toImportProposal(simpleName, signature) });
res.setRequiredProposals(new CompletionProposal[] { toImportProposal(simpleName, signature, type.getPackageFragment()) });
} else {
res.setRequiredProposals(new CompletionProposal[0]);
}
Expand Down Expand Up @@ -1701,10 +1701,11 @@ private CompletionProposal toAnonymousConstructorProposal(ITypeBinding typeBindi
return res;
}

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

0 comments on commit 7f5c20a

Please sign in to comment.