Cleanup (internal type text expressed via canonical wherever possible)

This commit is contained in:
Roman Shevchenko
2016-09-02 14:58:53 +03:00
parent dc2649d3dd
commit c3a623e167
12 changed files with 37 additions and 98 deletions
@@ -158,12 +158,6 @@ public class PsiTypeVariableFactory {
return getPresentableText();
}
@Override
@NotNull
public String getInternalCanonicalText() {
return getCanonicalText();
}
@Override
public boolean isValid() {
return true;
@@ -206,4 +200,4 @@ public class PsiTypeVariableFactory {
}
};
}
}
}
@@ -16,7 +16,6 @@
package com.intellij.psi;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
@@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public class PsiLambdaExpressionType extends PsiType {
private final PsiLambdaExpression myExpression;
public PsiLambdaExpressionType(PsiLambdaExpression expression) {
public PsiLambdaExpressionType(@NotNull PsiLambdaExpression expression) {
super(TypeAnnotationProvider.EMPTY);
myExpression = expression;
}
@@ -33,19 +32,13 @@ public class PsiLambdaExpressionType extends PsiType {
@NotNull
@Override
public String getPresentableText() {
return "<lambda expression>";
return getCanonicalText();
}
@NotNull
@Override
public String getCanonicalText() {
return getPresentableText();
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getCanonicalText();
return "<lambda expression>";
}
@Override
@@ -54,12 +47,12 @@ public class PsiLambdaExpressionType extends PsiType {
}
@Override
public boolean equalsToText(@NotNull @NonNls final String text) {
public boolean equalsToText(@NotNull String text) {
return false;
}
@Override
public <A> A accept(@NotNull final PsiTypeVisitor<A> visitor) {
public <A> A accept(@NotNull PsiTypeVisitor<A> visitor) {
return visitor.visitLambdaExpressionType(this);
}
@@ -16,7 +16,6 @@
package com.intellij.psi;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
@@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public class PsiLambdaParameterType extends PsiType {
private final PsiParameter myParameter;
public PsiLambdaParameterType(PsiParameter parameter) {
public PsiLambdaParameterType(@NotNull PsiParameter parameter) {
super(TypeAnnotationProvider.EMPTY);
myParameter = parameter;
}
@@ -33,19 +32,13 @@ public class PsiLambdaParameterType extends PsiType {
@NotNull
@Override
public String getPresentableText() {
return "<lambda parameter>";
return getCanonicalText();
}
@NotNull
@Override
public String getCanonicalText() {
return getPresentableText();
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getCanonicalText();
return "<lambda parameter>";
}
@Override
@@ -54,12 +47,12 @@ public class PsiLambdaParameterType extends PsiType {
}
@Override
public boolean equalsToText(@NotNull @NonNls final String text) {
public boolean equalsToText(@NotNull String text) {
return false;
}
@Override
public <A> A accept(@NotNull final PsiTypeVisitor<A> visitor) {
public <A> A accept(@NotNull PsiTypeVisitor<A> visitor) {
return visitor.visitType(this);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 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.
@@ -16,17 +16,15 @@
package com.intellij.psi;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* A type which represents a function denoted by a method reference.
*/
public class PsiMethodReferenceType extends PsiType {
@NotNull
private final PsiMethodReferenceExpression myReference;
public PsiMethodReferenceType(@NotNull final PsiMethodReferenceExpression reference) {
public PsiMethodReferenceType(@NotNull PsiMethodReferenceExpression reference) {
super(PsiAnnotation.EMPTY_ARRAY);
myReference = reference;
}
@@ -34,19 +32,13 @@ public class PsiMethodReferenceType extends PsiType {
@NotNull
@Override
public String getPresentableText() {
return "<method reference>";
return getCanonicalText();
}
@NotNull
@Override
public String getCanonicalText() {
return getPresentableText();
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getPresentableText();
return "<method reference>";
}
@Override
@@ -55,12 +47,12 @@ public class PsiMethodReferenceType extends PsiType {
}
@Override
public boolean equalsToText(@NotNull @NonNls final String text) {
public boolean equalsToText(@NotNull String text) {
return false;
}
@Override
public <A> A accept(@NotNull final PsiTypeVisitor<A> visitor) {
public <A> A accept(@NotNull PsiTypeVisitor<A> visitor) {
return visitor.visitMethodReferenceType(this);
}
@@ -78,4 +70,4 @@ public class PsiMethodReferenceType extends PsiType {
public PsiMethodReferenceExpression getExpression() {
return myReference;
}
}
}
@@ -74,11 +74,11 @@ public class PsiPrimitiveType extends PsiType.Stub {
@NotNull
@Override
public String getInternalCanonicalText() {
return getText(true, true);
return getCanonicalText(true);
}
private String getText(boolean qualified, boolean annotated) {
PsiAnnotation[] annotations = annotated ? getAnnotations() : PsiAnnotation.EMPTY_ARRAY; ;
PsiAnnotation[] annotations = annotated ? getAnnotations() : PsiAnnotation.EMPTY_ARRAY;
if (annotations.length == 0) return myName;
StringBuilder sb = new StringBuilder();
@@ -128,7 +128,9 @@ public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
* todo[r.sh] merge with getPresentableText()
*/
@NotNull
public abstract String getInternalCanonicalText();
public String getInternalCanonicalText() {
return getCanonicalText();
}
/**
* Checks if the type is currently valid.
@@ -31,7 +31,7 @@ public class Bottom extends PsiType {
@NotNull
@Override
public String getPresentableText() {
return "_";
return getCanonicalText();
}
@NotNull
@@ -40,12 +40,6 @@ public class Bottom extends PsiType {
return "_";
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getCanonicalText();
}
@Override
public boolean isValid() {
return true;
@@ -206,7 +206,7 @@ public class PsiClassReferenceType extends PsiClassType.Stub {
@NotNull
@Override
public String getInternalCanonicalText() {
return getText(true);
return getCanonicalText(true);
}
private String getText(boolean annotated) {
@@ -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.
@@ -74,12 +74,6 @@ public class GrAnonymousClassType extends GrLiteralClassType {
return new GrAnonymousClassType(languageLevel, myScope, myFacade, myAnonymous);
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getCanonicalText();
}
@Override
public boolean isValid() {
return myAnonymous.isValid();
@@ -94,4 +88,4 @@ public class GrAnonymousClassType extends GrLiteralClassType {
public PsiClassType getSimpleClassType() {
return new GrClassReferenceType(myAnonymous.getBaseClassReferenceGroovy(), myLanguageLevel);
}
}
}
@@ -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.
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
@@ -132,21 +130,14 @@ public class GrClassReferenceType extends PsiClassType {
return myReferenceElement.getCanonicalText();
}
@NotNull
@Override
public String getInternalCanonicalText() {
return getCanonicalText();
}
@Override
public boolean isValid() {
return myReferenceElement.isValid();
}
@Override
public boolean equalsToText(@NotNull @NonNls String text) {
return text.endsWith(getPresentableText()) && //optimization
text.equals(getCanonicalText());
public boolean equalsToText(@NotNull String text) {
return text.endsWith(getPresentableText()) /*optimization*/ && text.equals(getCanonicalText());
}
@Override
@@ -170,4 +161,4 @@ public class GrClassReferenceType extends PsiClassType {
public GrReferenceElement getReference() {
return myReferenceElement;
}
}
}
@@ -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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl;
import com.intellij.openapi.util.Comparing;
@@ -110,12 +109,6 @@ public class GrClosureType extends GrLiteralClassType {
return new GrClosureType(getLanguageLevel(), getResolveScope(), myFacade, mySignature, false);
}
@Override
@NotNull
public String getInternalCanonicalText() {
return getCanonicalText();
}
@Override
public boolean isValid() {
return mySignature.isValid();
@@ -195,4 +188,4 @@ public class GrClosureType extends GrLiteralClassType {
public GrSignature getSignature() {
return mySignature;
}
}
}
@@ -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.
@@ -19,7 +19,6 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeVisitor;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,7 +30,7 @@ public class GrPsiTypeStub extends PsiType {
@NotNull
@Override
public String getPresentableText() {
return "?";
return getCanonicalText();
}
@NotNull
@@ -40,19 +39,13 @@ public class GrPsiTypeStub extends PsiType {
return "?";
}
@NotNull
@Override
public String getInternalCanonicalText() {
return "?";
}
@Override
public boolean isValid() {
return true;
}
@Override
public boolean equalsToText(@NotNull @NonNls String text) {
public boolean equalsToText(@NotNull String text) {
return false;
}
@@ -72,4 +65,4 @@ public class GrPsiTypeStub extends PsiType {
public PsiType[] getSuperTypes() {
return EMPTY_ARRAY;
}
}
}