inspection tool window: do not throw ISE when open valid file without document (IDEA...
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 28 Apr 2016 11:54:42 +0000 (14:54 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 28 Apr 2016 14:19:25 +0000 (17:19 +0300)
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java

index fb1301eb99b2a9af8965a4e7b5df9128bb33fd02..ee5880a60d73020b95ed51edbf7eb9addd360959 100644 (file)
@@ -520,6 +520,9 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
       }
       final PsiFile file = selectedElement.getContainingFile();
       final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
+      if (document == null) {
+        return Pair.create(InspectionResultsViewUtil.createLabelForText("Can't open preview for \'" + file.getName() + "\'"), null);
+      }
 
       if (reuseEditorFor(document)) {
         myPreviewEditor.putUserData(PREVIEW_EDITOR_IS_REUSED_KEY, true);
index f8bd048de86451bbdf638224a9026a1e4fe71e1c..95a483ec31fb92f214ce73642841b11f187b8234 100644 (file)
@@ -69,7 +69,7 @@ public class InspectionResultsViewUtil {
   }
 
   @NotNull
-  private static JLabel createLabelForText(String text) {
+  static JLabel createLabelForText(String text) {
     final JLabel multipleSelectionLabel = new JBLabel(text);
     multipleSelectionLabel.setVerticalAlignment(SwingConstants.TOP);
     multipleSelectionLabel.setBorder(IdeBorderFactory.createEmptyBorder(16, 12, 0, 0));