mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-intentions] ConvertSwitchToIfIntention: avoid duplicating comments when extracting side effect
GitOrigin-RevId: a76e34111f7a733071d2397e0a9c0a0a4d51d175
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a2989f2a84
commit
4b9af8fc7b
+1
@@ -193,6 +193,7 @@ public class ConvertSwitchToIfIntention implements IntentionActionWithFixAllOpti
|
||||
JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
|
||||
if (hadSideEffects) {
|
||||
if (declarationString == null) {
|
||||
sideEffectExpressions.forEach(commentTracker::markUnchanged);
|
||||
PsiStatement[] statements = StatementExtractor.generateStatements(sideEffectExpressions, switchExpression);
|
||||
for (PsiStatement statement : statements) {
|
||||
javaCodeStyleManager.shortenClassReferences(parent.addBefore(statement, switchStatement));
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Unwrap 'switch'" "true-preview"
|
||||
class X {
|
||||
void test(int i) {
|
||||
int x;
|
||||
x = ((--i/*text*/) + "1" + (++i) + "1");
|
||||
System.out.println("1");
|
||||
;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Unwrap 'switch'" "true-preview"
|
||||
class X {
|
||||
void test(int i) {
|
||||
int x;
|
||||
<caret>switch ("1" + (x= ((--i/*text*/) + "1" + (++i) + "1"))) {
|
||||
default -> System.out.println("1");
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user