mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
implement PsiType.annotate in all subclasses using clone
This commit is contained in:
@@ -40,12 +40,6 @@ public class PsiArrayType extends PsiType.Stub {
|
||||
myComponentType = componentType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiArrayType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
return provider == getAnnotationProvider() ? this : new PsiArrayType(myComponentType, provider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
|
||||
@@ -35,12 +35,6 @@ public class PsiEllipsisType extends PsiArrayType {
|
||||
super(componentType, provider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiEllipsisType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
return provider == getAnnotationProvider() ? this : new PsiEllipsisType(getComponentType(), provider);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */
|
||||
@SuppressWarnings("unused")
|
||||
public static PsiType createEllipsis(@NotNull PsiType componentType, @NotNull PsiAnnotation[] annotations) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PsiPrimitiveType extends PsiType.Stub {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiPrimitiveType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
return provider == getAnnotationProvider() ? this : new PsiPrimitiveType(myName, provider);
|
||||
return (PsiPrimitiveType)super.annotate(provider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
@@ -26,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Representation of Java type (primitive type, array or class type).
|
||||
*/
|
||||
public abstract class PsiType implements PsiAnnotationOwner {
|
||||
public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
|
||||
@SuppressWarnings("StaticInitializerReferencesSubClass") public static final PsiPrimitiveType BYTE = new PsiPrimitiveType("byte", "java.lang.Byte");
|
||||
@SuppressWarnings("StaticInitializerReferencesSubClass") public static final PsiPrimitiveType CHAR = new PsiPrimitiveType("char", "java.lang.Character");
|
||||
@SuppressWarnings("StaticInitializerReferencesSubClass") public static final PsiPrimitiveType DOUBLE = new PsiPrimitiveType("double", "java.lang.Double");
|
||||
@@ -46,14 +45,13 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiType[count];
|
||||
}
|
||||
};
|
||||
private static final Logger LOG = Logger.getInstance("#" + PsiType.class.getName());
|
||||
|
||||
@NotNull
|
||||
public static PsiType[] createArray(int count) {
|
||||
return ARRAY_FACTORY.create(count);
|
||||
}
|
||||
|
||||
private final TypeAnnotationProvider myAnnotationProvider;
|
||||
private TypeAnnotationProvider myAnnotationProvider;
|
||||
|
||||
/**
|
||||
* Constructs a PsiType with given annotations
|
||||
@@ -71,8 +69,16 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
|
||||
@NotNull
|
||||
public PsiType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
LOG.error("Not implemented for " + getClass());
|
||||
return this;
|
||||
if (provider == myAnnotationProvider) return this;
|
||||
|
||||
try {
|
||||
PsiType copy = (PsiType)clone();
|
||||
copy.myAnnotationProvider = provider;
|
||||
return copy;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,12 +81,6 @@ public class PsiWildcardType extends PsiType.Stub {
|
||||
return annotations.length == 0 ? this : new PsiWildcardType(this, TypeAnnotationProvider.Static.create(annotations));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiWildcardType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
return provider == getAnnotationProvider() ? this : new PsiWildcardType(this, provider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
|
||||
Reference in New Issue
Block a user