@Test public void getWildcardTypeName() { Assert.assertEquals("?", PsiTypeUtils.getWildcardTypeName("?").toString()); Assert.assertEquals("? super T", PsiTypeUtils.getWildcardTypeName("? super T").toString()); Assert.assertEquals( "? extends com.some.Node", PsiTypeUtils.getWildcardTypeName("? extends com.some.Node").toString()); Assert.assertEquals( "? super com.A", PsiTypeUtils.getWildcardTypeName("? super com.A & com.B").toString()); }
@VisibleForTesting static TypeName getWildcardTypeName(String wildcardTypeName) { if (wildcardTypeName.equals("?")) { return WildcardTypeName.subtypeOf(Object.class); } Matcher matcher = SUPER_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.supertypeOf(guessClassName(matcher.group(1))); } matcher = EXTENDS_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.subtypeOf(guessClassName(matcher.group(1))); } return guessClassName(wildcardTypeName); }
PsiTypeUtils { @VisibleForTesting static TypeName getWildcardTypeName(String wildcardTypeName) { if (wildcardTypeName.equals("?")) { return WildcardTypeName.subtypeOf(Object.class); } Matcher matcher = SUPER_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.supertypeOf(guessClassName(matcher.group(1))); } matcher = EXTENDS_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.subtypeOf(guessClassName(matcher.group(1))); } return guessClassName(wildcardTypeName); } }
PsiTypeUtils { @VisibleForTesting static TypeName getWildcardTypeName(String wildcardTypeName) { if (wildcardTypeName.equals("?")) { return WildcardTypeName.subtypeOf(Object.class); } Matcher matcher = SUPER_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.supertypeOf(guessClassName(matcher.group(1))); } matcher = EXTENDS_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.subtypeOf(guessClassName(matcher.group(1))); } return guessClassName(wildcardTypeName); }  }
PsiTypeUtils { @VisibleForTesting static TypeName getWildcardTypeName(String wildcardTypeName) { if (wildcardTypeName.equals("?")) { return WildcardTypeName.subtypeOf(Object.class); } Matcher matcher = SUPER_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.supertypeOf(guessClassName(matcher.group(1))); } matcher = EXTENDS_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.subtypeOf(guessClassName(matcher.group(1))); } return guessClassName(wildcardTypeName); }   }
PsiTypeUtils { @VisibleForTesting static TypeName getWildcardTypeName(String wildcardTypeName) { if (wildcardTypeName.equals("?")) { return WildcardTypeName.subtypeOf(Object.class); } Matcher matcher = SUPER_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.supertypeOf(guessClassName(matcher.group(1))); } matcher = EXTENDS_PATTERN.matcher(wildcardTypeName); if (matcher.find()) { return WildcardTypeName.subtypeOf(guessClassName(matcher.group(1))); } return guessClassName(wildcardTypeName); }    }