diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java index e7a18342cee7..d920e2570c72 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java @@ -94,7 +94,7 @@ public final class QuickFixAction { doRegister(info, action, null, null, fixRange, null); } - public static void unregisterQuickFixAction(HighlightInfo info, Condition condition) { + public static void unregisterQuickFixAction(@NotNull HighlightInfo info, Condition condition) { for (Iterator> it = info.quickFixActionRanges.iterator(); it.hasNext();) { Pair pair = it.next(); if (condition.value(pair.first.getAction())) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java index 8391df9b3e8a..7a166c589df3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java @@ -220,9 +220,10 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo if (cannotBeDynamic || shouldHighlightAsUnresolved(ref)) { HighlightInfo info = createAnnotationForRef(ref, cannotBeDynamic, GroovyBundle.message("cannot.resolve", ref.getReferenceName())); + LOG.assertTrue(info != null); HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME); - if (isCall(ref)) { + if (ref.getParent() instanceof GrMethodCall) { registerStaticImportFix(ref, info, displayKey); } else { @@ -377,7 +378,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo return HighlightInfo.createHighlightInfo(highlightInfoType, refNameElement, message); } - private static void registerStaticImportFix(GrReferenceExpression referenceExpression, HighlightInfo info, final HighlightDisplayKey key) { + private static void registerStaticImportFix(@NotNull GrReferenceExpression referenceExpression, @Nullable HighlightInfo info, @Nullable final HighlightDisplayKey key) { final String referenceName = referenceExpression.getReferenceName(); if (StringUtil.isEmpty(referenceName)) return; if (referenceExpression.getQualifier() != null) return; @@ -436,7 +437,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo } } - private static void registerAddImportFixes(GrReferenceElement refElement, HighlightInfo info, final HighlightDisplayKey key) { + private static void registerAddImportFixes(GrReferenceElement refElement, @Nullable HighlightInfo info, final HighlightDisplayKey key) { final String referenceName = refElement.getReferenceName(); //noinspection ConstantConditions if (StringUtil.isEmpty(referenceName)) return; @@ -446,7 +447,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo QuickFixAction.registerQuickFixAction(info, new GroovyAddImportAction(refElement), key); } - private static void registerCreateClassByTypeFix(GrReferenceElement refElement, HighlightInfo info, final HighlightDisplayKey key) { + private static void registerCreateClassByTypeFix(GrReferenceElement refElement, @Nullable HighlightInfo info, final HighlightDisplayKey key) { GrPackageDefinition packageDefinition = PsiTreeUtil.getParentOfType(refElement, GrPackageDefinition.class); if (packageDefinition != null) return; @@ -505,7 +506,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo private final HighlightInfo myInfo; private HighlightDisplayKey myKey; - public QuickFixActionRegistrarAdapter(HighlightInfo info, HighlightDisplayKey displayKey) { + public QuickFixActionRegistrarAdapter(@Nullable HighlightInfo info, HighlightDisplayKey displayKey) { myInfo = info; myKey = displayKey; } @@ -523,7 +524,9 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo @Override public void unregister(Condition condition) { - QuickFixAction.unregisterQuickFixAction(myInfo, condition); + if (myInfo != null) { + QuickFixAction.unregisterQuickFixAction(myInfo, condition); + } } } }