mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
IDEA-108113 Would be great to have an instanceof operator in keyword completion
This commit is contained in:
@@ -531,8 +531,19 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
PsiElement prev = PsiTreeUtil.prevVisibleLeaf(position);
|
||||
if (prev == null) return false;
|
||||
|
||||
PsiExpression expr = PsiTreeUtil.getParentOfType(prev, PsiExpression.class);
|
||||
return expr != null && expr.getTextRange().getEndOffset() == prev.getTextRange().getEndOffset();
|
||||
PsiElement expr = PsiTreeUtil.getParentOfType(prev, PsiExpression.class);
|
||||
if (expr != null && expr.getTextRange().getEndOffset() == prev.getTextRange().getEndOffset()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (position instanceof PsiIdentifier && position.getParent() instanceof PsiLocalVariable) {
|
||||
PsiType type = ((PsiLocalVariable)position.getParent()).getType();
|
||||
if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSuitableForClass(PsiElement position) {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
void test(Object o) {
|
||||
o <caret>
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testNewInMethodRefs() throws Exception { doTest(1, "new"); }
|
||||
public void testSpaceAfterInstanceof() throws Exception { doTest(false); }
|
||||
public void testInstanceofAfterUnresolved() throws Exception { doTest(1, "instanceof"); }
|
||||
public void testInstanceofAfterStatementStart() throws Exception { doTest(1, "instanceof"); }
|
||||
public void testAbstractInInterface() throws Exception { doTest(1, "abstract"); }
|
||||
public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); }
|
||||
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
|
||||
|
||||
Reference in New Issue
Block a user