From d8f2e23979723c1809bfa247daab861dfc7ec8b3 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 12 Mar 2012 21:25:22 +0400 Subject: [PATCH] Allow count non-imported descriptors for empty prefix in qualified expression - important for extension functions --- .../completion/JetCompletionContributor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java index 47fa2401086..9281153044b 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java +++ b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java @@ -32,10 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; -import org.jetbrains.jet.lang.psi.JetFile; -import org.jetbrains.jet.lang.psi.JetQualifiedExpression; -import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; -import org.jetbrains.jet.lang.psi.JetTypeReference; +import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.caches.JetCacheManager; @@ -84,8 +81,15 @@ public class JetCompletionContributor extends CompletionContributor { String prefix = result.getPrefixMatcher().getPrefix(); - if (prefix.isEmpty() && parameters.getInvocationCount() < 2) { - return; + // Try to avoid computing not-imported descriptors for empty prefix + if (prefix.isEmpty()) { + if (parameters.getInvocationCount() < 2) { + return; + } + + if (PsiTreeUtil.getParentOfType(jetReference.getElement(), JetDotQualifiedExpression.class) == null) { + return; + } } if (shouldRunTopLevelCompletion(parameters, prefix)) {