From 3c4c1390fb94804656b65a293db0cdb9265c7a40 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 28 Feb 2014 17:03:54 +0100 Subject: [PATCH] IDEA-120290 Deprecated methods in import popup. --- .../impl/quickfix/StaticImportMethodFix.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java index 19a4639a0689..69800e5616f7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java @@ -200,7 +200,7 @@ public class StaticImportMethodFix implements IntentionAction { //do not show methods from default package && !((PsiJavaFile)file).getPackageName().isEmpty() && PsiUtil.isAccessible(file.getProject(), method, element, containingClass)) { - if (method.isDeprecated()) { + if (isEffectivelyDeprecated(method)) { deprecated.put(containingClass, method); return processCondition(); } @@ -209,6 +209,20 @@ public class StaticImportMethodFix implements IntentionAction { return processCondition(); } + private boolean isEffectivelyDeprecated(PsiMethod method) { + if (method.isDeprecated()) { + return true; + } + PsiClass aClass = method.getContainingClass(); + while (aClass != null) { + if (aClass.isDeprecated()) { + return true; + } + aClass = aClass.getContainingClass(); + } + return false; + } + private boolean processCondition() { return (applicableList.isEmpty() ? list : applicableList).size() + deprecated.size() < 50; }