Skip to content

Commit

Permalink
Camel case matching for completed types
Browse files Browse the repository at this point in the history
- (when necessary)
- add .gitignore for tests Snjezana added in 08c4e99
- also, suggest types for the following case:

```java
public class HelloWorld {
    AA|
}
```

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Dec 13, 2024
1 parent cc0dccd commit a36076f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a36076f

Please sign in to comment.