EA-72085 - NPE: ChangeToAppendUtil.buildAppendExpression
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Mon, 24 Aug 2015 16:16:02 +0000 (19:16 +0300)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Mon, 24 Aug 2015 17:00:17 +0000 (20:00 +0300)
java/java-analysis-impl/src/com/intellij/codeInspection/util/ChangeToAppendUtil.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeToAppend/beforeNoRExpr.java [new file with mode: 0644]

index e1ee7a4885d6a64034270d1f43e728abc824eddd..9327bdfbded1c588b865f754febdf00598d83944 100644 (file)
@@ -34,7 +34,8 @@ public class ChangeToAppendUtil {
   }
 
   @Nullable
-  public static StringBuilder buildAppendExpression(PsiExpression concatenation, boolean useStringValueOf, @NonNls StringBuilder out) {
+  public static StringBuilder buildAppendExpression(@Nullable PsiExpression concatenation, boolean useStringValueOf, @NonNls StringBuilder out) {
+    if (concatenation == null) return null;
     final PsiType type = concatenation.getType();
     if (concatenation instanceof PsiPolyadicExpression && type != null && type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
       final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)concatenation;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeToAppend/beforeNoRExpr.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeToAppend/beforeNoRExpr.java
new file mode 100644 (file)
index 0000000..25a0df2
--- /dev/null
@@ -0,0 +1,7 @@
+// "Change to 'builder.append()'" "false"
+class Test {
+  String s;
+  void bar(StringBuilder builder) {
+    buil<caret>der += ;
+  }
+}
\ No newline at end of file