mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-112567 Don't show any completion variants after method reference and dot
This commit is contained in:
+4
-1
@@ -35,6 +35,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PatternCondition;
|
||||
import com.intellij.patterns.PsiJavaElementPattern;
|
||||
import com.intellij.patterns.PsiNameValuePairPattern;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -78,6 +79,8 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
|
||||
public static final ElementPattern<PsiElement> ANNOTATION_NAME = psiElement().
|
||||
withParents(PsiJavaCodeReferenceElement.class, PsiAnnotation.class).afterLeaf("@");
|
||||
private static final PsiJavaElementPattern.Capture<PsiElement> UNEXPECTED_REFERENCE_AFTER_DOT =
|
||||
psiElement().afterLeaf(".").insideStarting(psiExpressionStatement());
|
||||
|
||||
private static JavaCompletionData getCompletionData(LanguageLevel level) {
|
||||
final Set<Map.Entry<LanguageLevel, JavaCompletionData>> entries = ourCompletionData.entrySet();
|
||||
@@ -203,7 +206,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AFTER_NUMBER_LITERAL.accepts(position)) {
|
||||
if (AFTER_NUMBER_LITERAL.accepts(position) || UNEXPECTED_REFERENCE_AFTER_DOT.accepts(position)) {
|
||||
_result.stopHere();
|
||||
return;
|
||||
}
|
||||
|
||||
+9
@@ -50,4 +50,13 @@ class Foo {{ Object o = Fo<caret>x }}
|
||||
class Foo {{ Object o = Foo::<caret>x }}
|
||||
"""
|
||||
}
|
||||
|
||||
public void testNoSuggestionsAfterMethodReferenceAndDot() {
|
||||
String text = """
|
||||
class Foo {{ Object o = StringBuilder::append.<caret> }}
|
||||
"""
|
||||
myFixture.configureByText "a.java", text
|
||||
assertEmpty(myFixture.completeBasic())
|
||||
myFixture.checkResult(text)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user