mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
keep comments (IDEA-140861)
This commit is contained in:
+1
-1
@@ -292,7 +292,7 @@ public class SimplifyBooleanExpressionFix extends LocalQuickFixOnPsiElement {
|
||||
|
||||
public static void simplifyExpression(PsiExpression expression) throws IncorrectOperationException {
|
||||
final PsiExpression result = createSimplifiedReplacement(expression);
|
||||
PsiExpression newExpression = (PsiExpression)expression.replace(result);
|
||||
PsiExpression newExpression = (PsiExpression)new CommentTracker().replaceAndRestoreComments(expression, result);
|
||||
if (newExpression instanceof PsiLiteralExpression) {
|
||||
final PsiElement parent = newExpression.getParent();
|
||||
if (parent instanceof PsiAssertStatement && ((PsiLiteralExpression)newExpression).getValue() == Boolean.TRUE) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Simplify boolean expression" "true"
|
||||
class A {
|
||||
public static void m(boolean fullSearch, boolean partialSearch) {
|
||||
|
||||
|
||||
if (!partialSearch) {
|
||||
return;
|
||||
}
|
||||
|
||||
String str
|
||||
= fullSearch ? "str1"
|
||||
: <warning descr="Condition 'partialSearch' is always 'true'"><caret>partialSearch</warning> ? "str2 " + "str3" // comment
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Simplify boolean expression" "true"
|
||||
class A {
|
||||
public static void m(boolean fullSearch, boolean partialSearch) {
|
||||
|
||||
|
||||
if (!partialSearch) {
|
||||
return;
|
||||
}
|
||||
|
||||
// comment
|
||||
String str
|
||||
= fullSearch ? "str1"
|
||||
: "str2 " + "str3";
|
||||
}
|
||||
}
|
||||
@@ -280,6 +280,11 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testFinalGetter() { doTest(); }
|
||||
public void testGetterResultsNotSame() { doTest(); }
|
||||
public void testIntersectionTypeInstanceof() { doTest(); }
|
||||
|
||||
public void testKeepComments() {
|
||||
doTest();
|
||||
checkIntentionResult("Simplify");
|
||||
}
|
||||
|
||||
public void testImmutableClassNonGetterMethod() {
|
||||
myFixture.addClass("package javax.annotation.concurrent; public @interface Immutable {}");
|
||||
|
||||
Reference in New Issue
Block a user