don't produce type canonical texts with ?extends (EA-47528)

This commit is contained in:
peter
2013-07-11 17:30:09 +02:00
parent ddf0867ae7
commit 1f156c6643
2 changed files with 14 additions and 1 deletions
@@ -46,7 +46,15 @@ public class SourceUtil {
@Override
public void visitLeaf(LeafElement leaf) {
if (!REF_FILTER.contains(leaf.getElementType())) {
buffer.append(leaf.getText());
String leafText = leaf.getText();
if (buffer.length() > 0 && leafText.length() > 0 && Character.isJavaIdentifierPart(leafText.charAt(0))) {
char lastInBuffer = buffer.charAt(buffer.length() - 1);
if (lastInBuffer == '?' || Character.isJavaIdentifierPart(lastInBuffer)) {
buffer.append(" ");
}
}
buffer.append(leafText);
}
}
@@ -239,4 +239,9 @@ public class MiscPsiTest extends LightCodeInsightFixtureTestCase {
assertFalse(assertInstanceOf(nestedBlock.getNode(), LazyParseableElement.class).isParsed());
}
public void testTypeCanonicalText() {
PsiType type = JavaPsiFacade.getElementFactory(getProject()).createTypeFromText("some .unknown. Foo<? extends String>", null);
assertEquals("some.unknown.Foo<? extends String>", type.getCanonicalText());
}
}