From 30a216475d50b0634d7e0c555600234b82e1d3be Mon Sep 17 00:00:00 2001 From: David Thompson <davthomp@redhat.com> Date: Thu, 12 Dec 2024 16:37:40 -0500 Subject: [PATCH] Camel case matching for completed types - (when necessary) - add .gitignore for tests Snjezana added in 08c4e999f3b277a70dba27db6f1261432bdcac77 - also, suggest types for the following case: ```java public class HelloWorld { AA| } ``` Signed-off-by: David Thompson <davthomp@redhat.com> --- .../proj1/.gitignore | 1 + .../proj2/.gitignore | 1 + .../codeassist/DOMCompletionEngine.java | 27 ++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj1/.gitignore create mode 100644 org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj2/.gitignore diff --git a/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj1/.gitignore b/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj1/.gitignore new file mode 100644 index 00000000000..1fcb1529f8e --- /dev/null +++ b/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj1/.gitignore @@ -0,0 +1 @@ +out diff --git a/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj2/.gitignore b/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj2/.gitignore new file mode 100644 index 00000000000..ba077a4031a --- /dev/null +++ b/org.eclipse.jdt.core.tests.javac/projects/multipleOutputDirectories/proj2/.gitignore @@ -0,0 +1 @@ +bin 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 daadebedb6f..c08a8f44aa3 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 @@ -341,6 +341,30 @@ public void run() { // } ITypeBinding typeDeclBinding = typeDecl.resolveBinding(); findOverridableMethods(typeDeclBinding, this.modelUnit.getJavaProject(), context); + // TODO: POTENTIAL_METHOD_DECLARATION + + final int typeMatchRule = IJavaSearchConstants.TYPE; + ExtendsOrImplementsInfo extendsOrImplementsInfo = isInExtendsOrImplements(this.toComplete); + if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { + findTypes(completeAfter, typeMatchRule, null) + // don't care about annotations + .filter(type -> { + try { + return !type.isAnnotation(); + } catch (JavaModelException e) { + return true; + } + }) + .filter(type -> { + return defaultCompletionBindings.stream().map(typeBinding -> typeBinding.getJavaElement()).noneMatch(elt -> type.equals(elt)); + }) + .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), + type.getElementName().toCharArray())) + .filter(type -> { + return filterBasedOnExtendsOrImplementsInfo(type, extendsOrImplementsInfo); + }) + .map(this::toProposal).forEach(this.requestor::accept); + } suggestDefaultCompletions = false; } if (context.getParent() instanceof MarkerAnnotation) { @@ -1173,7 +1197,8 @@ public void acceptTypeNameMatch(org.eclipse.jdt.core.search.TypeNameMatch match) namePrefix.toCharArray(), SearchPattern.R_PREFIX_MATCH | (this.assistOptions.substringMatch ? SearchPattern.R_SUBSTRING_MATCH : 0) - | (this.assistOptions.subwordMatch ? SearchPattern.R_SUBWORD_MATCH : 0), + | (this.assistOptions.subwordMatch ? SearchPattern.R_SUBWORD_MATCH : 0) + | (this.assistOptions.camelCaseMatch ? SearchPattern.R_CAMELCASE_MATCH : 0), typeMatchRule, searchScope, typeRequestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // TODO also resolve potential sub-packages } catch (JavaModelException ex) {