Get rid of getPsi() methods in JavaElement/JavaType hierarchy
This commit is contained in:
+3
-2
@@ -22,10 +22,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotationArgument;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public abstract class JavaAnnotationArgumentImpl extends JavaElementImpl<PsiAnnotationMemberValue> implements JavaAnnotationArgument {
|
||||
public abstract class JavaAnnotationArgumentImpl<Psi extends PsiAnnotationMemberValue> extends JavaElementImpl<Psi>
|
||||
implements JavaAnnotationArgument {
|
||||
private final Name name;
|
||||
|
||||
protected JavaAnnotationArgumentImpl(@NotNull PsiAnnotationMemberValue psiAnnotationMemberValue, @Nullable Name name) {
|
||||
protected JavaAnnotationArgumentImpl(@NotNull Psi psiAnnotationMemberValue, @Nullable Name name) {
|
||||
super(psiAnnotationMemberValue);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
+2
-7
@@ -23,17 +23,12 @@ import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotationAsAnnotationArgument;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public class JavaAnnotationAsAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaAnnotationAsAnnotationArgument {
|
||||
public class JavaAnnotationAsAnnotationArgumentImpl extends JavaAnnotationArgumentImpl<PsiAnnotation>
|
||||
implements JavaAnnotationAsAnnotationArgument {
|
||||
protected JavaAnnotationAsAnnotationArgumentImpl(@NotNull PsiAnnotation psiAnnotation, @Nullable Name name) {
|
||||
super(psiAnnotation, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiAnnotation getPsi() {
|
||||
return (PsiAnnotation) super.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaAnnotation getAnnotation() {
|
||||
|
||||
+2
-7
@@ -27,17 +27,12 @@ import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.namelessAnnotationArguments;
|
||||
|
||||
public class JavaArrayAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaArrayAnnotationArgument {
|
||||
public class JavaArrayAnnotationArgumentImpl extends JavaAnnotationArgumentImpl<PsiArrayInitializerMemberValue>
|
||||
implements JavaArrayAnnotationArgument {
|
||||
protected JavaArrayAnnotationArgumentImpl(@NotNull PsiArrayInitializerMemberValue psiArrayInitializerMemberValue, @Nullable Name name) {
|
||||
super(psiArrayInitializerMemberValue, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiArrayInitializerMemberValue getPsi() {
|
||||
return (PsiArrayInitializerMemberValue) super.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<JavaAnnotationArgument> getElements() {
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.*;
|
||||
|
||||
public class JavaClassImpl extends JavaClassifierImpl implements JavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
public class JavaClassImpl extends JavaClassifierImpl<PsiClass> implements JavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
public JavaClassImpl(@NotNull PsiClass psiClass) {
|
||||
super(psiClass);
|
||||
assert !(psiClass instanceof PsiTypeParameter)
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ import com.intellij.psi.PsiTypeParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClassifier;
|
||||
|
||||
public abstract class JavaClassifierImpl extends JavaElementImpl<PsiClass> implements JavaClassifier {
|
||||
protected JavaClassifierImpl(@NotNull PsiClass psiClass) {
|
||||
public abstract class JavaClassifierImpl<Psi extends PsiClass> extends JavaElementImpl<Psi> implements JavaClassifier {
|
||||
protected JavaClassifierImpl(@NotNull Psi psiClass) {
|
||||
super(psiClass);
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -22,17 +22,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaField;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaType;
|
||||
|
||||
public class JavaFieldImpl extends JavaMemberImpl implements JavaField {
|
||||
public class JavaFieldImpl extends JavaMemberImpl<PsiField> implements JavaField {
|
||||
public JavaFieldImpl(@NotNull PsiField psiField) {
|
||||
super(psiField);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiField getPsi() {
|
||||
return (PsiField) super.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnumEntry() {
|
||||
return getPsi() instanceof PsiEnumConstant;
|
||||
|
||||
+2
-2
@@ -29,9 +29,9 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class JavaMemberImpl extends JavaElementImpl<PsiMember>
|
||||
public abstract class JavaMemberImpl<Psi extends PsiMember> extends JavaElementImpl<Psi>
|
||||
implements JavaMember, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
protected JavaMemberImpl(@NotNull PsiMember psiMember) {
|
||||
protected JavaMemberImpl(@NotNull Psi psiMember) {
|
||||
super(psiMember);
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -32,17 +32,11 @@ import java.util.Collection;
|
||||
import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.typeParameters;
|
||||
import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.valueParameters;
|
||||
|
||||
public class JavaMethodImpl extends JavaMemberImpl implements JavaMethod {
|
||||
public class JavaMethodImpl extends JavaMemberImpl<PsiMethod> implements JavaMethod {
|
||||
public JavaMethodImpl(@NotNull PsiMethod psiMethod) {
|
||||
super(psiMethod);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod getPsi() {
|
||||
return (PsiMethod) super.getPsi();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getName() {
|
||||
|
||||
+2
-7
@@ -26,17 +26,12 @@ import org.jetbrains.jet.lang.resolve.java.structure.JavaElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaReferenceAnnotationArgument;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public class JavaReferenceAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaReferenceAnnotationArgument {
|
||||
public class JavaReferenceAnnotationArgumentImpl extends JavaAnnotationArgumentImpl<PsiReferenceExpression>
|
||||
implements JavaReferenceAnnotationArgument {
|
||||
protected JavaReferenceAnnotationArgumentImpl(@NotNull PsiReferenceExpression psiReferenceExpression, @Nullable Name name) {
|
||||
super(psiReferenceExpression, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReferenceExpression getPsi() {
|
||||
return (PsiReferenceExpression) super.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JavaElement resolve() {
|
||||
|
||||
+7
-7
@@ -34,35 +34,35 @@ public abstract class JavaTypeImpl<Psi extends PsiType> implements JavaType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JavaType create(@NotNull PsiType psiType) {
|
||||
return psiType.accept(new PsiTypeVisitor<JavaType>() {
|
||||
public static JavaTypeImpl<?> create(@NotNull PsiType psiType) {
|
||||
return psiType.accept(new PsiTypeVisitor<JavaTypeImpl<?>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaType visitType(PsiType type) {
|
||||
public JavaTypeImpl<?> visitType(PsiType type) {
|
||||
throw new UnsupportedOperationException("Unsupported PsiType: " + type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaType visitPrimitiveType(PsiPrimitiveType primitiveType) {
|
||||
public JavaTypeImpl<?> visitPrimitiveType(PsiPrimitiveType primitiveType) {
|
||||
return new JavaPrimitiveTypeImpl(primitiveType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaType visitArrayType(PsiArrayType arrayType) {
|
||||
public JavaTypeImpl<?> visitArrayType(PsiArrayType arrayType) {
|
||||
return new JavaArrayTypeImpl(arrayType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaType visitClassType(PsiClassType classType) {
|
||||
public JavaTypeImpl<?> visitClassType(PsiClassType classType) {
|
||||
return new JavaClassifierTypeImpl(classType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaType visitWildcardType(PsiWildcardType wildcardType) {
|
||||
public JavaTypeImpl<?> visitWildcardType(PsiWildcardType wildcardType) {
|
||||
return new JavaWildcardTypeImpl(wildcardType);
|
||||
}
|
||||
});
|
||||
|
||||
+1
-7
@@ -26,17 +26,11 @@ import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.classifierTypes;
|
||||
|
||||
public class JavaTypeParameterImpl extends JavaClassifierImpl implements JavaTypeParameter {
|
||||
public class JavaTypeParameterImpl extends JavaClassifierImpl<PsiTypeParameter> implements JavaTypeParameter {
|
||||
public JavaTypeParameterImpl(@NotNull PsiTypeParameter psiTypeParameter) {
|
||||
super(psiTypeParameter);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiTypeParameter getPsi() {
|
||||
return (PsiTypeParameter) super.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return getPsi().getIndex();
|
||||
|
||||
Reference in New Issue
Block a user