mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
[java-intentions] Reenable side-effect extraction for bare loop and if bodies (follow-up to IDEA-356722)
GitOrigin-RevId: 8fe8b5b70f19cf1cb3b268edbacc07abcb155f3d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3d09381950
commit
f19d9e91d8
+4
-1
@@ -1867,7 +1867,10 @@ public final class HighlightUtil {
|
||||
List<IntentionAction> registrar = new ArrayList<>();
|
||||
HighlightFixUtil.registerFixesForExpressionStatement(statement, registrar);
|
||||
QuickFixAction.registerQuickFixActions(error, null, registrar);
|
||||
if (expressionStatement.getParent() instanceof PsiCodeBlock) {
|
||||
PsiElement parent = expressionStatement.getParent();
|
||||
if (parent instanceof PsiCodeBlock ||
|
||||
parent instanceof PsiIfStatement ||
|
||||
parent instanceof PsiLoopStatement loop && loop.getBody() == expressionStatement) {
|
||||
IntentionAction action = PriorityIntentionActionWrapper
|
||||
.lowPriority(getFixFactory().createDeleteSideEffectAwareFix(expressionStatement));
|
||||
error.registerFix(action, null, null, null, null);
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Extract side effects as an 'if' statement" "true-preview"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
int i = 0;
|
||||
if (true) {
|
||||
if ((i < 100)) {
|
||||
i++;
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Extract side effects as an 'if' statement" "true-preview"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
int i = 0;
|
||||
for(int j=0;j<100;j++) {
|
||||
if ((i < 100)) {
|
||||
i++;
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Extract side effects as an 'if' statement" "true-preview"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
int i = 0;
|
||||
if (true) (<caret>i < 100) ? i++ : i--
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Extract side effects as an 'if' statement" "true-preview"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
int i = 0;
|
||||
for(int j=0;j<100;j++) (<caret>i < 100) ? i++ : i--
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user