From 71dcc4b1d942f552cf19788638ee6b741a5696ac Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 10 Apr 2012 14:46:02 +0400 Subject: [PATCH] convenient registerQuickFixAction without HighlightDisplayKey --- .../daemon/impl/PostHighlightingPass.java | 4 +-- .../analysis/HighlightControlFlowUtil.java | 2 +- .../impl/analysis/HighlightMethodUtil.java | 30 +++++++++---------- .../daemon/impl/analysis/HighlightUtil.java | 2 +- .../AddTypeArgumentsConditionalFix.java | 2 +- .../quickfix/ArgumentFixerActionFactory.java | 2 +- .../ChangeMethodSignatureFromUsageFix.java | 4 +-- .../quickfix/ConvertDoubleToFloatFix.java | 2 +- .../impl/quickfix/PermuteArgumentsFix.java | 2 +- .../impl/quickfix/QualifyThisArgumentFix.java | 2 +- .../impl/quickfix/WrapExpressionFix.java | 2 +- .../daemon/impl/quickfix/QuickFixAction.java | 6 +++- .../impl/analysis/XmlHighlightVisitor.java | 2 +- 13 files changed, 33 insertions(+), 29 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java index 91f53fdd8813..d1d227c8b9f2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java @@ -414,7 +414,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { HighlightInfo highlightInfo = suggestionsToMakeFieldUsed(field, identifier, message); if (!field.hasInitializer()) { - QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field), null); + QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field)); } return highlightInfo; } @@ -434,7 +434,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { final HighlightInfo info = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL); QuickFixAction.registerQuickFixAction(info, new CreateGetterOrSetterFix(false, true, field), myUnusedSymbolKey); - QuickFixAction.registerQuickFixAction(info, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field), null); + QuickFixAction.registerQuickFixAction(info, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field)); SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(field, new Processor() { @Override public boolean process(final String annoName) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index b36c101d74b5..fd57237a8a6e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -287,7 +287,7 @@ public class HighlightControlFlowUtil { String description = JavaErrorMessages.message("variable.not.initialized", field.getName()); TextRange range = HighlightNamesUtil.getFieldDeclarationTextRange(field); final HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, range.getStartOffset(), range.getEndOffset(), description); - QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field), null); + QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field)); final PsiClass containingClass = field.getContainingClass(); if (containingClass != null && !containingClass.isInterface()) { IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.FINAL, false, false); 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 0c0bf04ff2f5..72329e551a56 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 @@ -359,9 +359,9 @@ public class HighlightMethodUtil { } else { TextRange range = getFixRange(methodCall); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateMethodFromUsageFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateAbstractMethodFromUsageFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreatePropertyFromUsageFix(methodCall), null); + QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateAbstractMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreatePropertyFromUsageFix(methodCall)); } } } @@ -487,11 +487,11 @@ public class HighlightMethodUtil { PsiMethodCallExpression methodCall, PsiExpressionList list, PsiResolveHelper resolveHelper) { TextRange fixRange = getFixRange(methodCall); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateMethodFromUsageFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateAbstractMethodFromUsageFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromSuperFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromThisFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreatePropertyFromUsageFix(methodCall), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateAbstractMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromSuperFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromThisFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreatePropertyFromUsageFix(methodCall)); CandidateInfo[] methodCandidates = resolveHelper.getReferencedMethodCandidates(methodCall, false); CastMethodArgumentFix.REGISTRAR.registerCastActions(methodCandidates, methodCall, highlightInfo, fixRange); PermuteArgumentsFix.registerFix(highlightInfo, methodCall, methodCandidates, fixRange); @@ -502,11 +502,11 @@ public class HighlightMethodUtil { WrapExpressionFix.registerWrapAction(methodCandidates, list.getExpressions(), highlightInfo); ChangeParameterClassFix.registerQuickFixActions(methodCall, list, highlightInfo); if (methodCandidates.length == 0) { - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new StaticImportMethodFix(methodCall), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new StaticImportMethodFix(methodCall)); } VariableTypeFromCallFix.registerQuickFixActions(methodCall, list, highlightInfo); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ReplaceAddAllArrayToCollectionFix(methodCall), null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new SurroundWithArrayFix(methodCall), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ReplaceAddAllArrayToCollectionFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new SurroundWithArrayFix(methodCall)); QualifyThisArgumentFix.registerQuickFixAction(methodCandidates, methodCall, highlightInfo, fixRange); CandidateInfo[] candidates = resolveHelper.getReferencedMethodCandidates(methodCall, true); @@ -1209,7 +1209,7 @@ public class HighlightMethodUtil { String description = JavaErrorMessages.message("wrong.constructor.arguments", constructorName+"()", argTypes); String tooltip = createMismatchedArgumentsHtmlTooltip(list, PsiParameter.EMPTY_ARRAY, constructorName, PsiSubstitutor.EMPTY, aClass); HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, list, description, tooltip); - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall), null); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info,getFixRange(list)); } @@ -1247,7 +1247,7 @@ public class HighlightMethodUtil { name += buildArgTypesList(list); String description = JavaErrorMessages.message("cannot.resolve.constructor", name); HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, list, description, XmlStringUtil.escapeString(description)); - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall), null); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info,getFixRange(list)); PermuteArgumentsFix.registerFix(info, constructorCall, toMethodCandidates(results), getFixRange(list)); @@ -1270,14 +1270,14 @@ public class HighlightMethodUtil { String toolTip = createMismatchedArgumentsHtmlTooltip(result, list); PsiElement infoElement = list.getTextLength() > 0 ? list : constructorCall; HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, infoElement, description, toolTip); - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall), null); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info, getFixRange(infoElement)); ChangeMethodSignatureFromUsageFix.registerIntentions(results, list, info, null); ConvertDoubleToFloatFix.registerIntentions(results, list, info, null); PermuteArgumentsFix.registerFix(info, constructorCall, toMethodCandidates(results), getFixRange(list)); ChangeParameterClassFix.registerQuickFixActions(constructorCall, list, info); - QuickFixAction.registerQuickFixAction(info, getFixRange(list), new SurroundWithArrayFix(constructorCall), null); + QuickFixAction.registerQuickFixAction(info, getFixRange(list), new SurroundWithArrayFix(constructorCall)); } info.navigationShift = +1; holder.add(info); 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 fb0f18254196..99483109d7c4 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 @@ -288,7 +288,7 @@ public class HighlightUtil { if (ref != null) { fixRange = fixRange.union(ref.getTextRange()); } - QuickFixAction.registerQuickFixAction(errorResult, fixRange, fix, null); + QuickFixAction.registerQuickFixAction(errorResult, fixRange, fix); } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java index f1392ed12460..4457e5d47c40 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java @@ -145,7 +145,7 @@ public class AddTypeArgumentsConditionalFix implements IntentionAction { if (substitutedType != null && TypeConversionUtil.isAssignable(lType, substitutedType)) { QuickFixAction.registerQuickFixAction(highlightInfo, thenExpression.getTextRange(), - new AddTypeArgumentsConditionalFix(substitutor, (PsiMethodCallExpression)thenExpression, method), null); + new AddTypeArgumentsConditionalFix(substitutor, (PsiMethodCallExpression)thenExpression, method)); } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java index 2a2faab25642..76bf6ae59e1b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java @@ -99,7 +99,7 @@ public abstract class ArgumentFixerActionFactory { JavaResolveResult resolveResult = newCall.resolveMethodGenerics(); if (resolveResult.getElement() != null && resolveResult.isValidResult()) { suggestedCasts.add(parameterType.getCanonicalText()); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, createFix(list, i, parameterType),null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, createFix(list, i, parameterType)); } } } 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 4edcb73e9726..1aef4d76d167 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 @@ -479,8 +479,8 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP PsiSubstitutor substitutor = candidate.getSubstitutor(); if (method != null && context.getManager().isInProject(method)) { ChangeMethodSignatureFromUsageFix fix = new ChangeMethodSignatureFromUsageFix(method, expressions, substitutor, context, false, 2); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, fix, null); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, false, 2), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, false, 2)); } } 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 f23d99ba2d88..0b5d26e71334 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 @@ -105,7 +105,7 @@ public class ConvertDoubleToFloatFix implements IntentionAction { PsiParameter parameter = parameters[i]; final PsiExpression expression = expressions[i]; if (expression instanceof PsiLiteralExpression && PsiType.FLOAT.equals(parameter.getType()) && PsiType.DOUBLE.equals(expression.getType())) { - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ConvertDoubleToFloatFix(expression), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ConvertDoubleToFloatFix(expression)); } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java index 2ca479214bcc..bbc308939257 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java @@ -114,7 +114,7 @@ public class PermuteArgumentsFix implements IntentionAction { } if (permutations.size() == 1) { PermuteArgumentsFix fix = new PermuteArgumentsFix(callExpression, permutations.get(0)); - QuickFixAction.registerQuickFixAction(info, fixRange, fix, null); + QuickFixAction.registerQuickFixAction(info, fixRange, fix); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java index a5cfce5dd068..bb54763bbd0e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java @@ -111,7 +111,7 @@ public class QualifyThisArgumentFix extends PsiElementBaseIntentionAction { if (!TypeConversionUtil.isAssignable(parameterType, exprType)) { final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(parameterType); if (psiClass != null && containingClasses.contains(psiClass)) { - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new QualifyThisArgumentFix((PsiThisExpression)expression, psiClass), null); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new QualifyThisArgumentFix((PsiThisExpression)expression, psiClass)); } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java index 36fc33f602a0..e03214da210f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java @@ -158,7 +158,7 @@ public class WrapExpressionFix implements IntentionAction { } if (expectedType != null) { - QuickFixAction.registerQuickFixAction(highlightInfo, expr.getTextRange(), new WrapExpressionFix(expectedType, expr), null); + QuickFixAction.registerQuickFixAction(highlightInfo, expr.getTextRange(), new WrapExpressionFix(expectedType, expr)); } } 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 008319eab58a..70d351d6092e 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 @@ -50,7 +50,7 @@ public final class QuickFixAction { } public static void registerQuickFixAction(HighlightInfo info, IntentionAction action) { - registerQuickFixAction(info, null, action, null); + registerQuickFixAction(info, null, action); } public static void registerQuickFixActions(final HighlightInfo info, final Collection actions) { @@ -89,6 +89,10 @@ public final class QuickFixAction { doRegister(info, action, null, HighlightDisplayKey.getDisplayNameByKey(key), fixRange, key); } + public static void registerQuickFixAction(HighlightInfo info, TextRange fixRange, IntentionAction action) { + doRegister(info, action, null, null, fixRange, null); + } + public static void unregisterQuickFixAction(HighlightInfo info, Condition condition) { for (Iterator> it = info.quickFixActionRanges.iterator(); it.hasNext();) { Pair pair = it.next(); diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index 669b0d42c469..9708c56408dd 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -242,7 +242,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV for (final IntentionAction quickFixAction : quickFixActions) { if (quickFixAction == null) continue; - QuickFixAction.registerQuickFixAction(highlightInfo, textRange, quickFixAction, null); + QuickFixAction.registerQuickFixAction(highlightInfo, textRange, quickFixAction); } addToResults(highlightInfo); }