diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StreamPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StreamPostfixTemplate.java index 86fd754881e4..90548e2977ea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StreamPostfixTemplate.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StreamPostfixTemplate.java @@ -27,6 +27,8 @@ public class StreamPostfixTemplate extends StringBasedPostfixTemplate { private static final Condition IS_SUPPORTED_ARRAY = element -> { if (!(element instanceof PsiExpression)) return false; + if (element instanceof PsiAssignmentExpression && element.getParent() instanceof PsiExpressionStatement) return false; + PsiType type = ((PsiExpression)element).getType(); if (!(type instanceof PsiArrayType)) return false; diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment.java b/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment.java new file mode 100644 index 000000000000..f9792758e60a --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment.java @@ -0,0 +1,9 @@ +package templates; + +public class Foo { + public static void main(String[] args) { + Object[] a; + Object o; + a = o.str + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment_after.java new file mode 100644 index 000000000000..0ff273b1b8af --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/stream/assignment_after.java @@ -0,0 +1,9 @@ +package templates; + +public class Foo { + public static void main(String[] args) { + Object[] a; + Object o; + a = o.str + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java index d5e99532725c..551170aff119 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java @@ -44,6 +44,10 @@ public class StreamPostfixTemplateTest extends PostfixTemplateTestCase { doTest(); } + public void testAssignment() { + doTest(); + } + public void testNotAvailable() { doTest(); }