mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[java-completion] IDEA-363557 Don't offer classes after dot at class level
GitOrigin-RevId: da52d7093ed80c0eb80ebf11e5f43d2d58a0758e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
62af27623f
commit
201dffa02d
@@ -59,6 +59,7 @@ import com.intellij.psi.impl.light.LightJavaModule;
|
||||
import com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl;
|
||||
import com.intellij.psi.impl.source.PsiLabelReference;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.scope.ElementClassFilter;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
@@ -88,6 +89,16 @@ public final class JavaCompletionContributor extends CompletionContributor imple
|
||||
private static final ElementPattern<PsiElement> UNEXPECTED_REFERENCE_AFTER_DOT = or(
|
||||
// dot at the statement beginning
|
||||
psiElement().afterLeaf(".").insideStarting(psiExpressionStatement()),
|
||||
//example: class A{ .something }
|
||||
psiElement().afterLeaf(".")
|
||||
.insideStarting(psiElement(JavaElementType.TYPE))
|
||||
.afterLeafSkipping(psiElement().andOr(
|
||||
psiElement().whitespace(),
|
||||
psiElement().withText("")),
|
||||
psiElement().withParent(PsiErrorElement.class))
|
||||
.withParent(PsiJavaCodeReferenceElement.class)
|
||||
.withSuperParent(2, PsiTypeElement.class)
|
||||
.withSuperParent(3, PsiClass.class),
|
||||
// like `call(Cls::methodRef.<caret>`
|
||||
psiElement().afterLeaf(psiElement(JavaTokenType.DOT).afterSibling(psiElement(PsiMethodCallExpression.class).withLastChild(
|
||||
psiElement(PsiExpressionList.class).withLastChild(psiElement(PsiErrorElement.class))))),
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
class A{}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
.<caret>
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
class A{}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
Foo.<caret>
|
||||
}
|
||||
+8
@@ -3276,4 +3276,12 @@ public class NormalCompletionTest extends NormalCompletionTestCase {
|
||||
}
|
||||
""");
|
||||
}
|
||||
|
||||
public void testNoSuggestionsAfterDotAtClassLevel() { doAntiTest(); }
|
||||
|
||||
public void testSuggestionsAfterDotAtClassLevel() {
|
||||
configureByTestName();
|
||||
myFixture.completeBasic();
|
||||
assertTrue(myFixture.getLookupElementStrings().contains("A"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user