mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correct PsiEnumConstant#isDeprecated (IDEA-168740)
This commit is contained in:
@@ -194,14 +194,7 @@ public class PsiEnumConstantImpl extends JavaStubPsiElement<PsiFieldStub> implem
|
||||
|
||||
@Override
|
||||
public boolean isDeprecated() {
|
||||
final PsiFieldStub stub = getGreenStub();
|
||||
if (stub != null) {
|
||||
return stub.isDeprecated();
|
||||
}
|
||||
|
||||
PsiDocComment docComment = getDocComment();
|
||||
return docComment != null && docComment.findTagByName("deprecated") != null ||
|
||||
getModifierList().findAnnotation("java.lang.Deprecated") != null;
|
||||
return PsiFieldImpl.isFieldDeprecated(this, getGreenStub());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -299,12 +299,15 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
|
||||
|
||||
@Override
|
||||
public boolean isDeprecated() {
|
||||
final PsiFieldStub stub = getGreenStub();
|
||||
return isFieldDeprecated(this, getGreenStub());
|
||||
}
|
||||
|
||||
static boolean isFieldDeprecated(@NotNull PsiField field, @Nullable PsiFieldStub stub) {
|
||||
if (stub != null) {
|
||||
return stub.isDeprecated() || stub.hasDeprecatedAnnotation() && PsiImplUtil.isDeprecatedByAnnotation(this);
|
||||
return stub.isDeprecated() || stub.hasDeprecatedAnnotation() && PsiImplUtil.isDeprecatedByAnnotation(field);
|
||||
}
|
||||
|
||||
return PsiImplUtil.isDeprecatedByDocTag(this) || PsiImplUtil.isDeprecatedByAnnotation(this);
|
||||
return PsiImplUtil.isDeprecatedByDocTag(field) || PsiImplUtil.isDeprecatedByAnnotation(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -159,4 +159,15 @@ import java.lang.annotation.*;
|
||||
assert list.parametersCount == list.parameters.size()
|
||||
}
|
||||
|
||||
void "test deprecated enum constant"() {
|
||||
def cls = myFixture.addClass("enum Foo { c1, @Deprecated c2, /** @deprecated */ c3 }")
|
||||
assert !((PsiFileImpl) cls.containingFile).contentsLoaded
|
||||
|
||||
assert !cls.fields[0].deprecated
|
||||
assert cls.fields[1].deprecated
|
||||
assert cls.fields[2].deprecated
|
||||
|
||||
assert !((PsiFileImpl) cls.containingFile).contentsLoaded
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user