diff --git a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/GroovyUtils.java b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/GroovyUtils.java index 267d2d1ce6..ae2e99a7d8 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/GroovyUtils.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/GroovyUtils.java @@ -285,7 +285,7 @@ public static String getTypeSignatureWithoutGenerics(ClassNode node, boolean qua String name; if (node.isGenericsPlaceHolder()) { // use "T" instead of "Object" - name = node.getUnresolvedName(); + name = node.getUnresolvedName().replace('#', '!'); } else if (resolved || node.getOuterClass() == null) { name = qualified ? node.getName() : node.getNameWithoutPackage(); } else { diff --git a/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectMethodsTests.groovy b/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectMethodsTests.groovy index 5d2a2975c0..287fde75c0 100644 --- a/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectMethodsTests.groovy +++ b/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectMethodsTests.groovy @@ -510,19 +510,34 @@ final class CodeSelectMethodsTests extends BrowsingTestSuite { @Test void testCodeSelectStaticMethod3() { - String contents = 'class Foo { def m() { java.util.Collections.emptyList() } }' + String contents = 'def list = java.util.Collections.emptyList()' assertCodeSelect([contents], 'Collections') + IJavaElement element = assertCodeSelect([contents], 'emptyList') + assert element.inferredElement.returnType.toString(false) == 'java.util.List' + assert element.key == 'Ljava/util/Collections;.emptyList()Ljava/util/List;%' } @Test void testCodeSelectStaticMethod4() { - String contents = 'List empty = Collections.&emptyList' + String contents = 'java.util.function.Supplier getter = Collections.&emptyList' IJavaElement element = assertCodeSelect([contents], 'emptyList') - assert element.inferredElement.returnType.toString(false) == 'java.util.List' // TODO: want T to be java.lang.String + assert element.inferredElement.returnType.toString(false) == 'java.util.List' + assert element.key == 'Ljava/util/Collections;.emptyList()Ljava/util/List;%' } - @Test + @Test // https://github.com/groovy/groovy-eclipse/issues/1595 void testCodeSelectStaticMethod5() { + String contents = '''\ + |@groovy.transform.TypeChecked test() { + | def list = Collections.emptyList() + |}'''.stripMargin() + IJavaElement element = assertCodeSelect([contents], 'emptyList') + assert element.inferredElement.returnType.toString(false) == 'java.util.List' // TODO: want T to be java.lang.Object + assert element.key == 'Ljava/util/Collections;.emptyList()Ljava/util/List;%' + } + + @Test + void testCodeSelectStaticMethod6() { String contents = '''\ |import static java.util.Collections.singletonList |@groovy.transform.TypeChecked @@ -533,10 +548,11 @@ final class CodeSelectMethodsTests extends BrowsingTestSuite { |}'''.stripMargin() IJavaElement element = assertCodeSelect([contents], 'singletonList') assert element.inferredElement.returnType.toString(false) == 'java.util.List' + assert element.key == 'Ljava/util/Collections;.singletonList(Ljava/lang/String;)Ljava/util/List;%' } @Test - void testCodeSelectStaticMethod6() { + void testCodeSelectStaticMethod7() { String contents = '''\ |@groovy.transform.Sortable |class Foo { @@ -549,7 +565,7 @@ final class CodeSelectMethodsTests extends BrowsingTestSuite { } @Test - void testCodeSelectStaticMethod7() { + void testCodeSelectStaticMethod8() { String contents = '''\ |@Singleton(property='foo') |class Foo {