diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 14e7352028ee..802a4d89933f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -300,6 +300,7 @@ public class HighlightMethodUtil { return false; } + @Nullable static HighlightInfo checkMethodCall(PsiMethodCallExpression methodCall, PsiResolveHelper resolveHelper) { PsiExpressionList list = methodCall.getArgumentList(); PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression(); @@ -338,8 +339,10 @@ public class HighlightMethodUtil { String toolTip = parent instanceof PsiClass && !ApplicationManager.getApplication().isUnitTestMode() ? createMismatchedArgumentsHtmlTooltip(candidateInfo, list) : description; highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, list, description, toolTip); - registerMethodCallIntentions(highlightInfo, methodCall, list, resolveHelper); - highlightInfo.navigationShift = +1; + if (highlightInfo != null) { + registerMethodCallIntentions(highlightInfo, methodCall, list, resolveHelper); + highlightInfo.navigationShift = +1; + } } else { PsiReferenceExpression methodExpression = methodCall.getMethodExpression(); @@ -389,6 +392,7 @@ public class HighlightMethodUtil { return isDummy; } + @Nullable static HighlightInfo checkAmbiguousMethodCall(final PsiReferenceExpression referenceToMethod, JavaResolveResult[] resolveResults, final PsiExpressionList list, @@ -483,9 +487,10 @@ public class HighlightMethodUtil { return candidateList.toArray(new MethodCandidateInfo[candidateList.size()]); } - private static void registerMethodCallIntentions(HighlightInfo highlightInfo, + private static void registerMethodCallIntentions(@Nullable HighlightInfo highlightInfo, PsiMethodCallExpression methodCall, - PsiExpressionList list, PsiResolveHelper resolveHelper) { + PsiExpressionList list, + PsiResolveHelper resolveHelper) { TextRange fixRange = getFixRange(methodCall); QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateMethodFromUsageFix(methodCall)); QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateAbstractMethodFromUsageFix(methodCall)); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 6bd547c99c32..2f7b053f3e37 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -244,8 +244,9 @@ public class HighlightUtil { */ static void registerAccessQuickFixAction(@NotNull PsiMember refElement, @NotNull PsiJavaCodeReferenceElement place, - @NotNull HighlightInfo errorResult, + @Nullable HighlightInfo errorResult, final PsiElement fileResolveScope) { + if (errorResult == null) return; PsiClass accessObjectClass = null; PsiElement qualifier = place.getQualifier(); if (qualifier instanceof PsiExpression) { @@ -434,16 +435,11 @@ public class HighlightUtil { private static void registerChangeVariableTypeFixes(@NotNull PsiExpression expression, @NotNull PsiType type, - @NotNull HighlightInfo highlightInfo) { - if (!(expression instanceof PsiReferenceExpression)){ - return; - } + @Nullable HighlightInfo highlightInfo) { + if (highlightInfo == null || !(expression instanceof PsiReferenceExpression)) return; final PsiElement element = ((PsiReferenceExpression)expression).resolve(); - - if (element == null || !(element instanceof PsiVariable)){ - return; - } + if (element == null || !(element instanceof PsiVariable)) return; registerChangeVariableTypeFixes((PsiVariable)element, type, highlightInfo); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java index 391e89e75930..d611958266af 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java @@ -453,7 +453,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP public static void registerIntentions(@NotNull JavaResolveResult[] candidates, @NotNull PsiExpressionList list, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange) { if (candidates.length == 0) return; PsiExpression[] expressions = list.getExpressions(); @@ -463,7 +463,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP } private static void registerIntention(@NotNull PsiExpression[] expressions, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange, @NotNull JavaResolveResult candidate, @NotNull PsiElement context) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java index 88658e227728..be01f9bcdb8f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -107,8 +108,10 @@ public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction } } - public static void registerFixes(@NotNull final CandidateInfo[] candidates, @NotNull final PsiMethodCallExpression methodCall, - @NotNull final HighlightInfo info) { + public static void registerFixes(@NotNull final CandidateInfo[] candidates, + @NotNull final PsiMethodCallExpression methodCall, + @Nullable final HighlightInfo info) { + if (info == null) return; final Set literals = new HashSet(); boolean exactMatch = false; for (CandidateInfo candidate : candidates) { @@ -122,8 +125,9 @@ public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction } } - private static void processLiterals(@NotNull final Set literals, @NotNull final PsiCall call, - @NotNull final HighlightInfo info) { + private static void processLiterals(@NotNull final Set literals, + @NotNull final PsiCall call, + @NotNull final HighlightInfo info) { for (PsiLiteralExpression literal : literals) { final ChangeStringLiteralToCharInMethodCallFix fix = new ChangeStringLiteralToCharInMethodCallFix(literal, call); QuickFixAction.registerQuickFixAction(info, fix); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java index 3945e632a75a..8fc1cda79e44 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java @@ -37,6 +37,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class ChangeTypeArgumentsFix implements IntentionAction, HighPriorityAction { private final PsiMethod myTargetMethod; @@ -135,7 +136,7 @@ public class ChangeTypeArgumentsFix implements IntentionAction, HighPriorityActi public static void registerIntentions(@NotNull JavaResolveResult[] candidates, @NotNull PsiExpressionList list, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, PsiClass psiClass) { if (candidates.length == 0) return; PsiExpression[] expressions = list.getExpressions(); @@ -145,13 +146,12 @@ public class ChangeTypeArgumentsFix implements IntentionAction, HighPriorityActi } private static void registerIntention(@NotNull PsiExpression[] expressions, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, PsiClass psiClass, @NotNull JavaResolveResult candidate, @NotNull PsiElement context) { if (!candidate.isStaticsScopeCorrect()) return; PsiMethod method = (PsiMethod)candidate.getElement(); - PsiSubstitutor substitutor = candidate.getSubstitutor(); if (method != null && context.getManager().isInProject(method)) { final ChangeTypeArgumentsFix fix = new ChangeTypeArgumentsFix(method, psiClass, expressions, context); QuickFixAction.registerQuickFixAction(highlightInfo, null, fix); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java index 0b5d26e71334..4a5189ec1935 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * User: anna @@ -82,7 +83,7 @@ public class ConvertDoubleToFloatFix implements IntentionAction { public static void registerIntentions(@NotNull JavaResolveResult[] candidates, @NotNull PsiExpressionList list, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange) { if (candidates.length == 0) return; PsiExpression[] expressions = list.getExpressions(); @@ -92,7 +93,7 @@ public class ConvertDoubleToFloatFix implements IntentionAction { } private static void registerIntention(@NotNull PsiExpression[] expressions, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange, @NotNull JavaResolveResult candidate, @NotNull PsiElement context) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java index d7aa814c5e02..e73786dc4754 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java @@ -110,7 +110,7 @@ public class RemoveRedundantArgumentsFix implements IntentionAction { public static void registerIntentions(@NotNull JavaResolveResult[] candidates, @NotNull PsiExpressionList arguments, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange) { for (JavaResolveResult candidate : candidates) { registerIntention(arguments, highlightInfo, fixRange, candidate, arguments); @@ -118,7 +118,7 @@ public class RemoveRedundantArgumentsFix implements IntentionAction { } private static void registerIntention(@NotNull PsiExpressionList arguments, - @NotNull HighlightInfo highlightInfo, + @Nullable HighlightInfo highlightInfo, TextRange fixRange, @NotNull JavaResolveResult candidate, @NotNull PsiElement context) {