mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-151552 No completion after instanceof inside lambda
This commit is contained in:
+4
-4
@@ -74,11 +74,11 @@ public class DataFlowRunner {
|
||||
|
||||
@Nullable
|
||||
private Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, @NotNull InstructionVisitor visitor) {
|
||||
PsiClass containingClass = PsiTreeUtil.getParentOfType(psiBlock, PsiClass.class);
|
||||
if (containingClass != null && PsiUtil.isLocalOrAnonymousClass(containingClass)) {
|
||||
final PsiElement parent = containingClass.getParent();
|
||||
PsiElement container = PsiTreeUtil.getParentOfType(psiBlock, PsiClass.class, PsiLambdaExpression.class);
|
||||
if (container != null && (!(container instanceof PsiClass) || PsiUtil.isLocalOrAnonymousClass((PsiClass)container))) {
|
||||
final PsiElement parent = container.getParent();
|
||||
final PsiCodeBlock block = DfaPsiUtil.getTopmostBlockInSameClass(parent);
|
||||
if ((parent instanceof PsiNewExpression || parent instanceof PsiDeclarationStatement) && block != null) {
|
||||
if (block != null) {
|
||||
final RunnerResult result = analyzeMethod(block, visitor);
|
||||
if (result == RunnerResult.OK) {
|
||||
final Collection<DfaMemoryState> closureStates = myNestedClosures.get(DfaPsiUtil.getTopmostBlockInSameClass(psiBlock));
|
||||
|
||||
@@ -253,14 +253,14 @@ public class DfaPsiUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiCodeBlock getTopmostBlockInSameClass(@NotNull PsiElement position) {
|
||||
PsiCodeBlock block = PsiTreeUtil.getParentOfType(position, PsiCodeBlock.class, false, PsiMember.class, PsiFile.class);
|
||||
PsiCodeBlock block = PsiTreeUtil.getParentOfType(position, PsiCodeBlock.class, false, PsiMember.class, PsiFile.class, PsiLambdaExpression.class);
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiCodeBlock lastBlock = block;
|
||||
while (true) {
|
||||
block = PsiTreeUtil.getParentOfType(block, PsiCodeBlock.class, true, PsiMember.class, PsiFile.class);
|
||||
block = PsiTreeUtil.getParentOfType(block, PsiCodeBlock.class, true, PsiMember.class, PsiFile.class, PsiLambdaExpression.class);
|
||||
if (block == null) {
|
||||
return lastBlock;
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
Runnable r = () -> {
|
||||
if (o instanceof String) {
|
||||
o.leng<caret>
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
if (o instanceof String) {
|
||||
Runnable r = () -> {
|
||||
o.leng<caret>
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
if (o instanceof String) {
|
||||
Runnable r = () -> {
|
||||
((String) o).length()<caret>
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
Runnable r = () -> {
|
||||
if (o instanceof String) {
|
||||
((String) o).length()<caret>
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -68,4 +68,7 @@ public class FooImpl extends Foo {
|
||||
checkResultByFile(getTestName(false) + "_after.java")
|
||||
}
|
||||
|
||||
public void testCastInstanceofedQualifierInLambda() { doTest() }
|
||||
public void testCastInstanceofedQualifierInLambda2() { doTest() }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user