mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspection] IDEA-340970 don't offer fix if yield statement is broken
GitOrigin-RevId: 414d7230cd3887b5a92664582a42c8775ccf753a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
94c9f55c96
commit
d97f659b90
+5
-2
@@ -574,7 +574,7 @@ public final class EnhancedSwitchMigrationInspection extends AbstractBaseJavaLoc
|
||||
PsiStatement statement = result[i];
|
||||
if (statement instanceof PsiReturnStatement returnStatement) {
|
||||
PsiExpression returnValue = returnStatement.getReturnValue();
|
||||
if (returnValue == null) {
|
||||
if (returnValue == null || PsiTreeUtil.hasErrorElements(returnValue)) {
|
||||
return null;
|
||||
}
|
||||
result[i] = createYieldStatement(returnValue);
|
||||
@@ -585,7 +585,7 @@ public final class EnhancedSwitchMigrationInspection extends AbstractBaseJavaLoc
|
||||
Collection<PsiReturnStatement> returnStatements = PsiTreeUtil.findChildrenOfType(copy, PsiReturnStatement.class);
|
||||
for (PsiReturnStatement returnStatement : returnStatements) {
|
||||
PsiExpression returnValue = returnStatement.getReturnValue();
|
||||
if (returnValue == null) {
|
||||
if (returnValue == null || PsiTreeUtil.hasErrorElements(returnValue)) {
|
||||
return null;
|
||||
}
|
||||
returnStatement.replace(createYieldStatement(returnValue));
|
||||
@@ -763,6 +763,9 @@ public final class EnhancedSwitchMigrationInspection extends AbstractBaseJavaLoc
|
||||
result = new SwitchRuleExpressionResult(rExpression);
|
||||
}
|
||||
else {
|
||||
if (PsiTreeUtil.hasErrorElements(rExpression)) {
|
||||
return null;
|
||||
}
|
||||
result = new SwitchStatementBranch(withLastStatementReplacedWithYield(statements, rExpression));
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with 'switch' expression" "false"
|
||||
import java.util.*;
|
||||
|
||||
class Switch {
|
||||
void test(Integer o) {
|
||||
String s = "";
|
||||
s<caret>witch (o) {
|
||||
case 1:
|
||||
s = "";
|
||||
break;
|
||||
default:
|
||||
System.out.println("1");
|
||||
s = {System.out.println("break");
|
||||
break;
|
||||
} ;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user