diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java index 4f680b316071..f073953d0810 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java @@ -380,7 +380,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo } } } - variableName = ((PsiVariable)resolve).getName() + "."; + variableName = qualifierExpression.getText() + "."; } } else if (qualifierExpression == null) { variableName = ""; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnotherInstance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnotherInstance.java new file mode 100644 index 000000000000..13bdc5459fd3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnotherInstance.java @@ -0,0 +1,13 @@ +// "Replace with collect" "true" +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +class Sample { + List foo = new ArrayList<>(); + String foo(){ + Sample sm = new Sample(); + sm.foo.addAll(foo.stream().collect(Collectors.toList())); + return null; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnotherInstance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnotherInstance.java new file mode 100644 index 000000000000..e0d9d2ed91ed --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnotherInstance.java @@ -0,0 +1,14 @@ +// "Replace with collect" "true" +import java.util.ArrayList; +import java.util.List; + +class Sample { + List foo = new ArrayList<>(); + String foo(){ + Sample sm = new Sample(); + for (String s : foo) { + sm.foo.add(s); + } + return null; + } +}