EA-26355: don't produce wildcards in gdsl

This commit is contained in:
peter
2011-03-30 19:40:53 +02:00
parent f7586fb6c4
commit 931519ed0f
2 changed files with 12 additions and 2 deletions
@@ -25,6 +25,7 @@ import static standardDsls.Constants.STRING
interface Constants {
String NUMBER = "java.lang.Number"
String STRING = "java.lang.String"
String WILDCARD_PREFIX = "? extends "
}
def extractTypeParameter(def typeText) {
@@ -32,8 +33,13 @@ def extractTypeParameter(def typeText) {
final int end = typeText.lastIndexOf('>')
if (start < 0) return null
if (end < 0) return typeText.substring(start + 1)
return typeText.substring(start + 1, end);
String componentType = end < 0 ? typeText.substring(start + 1) : typeText.substring(start + 1, end)
if (componentType.startsWith(Constants.WILDCARD_PREFIX)) {
componentType = componentType.substring(Constants.WILDCARD_PREFIX.size())
}
return componentType;
}
def constructElementTypeArg(def psiType) {
@@ -346,6 +346,10 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
doTest(new GroovyResultOfAssignmentUsedInspection());
}
public void testGdslWildcardTypes() {
myFixture.configureByText("a.groovy", "List<? extends String> l = []; l.get(1)");
myFixture.checkHighlighting(true, false, false);
}
public void testThisTypeInStaticContext() {
doTest(new GroovyAssignabilityCheckInspection());