mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invert boolean: leave expressions with unused return value untouched (IDEA-56568 )
This commit is contained in:
+3
-1
@@ -233,7 +233,9 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
((PsiPrefixExpression)expression.getParent()).getOperationSign().getTokenType() == JavaTokenType.EXCL) {
|
||||
expression = (PsiExpression)expression.getParent();
|
||||
}
|
||||
expression.replace(CodeInsightServicesUtil.invertCondition(expression));
|
||||
if (!(expression.getParent() instanceof PsiExpressionStatement)) {
|
||||
expression.replace(CodeInsightServicesUtil.invertCondition(expression));
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
boolean f<caret>oo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void bar() {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
boolean fooInverted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void bar() {
|
||||
fooInverted();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class InvertBooleanTest extends LightCodeInsightTestCase {
|
||||
public void testParameter() throws Exception { doTest(); } //inverting boolean parameter
|
||||
|
||||
public void testParameter1() throws Exception { doTest(); } //inverting boolean parameter more advanced stuff
|
||||
public void testUnusedReturnValue() throws Exception { doTest(); }
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(TEST_ROOT + getTestName(true) + ".java");
|
||||
|
||||
Reference in New Issue
Block a user