mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DeleteSideEffectsAwareFix: fix removal of for-update statement
GitOrigin-RevId: 15a64c215cc98f4f94b76edc3486bcf762a8be28
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc97cbbd2c
commit
f127b4491c
+3
-1
@@ -109,7 +109,9 @@ public class DeleteSideEffectsAwareFix extends LocalQuickFixAndIntentionActionOn
|
||||
statement = Objects.requireNonNull(PsiTreeUtil.getNextSiblingOfType(lastAdded, PsiStatement.class));
|
||||
}
|
||||
PsiElement parent = statement.getParent();
|
||||
if (parent instanceof PsiStatement && !(parent instanceof PsiIfStatement && ((PsiIfStatement)parent).getElseBranch() == statement)) {
|
||||
if (parent instanceof PsiStatement &&
|
||||
!(parent instanceof PsiIfStatement && ((PsiIfStatement)parent).getElseBranch() == statement) &&
|
||||
!(parent instanceof PsiForStatement && ((PsiForStatement)parent).getUpdate() == statement)) {
|
||||
ct.replaceAndRestoreComments(statement, "{}");
|
||||
} else {
|
||||
ct.deleteAndRestoreComments(statement);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Delete element" "true"
|
||||
class X {
|
||||
void test() {
|
||||
for (int i = 0; i < Integer.MAX_VALUE; ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Delete element" "true"
|
||||
class X {
|
||||
void test() {
|
||||
for (int i = 0; i < Integer.MAX_VALUE; i<caret> *= 2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DeleteRedundantUpdateFixTest extends LightQuickFixParameterizedTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new DataFlowInspection()};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return LightJavaCodeInsightFixtureTestCase.JAVA_10_ANNOTATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/deleteRedundantUpdate";
|
||||
}
|
||||
}
|
||||
+1
@@ -69,6 +69,7 @@ import org.junit.runners.Suite;
|
||||
RedundantInstanceofFixTest.class,
|
||||
ReplaceComputeWithComputeIfPresentFixTest.class,
|
||||
DeleteSwitchLabelFixTest.class,
|
||||
DeleteRedundantUpdateFixTest.class
|
||||
})
|
||||
public class DataFlowInspectionTestSuite {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user