From a6bb7d03d2501e8f3d9f5c3821dc54ea6d0d6823 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 17 Jun 2011 19:59:23 +0400 Subject: [PATCH] NPE --- .../codeInspection/deprecation/DeprecationInspection.java | 4 ++-- .../deprecatedDefaultConstructorInSuper/expected.xml | 5 +++++ .../deprecatedDefaultConstructorInSuper/src/Test.java | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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 8c2009b23ab9..ae3bf16aea67 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java @@ -142,7 +142,7 @@ public class DeprecationInspection extends BaseJavaLocalInspectionTool { } } - private void registerDefaultConstructorProblem(PsiClass superClass, PsiIdentifier nameIdentifier) { + private void registerDefaultConstructorProblem(PsiClass superClass, PsiElement nameIdentifier) { myHolder.registerProblem(nameIdentifier, "Default constructor in " + superClass.getQualifiedName() + " is deprecated", ProblemHighlightType.LIKE_DEPRECATED); } @@ -152,7 +152,7 @@ public class DeprecationInspection extends BaseJavaLocalInspectionTool { if (currentConstructors.length == 0) { final PsiClass superClass = aClass.getSuperClass(); if (hasDefaultDeprecatedConstructor(superClass)) { - registerDefaultConstructorProblem(superClass, aClass.getNameIdentifier()); + registerDefaultConstructorProblem(superClass, aClass instanceof PsiAnonymousClass ? ((PsiAnonymousClass)aClass).getBaseClassReference() : aClass.getNameIdentifier()); } } } diff --git a/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/expected.xml b/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/expected.xml index 2ea8b4aa2f50..ae61ea8fa6b1 100644 --- a/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/expected.xml +++ b/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/expected.xml @@ -5,5 +5,10 @@ 5 Default constructor in C is deprecated + + Test.java + 10 + Default constructor in C is deprecated + diff --git a/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/src/Test.java b/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/src/Test.java index 52d011602385..7808c2c154a9 100644 --- a/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/src/Test.java +++ b/java/java-tests/testData/inspection/deprecation/deprecatedDefaultConstructorInSuper/src/Test.java @@ -4,3 +4,9 @@ class C { class D extends C { } + +class P { + public static void main(String[] args) { + new C(){}; + } +} \ No newline at end of file