Mark deprecated items in ProjectView (class, function, property, class-object)

#KT-2944 Fixed Mark deprecated classes in Project Tree
This commit is contained in:
Natalia.Ukhorskaya
2012-10-19 15:29:31 +04:00
parent 92ff6abf50
commit aa28a03f61
5 changed files with 50 additions and 12 deletions
@@ -185,6 +185,35 @@ public class JetPsiUtil {
return firstPart.child(name);
}
@Nullable
public static Name getShortName(JetAnnotationEntry annotation) {
JetTypeReference typeReference = annotation.getTypeReference();
assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText();
JetTypeElement typeElement = typeReference.getTypeElement();
if (typeElement instanceof JetUserType) {
JetUserType userType = (JetUserType) typeElement;
String shortName = userType.getReferencedName();
if (shortName != null) {
return Name.identifier(shortName);
}
}
return null;
}
public static boolean isDeprecated(JetModifierListOwner owner) {
JetModifierList modifierList = owner.getModifierList();
if (modifierList != null) {
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
for (JetAnnotationEntry annotation : annotationEntries) {
Name shortName = getShortName(annotation);
if (KotlinBuiltIns.getInstance().getDeprecatedAnnotation().getName().equals(shortName)) {
return true;
}
}
}
return false;
}
@Nullable @IfNotParsed
public static ImportPath getImportPath(JetImportDirective importDirective) {
final JetExpression importedReference = importDirective.getImportedReference();
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.psi.stubs.PsiJetAnnotationStub;
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetAnnotationStubImpl;
import org.jetbrains.jet.lang.resolve.name.Name;
import java.io.IOException;
@@ -48,18 +49,9 @@ public class JetAnnotationElementType extends JetStubElementType<PsiJetAnnotatio
@Override
public PsiJetAnnotationStub createStub(@NotNull JetAnnotationEntry psi, StubElement parentStub) {
JetTypeReference typeReference = psi.getTypeReference();
assert typeReference != null : "Annotation entry hasn't typeReference " + psi.getText();
JetTypeElement typeElement = typeReference.getTypeElement();
String shortName = null;
if (typeElement instanceof JetUserType) {
JetUserType userType = (JetUserType) typeElement;
shortName = userType.getReferencedName();
}
if (shortName == null) {
shortName = psi.getText();
}
return new PsiJetAnnotationStubImpl(parentStub, JetStubElementTypes.ANNOTATION_ENTRY, shortName);
Name shortName = JetPsiUtil.getShortName(psi);
String resultName = shortName != null ? shortName.getName() : psi.getText();
return new PsiJetAnnotationStubImpl(parentStub, JetStubElementTypes.ANNOTATION_ENTRY, resultName);
}
@Override