From 03c66e9976612062a88652e0526e4fda62589fcf Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 19 Sep 2012 09:50:59 +0200 Subject: [PATCH] deprecated inspection: skip import statements (IDEA-91767) --- .../codeInspection/deprecation/DeprecationInspection.java | 4 ++++ .../inspection/deprecation/deprecatedInImport/expected.xml | 2 ++ .../inspection/deprecation/deprecatedInImport/src/Test.java | 3 +++ .../inspection/deprecation/deprecatedInImport/src/a/A.java | 3 +++ .../intellij/codeInspection/DeprecationInspectionTest.java | 4 ++++ 5 files changed, 16 insertions(+) create mode 100644 java/java-tests/testData/inspection/deprecation/deprecatedInImport/expected.xml create mode 100644 java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/Test.java create mode 100644 java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/a/A.java diff --git a/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java index 1bfadfd2420b..ab940b08e54e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java @@ -241,6 +241,10 @@ public class DeprecationInspection extends BaseJavaLocalInspectionTool { } } + if (PsiTreeUtil.getParentOfType(elementToHighlight, PsiImportStatementBase.class) != null) { + return; + } + String description = JavaErrorMessages.message("deprecated.symbol", HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY)); diff --git a/java/java-tests/testData/inspection/deprecation/deprecatedInImport/expected.xml b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/expected.xml new file mode 100644 index 000000000000..4704d91e891d --- /dev/null +++ b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/expected.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/Test.java b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/Test.java new file mode 100644 index 000000000000..36192223395a --- /dev/null +++ b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/Test.java @@ -0,0 +1,3 @@ +import a.A; +public class Test { +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/a/A.java b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/a/A.java new file mode 100644 index 000000000000..c2cd9f4f3dc4 --- /dev/null +++ b/java/java-tests/testData/inspection/deprecation/deprecatedInImport/src/a/A.java @@ -0,0 +1,3 @@ +package a; +@Deprecated +public class A {} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java index b53c7ed57418..41a802df93cf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java @@ -25,6 +25,10 @@ public class DeprecationInspectionTest extends InspectionTestCase { doTest(); } + public void testDeprecatedInImport() throws Exception{ + doTest(); + } + public void testDeprecatedInner() throws Exception { doTest(); }