IDEA-156098 @Deprecated external annotation on method does not affect editor

This commit is contained in:
peter
2016-05-18 19:44:27 +02:00
parent e1b69b301e
commit 50bcecaaf8
8 changed files with 39 additions and 16 deletions
@@ -25,6 +25,7 @@ package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.intention.LowPriorityAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.CommonClassNames;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -32,6 +33,6 @@ public class AddDeprecationAnnotationIntention extends AddAnnotationIntention im
@NotNull
@Override
public Pair<String, String[]> getAnnotations(@NotNull Project project) {
return Pair.create("java.lang.annotation.Deprecated", ArrayUtil.EMPTY_STRING_ARRAY);
return Pair.create(CommonClassNames.JAVA_LANG_DEPRECATED, ArrayUtil.EMPTY_STRING_ARRAY);
}
}
@@ -16,6 +16,7 @@
package com.intellij.psi.impl;
import com.intellij.codeInsight.AnnotationTargetUtil;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.lang.ASTNode;
import com.intellij.lang.FileASTNode;
import com.intellij.openapi.application.ApplicationManager;
@@ -469,8 +470,7 @@ public class PsiImplUtil {
}
public static boolean isDeprecatedByAnnotation(@NotNull PsiModifierListOwner owner) {
PsiModifierList modifierList = owner.getModifierList();
return modifierList != null && modifierList.findAnnotation("java.lang.Deprecated") != null;
return AnnotationUtil.findAnnotation(owner, CommonClassNames.JAVA_LANG_DEPRECATED) != null;
}
public static boolean isDeprecatedByDocTag(@NotNull PsiDocCommentOwner owner) {
@@ -22,18 +22,18 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.PsiNameIdentifierOwner;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.java.stubs.PsiMemberStub;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.stubs.NamedStub;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
public abstract class ClsMemberImpl<T extends NamedStub> extends ClsRepositoryPsiElement<T> implements PsiDocCommentOwner, PsiNameIdentifierOwner {
public abstract class ClsMemberImpl<T extends PsiMemberStub> extends ClsRepositoryPsiElement<T> implements PsiDocCommentOwner, PsiNameIdentifierOwner {
private final NotNullLazyValue<PsiDocComment> myDocComment;
private final NotNullLazyValue<PsiIdentifier> myNameIdentifier;
protected ClsMemberImpl(T stub) {
super(stub);
myDocComment = !isDeprecated() ? null : new AtomicNotNullLazyValue<PsiDocComment>() {
myDocComment = !stub.isDeprecated() ? null : new AtomicNotNullLazyValue<PsiDocComment>() {
@NotNull
@Override
protected PsiDocComment compute() {
@@ -172,7 +172,7 @@ public class ClsMethodImpl extends ClsMemberImpl<PsiMethodStub> implements PsiAn
@Override
public boolean isDeprecated() {
return getStub().isDeprecated();
return getStub().isDeprecated() || PsiImplUtil.isDeprecatedByAnnotation(this);
}
@Override
@@ -21,11 +21,10 @@ package com.intellij.psi.impl.java.stubs;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiClass;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
public interface PsiClassStub<T extends PsiClass> extends NamedStub<T> {
public interface PsiClassStub<T extends PsiClass> extends PsiMemberStub<T> {
@NonNls
@Nullable
String getQualifiedName();
@@ -34,7 +33,6 @@ public interface PsiClassStub<T extends PsiClass> extends NamedStub<T> {
@Nullable
String getBaseClassReferenceText();
boolean isDeprecated();
boolean hasDeprecatedAnnotation();
boolean isInterface();
boolean isEnum();
@@ -17,20 +17,18 @@ package com.intellij.psi.impl.java.stubs;
import com.intellij.psi.PsiField;
import com.intellij.psi.impl.cache.TypeInfo;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.NotNull;
/**
* @author max
*/
public interface PsiFieldStub extends NamedStub<PsiField> {
public interface PsiFieldStub extends PsiMemberStub<PsiField> {
String INITIALIZER_TOO_LONG = ";INITIALIZER_TOO_LONG;";
String INITIALIZER_NOT_STORED = ";INITIALIZER_NOT_STORED;";
@NotNull TypeInfo getType(boolean doResolve);
String getInitializerText();
boolean isEnumConstant();
boolean isDeprecated();
boolean hasDeprecatedAnnotation();
boolean hasDocComment();
}
@@ -0,0 +1,28 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.impl.java.stubs;
import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.stubs.NamedStub;
/**
* @author peter
*/
public interface PsiMemberStub<T extends PsiMember & PsiNamedElement> extends NamedStub<T> {
boolean isDeprecated();
}
@@ -18,14 +18,13 @@ package com.intellij.psi.impl.java.stubs;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.impl.cache.TypeInfo;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author max
*/
public interface PsiMethodStub extends NamedStub<PsiMethod> {
public interface PsiMethodStub extends PsiMemberStub<PsiMethod> {
boolean isConstructor();
boolean isVarArgs();
boolean isAnnotationMethod();
@@ -33,7 +32,6 @@ public interface PsiMethodStub extends NamedStub<PsiMethod> {
@Nullable String getDefaultValueText();
@NotNull TypeInfo getReturnTypeText(boolean doResolve);
boolean isDeprecated();
boolean hasDeprecatedAnnotation();
boolean hasDocComment();