mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-166582 No completion inside lambda when instance of contains lambda
This commit is contained in:
+1
-2
@@ -75,8 +75,7 @@ public class DataFlowRunner {
|
||||
private Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, @NotNull InstructionVisitor visitor) {
|
||||
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);
|
||||
PsiElement block = DfaPsiUtil.getTopmostBlockInSameClass(container.getParent());
|
||||
if (block != null) {
|
||||
final RunnerResult result = analyzeMethod(block, visitor);
|
||||
if (result == RunnerResult.OK) {
|
||||
|
||||
@@ -336,29 +336,21 @@ public class DfaPsiUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiCodeBlock getTopmostBlockInSameClass(@NotNull PsiElement position) {
|
||||
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, PsiLambdaExpression.class);
|
||||
if (block == null) {
|
||||
return lastBlock;
|
||||
}
|
||||
lastBlock = block;
|
||||
}
|
||||
public static PsiElement getTopmostBlockInSameClass(@NotNull PsiElement position) {
|
||||
return JBIterable.
|
||||
generate(position, PsiElement::getParent).
|
||||
takeWhile(e -> !(e instanceof PsiMember || e instanceof PsiFile || e instanceof PsiLambdaExpression)).
|
||||
filter(e -> e instanceof PsiCodeBlock || e instanceof PsiExpression && e.getParent() instanceof PsiLambdaExpression).
|
||||
last();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<PsiExpression> getVariableAssignmentsInFile(@NotNull PsiVariable psiVariable,
|
||||
final boolean literalsOnly,
|
||||
final PsiElement place) {
|
||||
final Ref<Boolean> modificationRef = Ref.create(Boolean.FALSE);
|
||||
final PsiCodeBlock codeBlock = place == null? null : getTopmostBlockInSameClass(place);
|
||||
final int placeOffset = codeBlock != null? place.getTextRange().getStartOffset() : 0;
|
||||
Ref<Boolean> modificationRef = Ref.create(Boolean.FALSE);
|
||||
PsiElement codeBlock = place == null? null : getTopmostBlockInSameClass(place);
|
||||
int placeOffset = codeBlock != null? place.getTextRange().getStartOffset() : 0;
|
||||
PsiFile containingFile = psiVariable.getContainingFile();
|
||||
LocalSearchScope scope = new LocalSearchScope(new PsiElement[]{containingFile}, null, true);
|
||||
Collection<PsiReference> references = ReferencesSearch.search(psiVariable, scope).findAll();
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
if (o instanceof String) {
|
||||
Runnable r = () -> o.leng<caret>;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class Test {
|
||||
public void f(Object o ) {
|
||||
if (o instanceof String) {
|
||||
Runnable r = () -> ((String) o).length()<caret>;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -72,4 +72,6 @@ public class FooImpl extends Foo {
|
||||
|
||||
void testCastInstanceofedQualifierInLambda2() { doTest() }
|
||||
|
||||
void testCastInstanceofedQualifierInExpressionLambda() { doTest() }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user