mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Fix ExpectedTypesProvider for completion inside switch expressions (IDEA-204680)
Review ID: IDEA-CR-41558
This commit is contained in:
@@ -308,6 +308,9 @@ public class ExpectedTypesProvider {
|
||||
if (statement.getParent() instanceof PsiSwitchLabeledRuleStatement) {
|
||||
PsiSwitchBlock block = ((PsiSwitchLabeledRuleStatement)statement.getParent()).getEnclosingSwitchBlock();
|
||||
if (block instanceof PsiSwitchExpression) {
|
||||
if (myForCompletion) {
|
||||
myExpr = (PsiSwitchExpression)block;
|
||||
}
|
||||
block.getParent().accept(this);
|
||||
return;
|
||||
}
|
||||
@@ -321,6 +324,9 @@ public class ExpectedTypesProvider {
|
||||
public void visitBreakStatement(PsiBreakStatement statement) {
|
||||
PsiElement exitedElement = statement.findExitedElement();
|
||||
if (exitedElement instanceof PsiSwitchExpression) {
|
||||
if (myForCompletion) {
|
||||
myExpr = (PsiExpression)exitedElement;
|
||||
}
|
||||
exitedElement.getParent().accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
public class ConstConfig {
|
||||
int test(boolean aaaaaaaa) {
|
||||
Boolean b;
|
||||
if ((b = switch (0) {
|
||||
case 1: {
|
||||
break aaaa<caret>;
|
||||
}
|
||||
default: break false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class ConstConfig {
|
||||
int test(boolean aaaaaaaa) {
|
||||
Boolean b;
|
||||
if ((b = switch (0) {
|
||||
case 1: {
|
||||
break aaaaaaaa<caret>;
|
||||
}
|
||||
default: break false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class ConstConfig {
|
||||
int test(boolean aaaaaaaa) {
|
||||
Boolean b;
|
||||
if ((b = switch (0) {
|
||||
case 1 -> aaaa<caret>;
|
||||
default -> break false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class ConstConfig {
|
||||
int test(boolean aaaaaaaa) {
|
||||
Boolean b;
|
||||
if ((b = switch (0) {
|
||||
case 1 -> aaaaaaaa<caret>;
|
||||
default -> break false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,6 @@ class Normal12CompletionTest extends NormalCompletionTestCase {
|
||||
void testSecondLabelInRuleSwitch() throws Throwable { doTest() }
|
||||
void testSwitchExpressionStart() throws Throwable { doTest() }
|
||||
void testBreakInSwitchExpression() throws Throwable { doTest() }
|
||||
void testInsideBreakInSwitchExpression() throws Throwable { doTest() }
|
||||
void testInsideRuleInSwitchExpression() throws Throwable { doTest() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user