Skip to content

Commit 8d40742

Browse files
committed
Cache and re-use type bindings for a completion invocation
Signed-off-by: Snjezana Peco <[email protected]>
1 parent 90215ef commit 8d40742

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalReplacementProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public class CompletionProposalReplacementProvider {
9797
*/
9898
private boolean isResolvingRequest;
9999

100+
final Map<String, IBinding> bindings = new HashMap<>();
101+
100102
public CompletionProposalReplacementProvider(ICompilationUnit compilationUnit, CompletionContext context, int offset,
101103
Preferences preferences, ClientPreferences clientPrefs, boolean isResolvingRequest) {
102104
super();
@@ -937,13 +939,16 @@ private ITypeBinding getExpectedTypeForGenericParameters() {
937939
for (int i= 0; i < keys.length; i++) {
938940
keys[i]= String.valueOf(chKeys[0]);
939941
}
942+
// https://github.com/eclipse/eclipse.jdt.ls/pull/2535
943+
if (bindings.size() > 0) {
944+
return (ITypeBinding) bindings.get(keys[0]);
945+
}
940946

941947
final ASTParser parser = ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
942948
parser.setProject(compilationUnit.getJavaProject());
943949
parser.setResolveBindings(true);
944950
parser.setStatementsRecovery(true);
945951

946-
final Map<String, IBinding> bindings= new HashMap<>();
947952
ASTRequestor requestor= new ASTRequestor() {
948953
@Override
949954
public void acceptBinding(String bindingKey, IBinding binding) {

0 commit comments

Comments
 (0)