tolerate INRE when checking for java property deprecatedness in structure view (EA...
authorpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 16:48:23 +0000 (17:48 +0100)
committerpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 17:18:28 +0000 (18:18 +0100)
java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java

index f30af8b1a6617b514d3d09905e65eaf6b684aa55..cbe863b8933c1bb4fbbce9a21c1d4ffb3287d17c 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.colors.CodeInsightColors;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
+import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.IconLoader;
@@ -32,6 +33,7 @@ import com.intellij.psi.util.PropertyUtil;
 import com.intellij.psi.util.PsiUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.util.ArrayList;
@@ -254,11 +256,13 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve
     return isDeprecated(getField()) && isDeprecated(getGetter()) && isDeprecated(getSetter());
   }
 
-  private static boolean isDeprecated(final PsiElement element) {
-    if (element == null) return false;
-    if (!element.isValid()) return false;
-    if (!(element instanceof PsiDocCommentOwner)) return false;
-    return ((PsiDocCommentOwner)element).isDeprecated();
+  private static boolean isDeprecated(@Nullable final PsiDocCommentOwner element) {
+    try {
+      return element != null && element.isValid() && element.isDeprecated();
+    }
+    catch (IndexNotReadyException e) {
+      return false;
+    }
   }
 
   public boolean isComplete() {