mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-113298 (replace assertTrue with assertFalse removes message)
This commit is contained in:
@@ -78,12 +78,13 @@ public class FlipAssertLiteralIntention extends MutablyNamedIntention {
|
||||
}
|
||||
newCall.append(toMethodName).append('(');
|
||||
final PsiExpressionList argumentList = call.getArgumentList();
|
||||
final PsiExpression[] args = argumentList.getExpressions();
|
||||
if (args.length == 1) {
|
||||
newCall.append(BoolUtils.getNegatedExpressionText(args[0]));
|
||||
final PsiExpression[] arguments = argumentList.getExpressions();
|
||||
if (arguments.length == 1) {
|
||||
newCall.append(BoolUtils.getNegatedExpressionText(arguments[0]));
|
||||
}
|
||||
else {
|
||||
newCall.append(BoolUtils.getNegatedExpressionText(args[1]));
|
||||
newCall.append(arguments[0].getText()).append(',');
|
||||
newCall.append(BoolUtils.getNegatedExpressionText(arguments[1]));
|
||||
}
|
||||
newCall.append(')');
|
||||
replaceExpression(newCall.toString(), call);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.siyeh.ipp.junit.flip_assert_literal;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
class Messsage {
|
||||
void test(boolean b) {
|
||||
<caret>Assert.assertTrue("message", !b);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.siyeh.ipp.junit.flip_assert_literal;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
class Messsage {
|
||||
void test(boolean b) {
|
||||
Assert.assertFalse("message", b);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* (c) 2013 Desert Island BV
|
||||
* created: 08 09 2013
|
||||
*/
|
||||
package com.siyeh.ipp.junit;
|
||||
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.IPPTestCase;
|
||||
|
||||
/**
|
||||
* @see FlipAssertLiteralIntention
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class FlipAssertLiteralIntentionTest extends IPPTestCase {
|
||||
|
||||
public void testMessage() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.addClass("package org.junit;" +
|
||||
"class Assert {" +
|
||||
" public static void assertTrue(java.lang.String message, boolean condition) {}" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRelativePath() {
|
||||
return "junit/flip_assert_literal";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
return IntentionPowerPackBundle.message("flip.assert.literal.intention.name", "assertTrue", "assertFalse");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user