Skip to content

Commit

Permalink
Cache and re-use type bindings for a completion invocation
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Apr 4, 2023
1 parent 90215ef commit 8d40742
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class CompletionProposalReplacementProvider {
*/
private boolean isResolvingRequest;

final Map<String, IBinding> bindings = new HashMap<>();

public CompletionProposalReplacementProvider(ICompilationUnit compilationUnit, CompletionContext context, int offset,
Preferences preferences, ClientPreferences clientPrefs, boolean isResolvingRequest) {
super();
Expand Down Expand Up @@ -937,13 +939,16 @@ private ITypeBinding getExpectedTypeForGenericParameters() {
for (int i= 0; i < keys.length; i++) {
keys[i]= String.valueOf(chKeys[0]);
}
// https://github.com/eclipse/eclipse.jdt.ls/pull/2535
if (bindings.size() > 0) {
return (ITypeBinding) bindings.get(keys[0]);
}

final ASTParser parser = ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
parser.setProject(compilationUnit.getJavaProject());
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);

final Map<String, IBinding> bindings= new HashMap<>();
ASTRequestor requestor= new ASTRequestor() {
@Override
public void acceptBinding(String bindingKey, IBinding binding) {
Expand Down

0 comments on commit 8d40742

Please sign in to comment.