Skip to content

Commit

Permalink
Fix some regressions caused by field access fix
Browse files Browse the repository at this point in the history
- `myMethod().|`
- completion after method declaration in `@interface`

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Nov 5, 2024
1 parent 8d3654c commit 493f040
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ public void run() {
completeAfter = fieldAccess.getName().toString();
} else if (this.toComplete instanceof MethodInvocation methodInvocation) {
completeAfter = methodInvocation.getName().toString();
try {
IBuffer cuBuffer = this.modelUnit.getBuffer();
if (cuBuffer.getChar(this.offset - 1) == '.') {
completeAfter = ""; //$NON-NLS-1$
}
} catch (JavaModelException e) {
ILog.get().error("error while trying to read buffer for completion purposes", e); //$NON-NLS-1$
}
}
this.prefix = completeAfter;
this.qualifiedPrefix = this.prefix;
Expand Down Expand Up @@ -320,6 +328,17 @@ public void run() {
.forEach(this.requestor::accept);
}
suggestDefaultCompletions = false;
} else if (invocation.getName().getStartPosition() + invocation.getName().getLength() + 3 /* the three chars: `().` */ <= this.offset && this.prefix.isEmpty()) {
// handle `myMethod().|`
IMethodBinding methodBinding = invocation.resolveMethodBinding();
if (methodBinding != null) {
ITypeBinding returnType = methodBinding.getReturnType();
processMembers(invocation, returnType, specificCompletionBindings, false);
specificCompletionBindings.stream()
.map(binding -> toProposal(binding))
.forEach(this.requestor::accept);
}
suggestDefaultCompletions = false;
}
}
if (context instanceof VariableDeclaration declaration) {
Expand Down Expand Up @@ -358,6 +377,9 @@ public void run() {
if (context.getParent() instanceof MethodDeclaration) {
suggestDefaultCompletions = false;
}
if (context.getParent() instanceof AnnotationTypeMemberDeclaration) {
suggestDefaultCompletions = false;
}
if (context.getLocationInParent().getId().equals(QualifiedName.QUALIFIER_PROPERTY.getId()) && context.getParent() instanceof QualifiedName) {
// eg.
// void myMethod() {
Expand Down

0 comments on commit 493f040

Please sign in to comment.