From d2e15e59657d5386e36f759d7ed3eda08e26c941 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 30 Jun 2016 18:03:49 +0200 Subject: [PATCH] who gives us invalid PSI to highlight usages of? (EA-85215) --- .../codeInsight/daemon/impl/IdentifierHighlighterPass.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java index ecce5532102d..aac704fdd4c2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java @@ -107,11 +107,17 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass { } else { PsiReference ref = TargetElementUtil.findReference(myEditor); if (ref instanceof PsiPolyVariantReference) { + if (!ref.getElement().isValid()) { + throw new PsiInvalidElementAccessException(ref.getElement(), "Invalid element in " + ref + " of " + ref.getClass() + "; editor=" + myEditor); + } ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false); if (results.length > 0) { for (ResolveResult result : results) { PsiElement target = result.getElement(); if (target != null) { + if (!target.isValid()) { + throw new PsiInvalidElementAccessException(target, "Invalid element returned from " + ref + " of " + ref.getClass() + "; editor=" + myEditor); + } highlightTargetUsages(target); } }