From 5a3132419e904be0de0421e6fb95a0b889dde20f Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 15 Feb 2017 16:39:24 +0100 Subject: [PATCH] IDEA-168214 Unexpected live templates in extends completion --- .../codeInsight/template/JavaCodeContextType.java | 2 +- .../codeInsight/template/LiveTemplateTest.groovy | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/template/JavaCodeContextType.java b/java/java-impl/src/com/intellij/codeInsight/template/JavaCodeContextType.java index 9e3a12919f6c..45e8e5bf02e0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/JavaCodeContextType.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/JavaCodeContextType.java @@ -129,7 +129,7 @@ public abstract class JavaCodeContextType extends TemplateContextType { if (((PsiJavaCodeReferenceElement)parent).isQualified()) { return false; } - if (parent.getParent() instanceof PsiMethodCallExpression) { + if (parent.getParent() instanceof PsiMethodCallExpression || parent.getParent() instanceof PsiReferenceList) { return false; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index e711200ee90f..59a5918e6df5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -593,12 +593,13 @@ class Outer { void testJavaExpressionContext() { final TemplateImpl template = TemplateSettings.getInstance().getTemplate("toar", "other") - assertFalse(isApplicable("class Foo {{ if (a toar) }}", template)) - assertTrue(isApplicable("class Foo {{ toar }}", template)) - assertTrue(isApplicable("class Foo {{ return (toar) }}", template)) - assertFalse(isApplicable("class Foo {{ return (aaa toar) }}", template)) - assertTrue(isApplicable("class Foo {{ Runnable r = () -> { System.out.println(\"foo\"); }; ) }}", template)) - assertTrue(isApplicable("class Foo {{ Runnable r = () -> System.out.println(\"foo\"); ) }}", template)) + assert !isApplicable("class Foo {{ if (a toar) }}", template) + assert isApplicable("class Foo {{ toar }}", template) + assert isApplicable("class Foo {{ return (toar) }}", template) + assert !isApplicable("class Foo {{ return (aaa toar) }}", template) + assert isApplicable("class Foo {{ Runnable r = () -> { System.out.println(\"foo\"); }; ) }}", template) + assert isApplicable("class Foo {{ Runnable r = () -> System.out.println(\"foo\"); ) }}", template) + assert !isApplicable("class Foo extends t {}", template) } void testJavaDeclarationContext() {