mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[intention-preview] IDEA-317060 fix creation of a statement from expression
GitOrigin-RevId: 95c10072de86b6c86354823c9dec8a828bebcef4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8b508e991d
commit
cab7eb3b00
+1
@@ -45,6 +45,7 @@ public final class RemoveUnusedVariableUtil {
|
||||
List<PsiElement> sideEffects = new ArrayList<>();
|
||||
boolean hasSideEffects = checkSideEffects(element, variableToIgnore, sideEffects);
|
||||
if (!hasSideEffects || sideEffects.isEmpty()) return RemoveMode.DELETE_ALL;
|
||||
if (!PsiUtil.isStatement(element)) return RemoveMode.DELETE_ALL;
|
||||
return RemoveMode.MAKE_STATEMENT;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Remove redundant initializer" "true-preview"
|
||||
class A {
|
||||
void test2(){
|
||||
|
||||
String str;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Remove redundant initializer" "true-preview"
|
||||
class A {
|
||||
void test2(){
|
||||
|
||||
String str = switch<caret> (1) {
|
||||
case 1 -> "a";
|
||||
default ->
|
||||
{
|
||||
str = "b";
|
||||
System.out.println(str);
|
||||
yield str + "c";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user