Skip to content

Commit

Permalink
Improve type completion inside expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanper authored and mickaelistria committed Jul 8, 2024
1 parent 4b6de2f commit 0ad2048
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
Expand Down Expand Up @@ -284,13 +285,17 @@ public void acceptConstructor(int modifiers, char[] simpleTypeName, int paramete
}
var suitableBinding = this.recoveredNodeScanner.findClosestSuitableBinding(context, scope);
if (suitableBinding != null) {
processMembers(suitableBinding, scope);
scope.stream()
.filter(binding -> this.pattern.matchesName(this.prefix.toCharArray(),
binding.getName().toCharArray()))
.map(binding -> toProposal(binding)).forEach(this.requestor::accept);
this.requestor.endReporting();
return;
// this handle where we complete inside a expressions like
// Type type = new Type(); where complete after "Typ", since completion should support all type completions
// we should not return from this block at the end.
if (!(this.toComplete.getParent() instanceof Type)) {
processMembers(suitableBinding, scope);
scope.stream().filter(
binding -> this.pattern.matchesName(this.prefix.toCharArray(), binding.getName().toCharArray()))
.map(binding -> toProposal(binding)).forEach(this.requestor::accept);
this.requestor.endReporting();
return;
}
}

ASTNode parent = this.toComplete;
Expand Down

0 comments on commit 0ad2048

Please sign in to comment.