EA-33172 - NPE: JavaHierarchyUtil.getPackageName
authorDmitry Jemerov <yole@jetbrains.com>
Tue, 31 Jan 2012 18:08:46 +0000 (19:08 +0100)
committerDmitry Jemerov <yole@jetbrains.com>
Tue, 31 Jan 2012 18:08:46 +0000 (19:08 +0100)
java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java

index 9afe7593f0a66c7a1e10c8329a9605b6d1d4b2a9..6a65678a8d3a6256770eff630187cc86a63bda30 100644 (file)
@@ -156,8 +156,13 @@ public final class CallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
       myHighlightedText.getEnding().addText(IdeBundle.message("node.call.hierarchy.N.usages", myUsageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes());
     }
     if (!(JspPsiUtil.isInJspFile(enclosingElement) && enclosingElement instanceof PsiFile)) {
-      final String packageName = JavaHierarchyUtil.getPackageName(enclosingElement instanceof PsiMethod ? ((PsiMethod)enclosingElement).getContainingClass() : (PsiClass)enclosingElement);
-      myHighlightedText.getEnding().addText("  (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
+      final PsiClass containingClass = enclosingElement instanceof PsiMethod
+                                       ? ((PsiMethod)enclosingElement).getContainingClass()
+                                       : (PsiClass)enclosingElement;
+      if (containingClass != null) {
+        final String packageName = JavaHierarchyUtil.getPackageName(containingClass);
+        myHighlightedText.getEnding().addText("  (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
+      }
     }
     myName = myHighlightedText.getText();