diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java
index 79c9820b5fb8..e34e8587f3df 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java
@@ -115,12 +115,7 @@ public class SimplifyBooleanExpressionFix extends LocalQuickFixOnPsiElement {
@Override
public void invoke(@NotNull final Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
- if (isAvailable()) {
- doSimplify();
- }
- }
-
- public void doSimplify() {
+ if (!isAvailable()) return;
PsiExpression subExpression = getSubExpression();
if (subExpression == null) return;
if (shouldExtractSideEffect()) {
@@ -144,7 +139,7 @@ public class SimplifyBooleanExpressionFix extends LocalQuickFixOnPsiElement {
return;
}
}
- final PsiElementFactory factory = JavaPsiFacade.getElementFactory(subExpression.getProject());
+ final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
final PsiExpression constExpression = factory.createExpressionFromText(Boolean.toString(mySubExpressionValue), subExpression);
PsiExpression expression = (PsiExpression)subExpression.replace(constExpression);
while (expression.getParent() instanceof PsiExpression) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
index 20d4d7e8349d..21e53acc260d 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -663,7 +663,6 @@ c.style.array.declaration.display.name=C-style array declaration
final.method.in.final.class.display.name='final' method in 'final' class
extends.annotation.display.name=Class extends annotation interface
naked.notify.display.name='notify()' or 'notifyAll()' without corresponding state change
-constant.if.statement.display.name=Constant 'if' statement
switch.statement.density.display.name='switch' statement with too low of a branch density
switch.statement.with.too.few.branches.display.name='switch' statement with too few branches
upper.case.field.name.not.constant.display.name=Non-constant field with upper-case name
@@ -956,7 +955,6 @@ non.final.field.of.exception.problem.descriptor=Non-final field #ref#ref statement #loc
unnecessary.label.on.continue.statement.problem.descriptor=Unnecessary label on #ref statement #loc
trivial.if.problem.descriptor=#ref statement can be simplified #loc
-constant.if.statement.problem.descriptor=#ref statement can be simplified #loc
unnecessary.parentheses.problem.descriptor=Parentheses around #ref are unnecessary #loc
unnecessary.local.variable.problem.descriptor=Local variable #ref is redundant #loc
unnecessary.this.problem.descriptor=#ref is unnecessary in this context #loc
diff --git a/plugins/InspectionGadgets/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/src/META-INF/InspectionGadgets.xml
index ca9409569ac9..f6ad1b6c77cd 100644
--- a/plugins/InspectionGadgets/src/META-INF/InspectionGadgets.xml
+++ b/plugins/InspectionGadgets/src/META-INF/InspectionGadgets.xml
@@ -625,9 +625,6 @@
key="constant.conditional.expression.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.control.flow.issues" enabledByDefault="true" level="WARNING"
implementationClass="com.siyeh.ig.controlflow.ConstantConditionalExpressionInspection"/>
-
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java
deleted file mode 100644
index 22e6cde0157d..000000000000
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2003-2016 Dave Griffith, Bas Leijdekkers
- *
- * 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.siyeh.ig.controlflow;
-
-import com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpressionFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiIfStatement;
-import com.intellij.psi.PsiStatement;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.BaseInspection;
-import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.InspectionGadgetsFix;
-import com.siyeh.ig.psiutils.BoolUtils;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Objects;
-
-public class ConstantIfStatementInspection extends BaseInspection {
-
- @Override
- @NotNull
- public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "constant.if.statement.display.name");
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- @NotNull
- protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "constant.if.statement.problem.descriptor");
- }
-
- @Override
- public BaseInspectionVisitor buildVisitor() {
- return new ConstantIfStatementVisitor();
- }
-
- @Override
- public InspectionGadgetsFix buildFix(Object... infos) {
- return new ConstantIfStatementFix();
- }
-
- private static class ConstantIfStatementFix extends InspectionGadgetsFix {
-
- @Override
- @NotNull
- public String getFamilyName() {
- return InspectionGadgetsBundle.message(
- "constant.conditional.expression.simplify.quickfix");
- }
-
- @Override
- public void doFix(Project project, ProblemDescriptor descriptor) {
- PsiElement ifKeyword = descriptor.getPsiElement();
- PsiExpression condition = Objects.requireNonNull(((PsiIfStatement)ifKeyword.getParent()).getCondition());
- new SimplifyBooleanExpressionFix(condition, BoolUtils.isTrue(condition)).doSimplify();
- }
-
- }
-
- private static class ConstantIfStatementVisitor
- extends BaseInspectionVisitor {
-
- @Override
- public void visitIfStatement(PsiIfStatement statement) {
- super.visitIfStatement(statement);
- final PsiExpression condition = statement.getCondition();
- if (condition == null) {
- return;
- }
- final PsiStatement thenBranch = statement.getThenBranch();
- if (thenBranch == null) {
- return;
- }
- if (BoolUtils.isTrue(condition) || BoolUtils.isFalse(condition)) {
- registerStatementError(statement);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html
deleted file mode 100644
index 791cf4e41102..000000000000
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-Reports if statements of the form
-if(true)... or if(false)....
-These statements sometimes occur due to automatic refactorings, and may obviously
-be simplified.
-
-
-
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.after.java
deleted file mode 100644
index ab585746b99e..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.after.java
+++ /dev/null
@@ -1,6 +0,0 @@
-class Test {
- {
- // this comment will be deleted.
- System.out.println();
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.java
deleted file mode 100644
index 21b1a2d973a3..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/constant_if/Comment.java
+++ /dev/null
@@ -1,8 +0,0 @@
-class Test {
- {
- if (true) {
- // this comment will be deleted.
- System.out.println();
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConstantIfStatementInspectionTest.groovy b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConstantIfStatementInspectionTest.groovy
deleted file mode 100644
index 17a9be1a46c5..000000000000
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConstantIfStatementInspectionTest.groovy
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
- */
-package com.siyeh.ig.controlflow;
-
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.siyeh.ig.LightInspectionTestCase;
-
-/**
- * @author Bas Leijdekkers
- */
-class ConstantIfStatementInspectionTest extends LightInspectionTestCase {
-
- void testParentheses() {
- doStatementTest("""/*'if' statement can be simplified*/if/**/ (((false))) {
- System.out.println(1);
- } else {
- System.out.println(2);
- }""");
- }
-
- void "test remove following statements when body always returns via break"() {
- myFixture.configureByText"a.java", """
-class Foo {
- void f(){
- while (true) {
- if (true) {
- break;//comment
- }
- System.out.println();
- }
- }
-}
-"""
- myFixture.enableInspections(getInspection())
- myFixture.checkHighlighting()
- myFixture.launchAction(myFixture.findSingleIntention("Simplify"))
- myFixture.checkResult """
-class Foo {
- void f(){
- while (true) {
- break;//comment
- }
- }
-}
-"""
- }
-
- @Override
- protected InspectionProfileEntry getInspection() {
- return new ConstantIfStatementInspection();
- }
-}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/ConstantIfFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/ConstantIfFixTest.java
deleted file mode 100644
index 7613d1818b14..000000000000
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/ConstantIfFixTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2000-2013 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.siyeh.ig.fixes.controlflow;
-
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.IGQuickFixesTestCase;
-import com.siyeh.ig.controlflow.ConstantIfStatementInspection;
-
-public class ConstantIfFixTest extends IGQuickFixesTestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- myFixture.enableInspections(new ConstantIfStatementInspection());
- myRelativePath = "controlflow/constant_if";
- myDefaultHint = InspectionGadgetsBundle.message("constant.conditional.expression.simplify.quickfix");
- }
-
- public void testComment() { doTest(); }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/SimplifiableEqualsExpressionFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/SimplifiableEqualsExpressionFixTest.java
index 1ec9847167d1..b9e3a2432614 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/SimplifiableEqualsExpressionFixTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/SimplifiableEqualsExpressionFixTest.java
@@ -17,7 +17,6 @@ package com.siyeh.ig.fixes.controlflow;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.IGQuickFixesTestCase;
-import com.siyeh.ig.controlflow.ConstantIfStatementInspection;
import com.siyeh.ig.controlflow.SimplifiableEqualsExpressionInspection;
public class SimplifiableEqualsExpressionFixTest extends IGQuickFixesTestCase {