IDEA-53153: Anonymous inner class creation using generics appears red in Groovy code. pycharm/96.21
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Thu, 1 Apr 2010 11:38:17 +0000 (15:38 +0400)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Thu, 1 Apr 2010 11:46:16 +0000 (15:46 +0400)
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrAnonymousClassDefinitionImpl.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
plugins/groovy/testdata/highlighting/AnonymousClassShouldImplementSubstitutedMethod.groovy [new file with mode: 0644]

index ea3aae930cc35fffc30afb8360232cba5e54c917..75088ab2cae20ada28217edc0ed1e891dd42ef92 100644 (file)
@@ -17,9 +17,7 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
-import com.intellij.psi.impl.light.LightClassReference;
 import com.intellij.reference.SoftReference;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -31,6 +29,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousC
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
 import org.jetbrains.plugins.groovy.lang.psi.util.GrClassImplUtil;
 
@@ -76,37 +75,7 @@ public class GrAnonymousClassDefinitionImpl extends GrTypeDefinitionImpl impleme
   @NotNull
   public PsiJavaCodeReferenceElement getBaseClassReference() {
     final GrCodeReferenceElement ref = getBaseClassReferenceGroovy();
-    return new LightClassReference(getManager(), ref.getText(), ref.getReferenceName(), getResolveScope()) {
-      @Override
-      public PsiElement getElement() {
-        return ref;
-      }
-
-      @Override
-      public TextRange getRangeInElement() {
-        return ref.getRangeInElement();
-      }
-
-      @Override
-      public int getStartOffsetInParent() {
-        return ref.getStartOffsetInParent();
-      }
-
-      @Override
-      public TextRange getTextRange() {
-        return ref.getTextRange();
-      }
-
-      @Override
-      public int getTextOffset() {
-        return ref.getTextOffset();
-      }
-
-      @Override
-      public PsiElement resolve() {
-        return ref.resolve();
-      }
-    };
+    return JavaPsiFacade.getElementFactory(getProject()).createReferenceElementByType(new GrClassReferenceType(ref));
   }
 
   @NotNull
index 37b30df69102916c707640ba1a7ea6872a07c17c..ff6c5e95e50584cf9b4fe388a7f3f5646d1ac0e5 100644 (file)
@@ -138,7 +138,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
   public void testAnonymousClassAbstractMethod() throws Throwable {doTest();}
   public void testAnonymousClassStaticMethod() throws Throwable {doTest();}
   public void testAnonymousClassShoudImplementMethods() throws Throwable {doTest();}
-
+  public void testAnonymousClassShouldImplementSubstitutedMethod() throws Exception {doTest();}
 
   public void testDefaultMapConstructorNamedArgs() throws Throwable {doTest();}
   public void testDefaultMapConstructorNamedArgsError() throws Throwable {doTest();}
diff --git a/plugins/groovy/testdata/highlighting/AnonymousClassShouldImplementSubstitutedMethod.groovy b/plugins/groovy/testdata/highlighting/AnonymousClassShouldImplementSubstitutedMethod.groovy
new file mode 100644 (file)
index 0000000..6c88be3
--- /dev/null
@@ -0,0 +1,11 @@
+class TestClass {}
+
+print new Predicate<TestClass>() {
+  boolean evaluate(TestClass test) {
+    return test != null;
+  }
+};
+
+interface Predicate<T> {
+  boolean evaluate(T test)
+}