mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-118588 (Concatenation with empty string fails to fix an expression)
This commit is contained in:
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2013 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.
|
||||
@@ -91,7 +91,7 @@ public class TrivialStringConcatenationInspection extends BaseInspection {
|
||||
replaced = true;
|
||||
continue;
|
||||
}
|
||||
if (operand == expression) {
|
||||
if (ParenthesesUtils.stripParentheses(operand) == expression) {
|
||||
seenEmpty = true;
|
||||
continue;
|
||||
}
|
||||
@@ -114,6 +114,7 @@ public class TrivialStringConcatenationInspection extends BaseInspection {
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@NonNls
|
||||
static String buildReplacement(@NotNull PsiExpression operandToReplace, boolean seenString) {
|
||||
if (ExpressionUtils.isNullLiteral(operandToReplace)) {
|
||||
if (seenString) {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.siyeh.igfixes.performance.trivial_string_concatenation;
|
||||
|
||||
class Parentheses2 {
|
||||
void m(String version) {
|
||||
final String s = " (" + "Groovy " + (version) + ")";
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.siyeh.igfixes.performance.trivial_string_concatenation;
|
||||
|
||||
class Parentheses2 {
|
||||
void m(String version) {
|
||||
final String s = " (" + (""<caret>) + "Groovy " + (version) + ")";
|
||||
}
|
||||
}
|
||||
+1
@@ -13,6 +13,7 @@ public class TrivialStringConcatenationFixTest extends IGQuickFixesTestCase {
|
||||
}
|
||||
|
||||
public void testParentheses() { doTest("Replace concatenation with 'completedTiles + \" , \" + (totalTiles - completedTiles)'"); }
|
||||
public void testParentheses2() { doTest("Replace concatenation with '\" (\" + \"Groovy \" + (version) + \")\"'"); }
|
||||
public void testBinaryNull() { doTest("Replace concatenation with 'String.valueOf((Object)null)'"); }
|
||||
public void testAtTheEnd() { doTest("Replace concatenation with '\"asdf\" + 1 + o'"); }
|
||||
}
|
||||
Reference in New Issue
Block a user