diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java index c575fda495b7..0b4dc267bf66 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java @@ -91,20 +91,42 @@ public class TypeInfo { public final boolean isEllipsis; private final List myAnnotationStubs; - public TypeInfo(StringRef text, byte arrayCount, boolean ellipsis, @NotNull List annotationStubs) { - this.text = text; - this.arrayCount = arrayCount; + public TypeInfo(StringRef _text, byte _arrayCount, boolean ellipsis, @NotNull List annotationStubs) { + text = _text; + arrayCount = _arrayCount; isEllipsis = ellipsis; myAnnotationStubs = annotationStubs; } public TypeInfo(@NotNull TypeInfo typeInfo) { - this.text = typeInfo.text; - this.arrayCount = typeInfo.arrayCount; + text = typeInfo.text; + arrayCount = typeInfo.arrayCount; isEllipsis = typeInfo.isEllipsis; myAnnotationStubs = new SmartList(typeInfo.myAnnotationStubs); } + public void addAnnotation(PsiAnnotationStub annotation) { + myAnnotationStubs.add(annotation); + } + + @NotNull + public String getShortTypeText() { + if (text == null) return ""; + String name = PsiNameHelper.getShortClassName(text.getString()); + if (arrayCount > 0) { + name += StringUtil.repeat("[]", arrayCount); + } + return name; + } + + @Override + public String toString() { + String text = createTypeText(this); + return text != null ? text : "null"; + } + + /* factories and serialization */ + @NotNull public static TypeInfo createConstructorType() { return NULL; @@ -162,7 +184,7 @@ public class TypeInfo { } @NotNull - public static TypeInfo fromString(String typeText, boolean isEllipsis) { + public static TypeInfo fromString(@NotNull String typeText, boolean isEllipsis) { assert !typeText.endsWith("...") : typeText; byte arrayCount = 0; @@ -277,15 +299,4 @@ public class TypeInfo { return buf.toString(); } - - public void addAnnotation(PsiAnnotationStub annotation) { - myAnnotationStubs.add(annotation); - } - - @NotNull - public String getShortTypeText() { - if (text == null) return ""; - String name = PsiNameHelper.getShortClassName(text.getString()); - return arrayCount > 0 ? name + StringUtil.repeat("[]", arrayCount) : name; - } }