[java] PsiType.getPresentableText() not annotated by default (IDEA-158983)

This commit is contained in:
Roman Shevchenko
2016-08-02 09:01:22 -07:00
parent 6c3373cf0d
commit c3386151f6
15 changed files with 64 additions and 42 deletions
@@ -397,9 +397,10 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
if (substitutor != null) {
returnType = substitutor.substitute(returnType);
}
assert returnType != null : method;
appendModifierList(buffer, method);
buffer.append(returnType.getPresentableText());
buffer.append(returnType.getPresentableText(true));
buffer.append(" ");
}
buffer.append(method.getName());
@@ -426,7 +427,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
paramType = substitutor.substitute(paramType);
}
appendModifierList(buffer, param);
buffer.append(paramType.getPresentableText());
buffer.append(paramType.getPresentableText(true));
String name = param.getName();
if (name != null) {
buffer.append(" ");
@@ -42,8 +42,8 @@ public class PsiArrayType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
return getText(myComponentType.getPresentableText(), "[]", false, true);
public String getPresentableText(boolean annotated) {
return getText(myComponentType.getPresentableText(), "[]", false, annotated);
}
@NotNull
@@ -133,8 +133,8 @@ public class PsiCapturedWildcardType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
return "capture of " + myExistential.getPresentableText();
public String getPresentableText(boolean annotated) {
return "capture of " + myExistential.getPresentableText(annotated);
}
@NotNull
@@ -295,18 +295,25 @@ public abstract class PsiClassType extends PsiType {
};
}
/**
* Temporary class to facilitate transition to {@link #getCanonicalText(boolean)}.
*/
public static abstract class Stub extends PsiClassType {
protected Stub(LanguageLevel languageLevel, @NotNull PsiAnnotation[] annotations) {
super(languageLevel, annotations);
}
public Stub(LanguageLevel languageLevel, @NotNull TypeAnnotationProvider annotations) {
protected Stub(LanguageLevel languageLevel, @NotNull TypeAnnotationProvider annotations) {
super(languageLevel, annotations);
}
@NotNull
@Override
public final String getPresentableText() {
return getPresentableText(false);
}
@NotNull
@Override
public abstract String getPresentableText(boolean annotated);
@NotNull
@Override
public final String getCanonicalText() {
@@ -83,11 +83,11 @@ public class PsiDisjunctionType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
public String getPresentableText(final boolean annotated) {
return StringUtil.join(myTypes, new Function<PsiType, String>() {
@Override
public String fun(PsiType psiType) {
return psiType.getPresentableText();
return psiType.getPresentableText(annotated);
}
}, " | ");
}
@@ -43,8 +43,8 @@ public class PsiEllipsisType extends PsiArrayType {
@NotNull
@Override
public String getPresentableText() {
return getText(getComponentType().getPresentableText(), "...", false, true);
public String getPresentableText(boolean annotated) {
return getText(getComponentType().getPresentableText(), "...", false, annotated);
}
@NotNull
@@ -116,11 +116,11 @@ public class PsiIntersectionType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
public String getPresentableText(final boolean annotated) {
return StringUtil.join(myConjuncts, new Function<PsiType, String>() {
@Override
public String fun(PsiType psiType) {
return psiType.getPresentableText();
return psiType.getPresentableText(annotated);
}
}, " & ");
}
@@ -61,8 +61,8 @@ public class PsiPrimitiveType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
return getText(false, true);
public String getPresentableText(boolean annotated) {
return getText(false, annotated);
}
@NotNull
@@ -99,6 +99,14 @@ public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
* Returns text of the type that can be presented to a user (references normally non-qualified).
*/
@NotNull
public String getPresentableText(boolean annotated) {
return getPresentableText();
}
/**
* Same as {@code getPresentableText(false)}.
*/
@NotNull
public abstract String getPresentableText();
/**
@@ -336,9 +344,6 @@ public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
return "PsiType:" + getPresentableText();
}
/**
* Temporary class to facilitate transition to {@link #getCanonicalText(boolean)}.
*/
protected static abstract class Stub extends PsiType {
protected Stub(@NotNull PsiAnnotation[] annotations) {
super(annotations);
@@ -348,6 +353,16 @@ public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
super(annotations);
}
@NotNull
@Override
public final String getPresentableText() {
return getPresentableText(false);
}
@NotNull
@Override
public abstract String getPresentableText(boolean annotated);
@NotNull
@Override
public final String getCanonicalText() {
@@ -83,8 +83,8 @@ public class PsiWildcardType extends PsiType.Stub {
@NotNull
@Override
public String getPresentableText() {
return getText(false, true, myBound == null ? null : myBound.getPresentableText());
public String getPresentableText(boolean annotated) {
return getText(false, annotated, myBound == null ? null : myBound.getPresentableText());
}
@Override
@@ -395,7 +395,7 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
}
}
if (type == null) return "null";
return !BitUtil.isSet(options, SHOW_FQ_CLASS_NAMES) ? type.getPresentableText() :
return !BitUtil.isSet(options, SHOW_FQ_CLASS_NAMES) ? type.getPresentableText(false) :
!BitUtil.isSet(options, USE_INTERNAL_CANONICAL_TEXT) ? type.getCanonicalText(false) :
type.getInternalCanonicalText();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import gnu.trove.THashMap;
import gnu.trove.THashSet;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -62,7 +61,7 @@ public class TypeConversionUtil {
private static final int BOOL_RANK = 10;
private static final int STRING_RANK = 100;
private static final int MAX_NUMERIC_RANK = DOUBLE_RANK;
public static final PsiType NULL_TYPE = new PsiEllipsisType(PsiType.NULL){
public static final PsiType NULL_TYPE = new PsiEllipsisType(PsiType.NULL) {
@Override
public boolean isValid() {
return true;
@@ -70,8 +69,7 @@ public class TypeConversionUtil {
@NotNull
@Override
@NonNls
public String getPresentableText() {
public String getPresentableText(boolean annotated) {
return "FAKE TYPE";
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -153,12 +153,6 @@ class TypeCorrector extends PsiTypeMapper {
myResolveResult = resolveResult;
}
@NotNull
@Override
public String getCanonicalText(boolean annotated) {
return myDelegate.getCanonicalText(annotated);
}
@NotNull
@Override
public PsiClass resolve() {
@@ -224,8 +218,14 @@ class TypeCorrector extends PsiTypeMapper {
@NotNull
@Override
public String getPresentableText() {
return myDelegate.getPresentableText();
public String getPresentableText(boolean annotated) {
return myDelegate.getPresentableText(annotated);
}
@NotNull
@Override
public String getCanonicalText(boolean annotated) {
return myDelegate.getCanonicalText(annotated);
}
@NotNull
@@ -185,9 +185,10 @@ public class PsiClassReferenceType extends PsiClassType.Stub {
@NotNull
@Override
public String getPresentableText() {
public String getPresentableText(boolean annotated) {
String presentableText = PsiNameHelper.getPresentableText(myReference);
PsiAnnotation[] annotations = getAnnotations();
PsiAnnotation[] annotations = annotated ? getAnnotations() : PsiAnnotation.EMPTY_ARRAY;
if (annotations.length == 0) return presentableText;
StringBuilder sb = new StringBuilder();
@@ -151,9 +151,9 @@ public class PsiImmediateClassType extends PsiClassType.Stub {
@NotNull
@Override
public String getPresentableText() {
public String getPresentableText(boolean annotated) {
if (myPresentableText == null) {
myPresentableText = getText(TextType.PRESENTABLE, true);
myPresentableText = getText(TextType.PRESENTABLE, annotated);
}
return myPresentableText;
}