From 7f5c20a4dee2ff592ab1e2eb297de615a99f1980 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 5 Dec 2024 16:59:49 -0500 Subject: [PATCH] Don't add import for `java.lang` 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 --- .../eclipse/jdt/internal/codeassist/DOMCompletionEngine.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java index 4c501569de0..d6bd33044e3 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java @@ -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]); } @@ -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;