diff options
Diffstat (limited to 'platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java')
-rw-r--r-- | platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index 483f3c5b2839..88f230f8f2d3 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -21,11 +21,9 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionManager; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.actions.CleanupInspectionIntention; import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.codeInspection.ex.QuickFixWrapper; import com.intellij.lang.ASTNode; import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.HighlightSeverity; @@ -114,8 +112,7 @@ public class HighlightInfo implements Segment { String description = this.description; if (toolTip == null || description == null || !toolTip.contains(DESCRIPTION_PLACEHOLDER)) return toolTip; String decoded = StringUtil.replace(toolTip, DESCRIPTION_PLACEHOLDER, XmlStringUtil.escapeString(description)); - String niceTooltip = XmlStringUtil.wrapInHtml(decoded); - return niceTooltip; + return XmlStringUtil.wrapInHtml(decoded); } private static String encodeTooltip(String toolTip, String description) { @@ -177,10 +174,7 @@ public class HighlightInfo implements Segment { return forcedTextAttributes; } - final EditorColorsScheme colorsScheme = getColorsScheme(editorColorsScheme); - if (colorsScheme == null) { - return null; - } + EditorColorsScheme colorsScheme = getColorsScheme(editorColorsScheme); if (forcedTextAttributesKey != null) { return colorsScheme.getAttributes(forcedTextAttributesKey); @@ -208,10 +202,7 @@ public class HighlightInfo implements Segment { if (forcedTextAttributes != null && forcedTextAttributes.getErrorStripeColor() != null) { return forcedTextAttributes.getErrorStripeColor(); } - final EditorColorsScheme scheme = getColorsScheme(colorsScheme); - if (scheme == null) { - return null; - } + EditorColorsScheme scheme = getColorsScheme(colorsScheme); if (forcedTextAttributesKey != null) { TextAttributes forcedTextAttributes = scheme.getAttributes(forcedTextAttributesKey); if (forcedTextAttributes != null) { @@ -244,7 +235,7 @@ public class HighlightInfo implements Segment { } - @Nullable + @NotNull private static EditorColorsScheme getColorsScheme(@Nullable final EditorColorsScheme customScheme) { if (customScheme != null) { return customScheme; @@ -325,6 +316,7 @@ public class HighlightInfo implements Segment { return true; } + @Override public boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof HighlightInfo)) return false; @@ -340,7 +332,7 @@ public class HighlightInfo implements Segment { Comparing.strEqual(info.getDescription(), getDescription()); } - public boolean equalsByActualOffset(HighlightInfo info) { + public boolean equalsByActualOffset(@NotNull HighlightInfo info) { if (info == this) return true; return info.getSeverity() == getSeverity() && @@ -353,10 +345,12 @@ public class HighlightInfo implements Segment { Comparing.strEqual(info.getDescription(), getDescription()); } + @Override public int hashCode() { return startOffset; } + @Override @NonNls public String toString() { return getDescription() != null ? getDescription() : ""; @@ -658,7 +652,7 @@ public class HighlightInfo implements Segment { public static final String ANNOTATOR_INSPECTION_SHORT_NAME = "Annotator"; - private static void appendFixes(@Nullable TextRange fixedRange, @NotNull HighlightInfo info, List<Annotation.QuickFixInfo> fixes) { + private static void appendFixes(@Nullable TextRange fixedRange, @NotNull HighlightInfo info, @Nullable List<Annotation.QuickFixInfo> fixes) { if (fixes != null) { for (final Annotation.QuickFixInfo quickFixInfo : fixes) { TextRange range = fixedRange != null ? fixedRange : quickFixInfo.textRange; @@ -670,6 +664,7 @@ public class HighlightInfo implements Segment { } } + @NotNull public static HighlightInfoType convertType(@NotNull Annotation annotation) { ProblemHighlightType type = annotation.getHighlightType(); if (type == ProblemHighlightType.LIKE_UNUSED_SYMBOL) return HighlightInfoType.UNUSED_SYMBOL; @@ -688,6 +683,7 @@ public class HighlightInfo implements Segment { HighlightInfoType.INFORMATION; } + @NotNull public static ProblemHighlightType convertType(HighlightInfoType infoType) { if (infoType == HighlightInfoType.ERROR || infoType == HighlightInfoType.WRONG_REF) return ProblemHighlightType.ERROR; if (infoType == HighlightInfoType.WARNING) return ProblemHighlightType.GENERIC_ERROR_OR_WARNING; @@ -695,6 +691,7 @@ public class HighlightInfo implements Segment { return ProblemHighlightType.WEAK_WARNING; } + @NotNull public static ProblemHighlightType convertSeverityToProblemHighlight(HighlightSeverity severity) { return severity == HighlightSeverity.ERROR ? ProblemHighlightType.ERROR : severity == HighlightSeverity.WARNING ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING : @@ -763,7 +760,7 @@ public class HighlightInfo implements Segment { return myAction; } - public boolean canCleanup(PsiElement element) { + public boolean canCleanup(@NotNull PsiElement element) { if (myCanCleanup == null) { InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile(); final HighlightDisplayKey key = myKey; @@ -794,7 +791,8 @@ public class HighlightInfo implements Segment { if (options != null || key == null) { return options; } - List<IntentionAction> newOptions = IntentionManager.getInstance().getStandardIntentionOptions(key, element); + IntentionManager intentionManager = IntentionManager.getInstance(); + List<IntentionAction> newOptions = intentionManager.getStandardIntentionOptions(key, element); InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile(); InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element); if (!(toolWrapper instanceof LocalInspectionToolWrapper)) { @@ -807,29 +805,9 @@ public class HighlightInfo implements Segment { myCanCleanup = toolWrapper.isCleanupTool(); - InspectionProfileEntry wrappedTool; - if (toolWrapper instanceof LocalInspectionToolWrapper) { - wrappedTool = ((LocalInspectionToolWrapper)toolWrapper).getTool(); - Class aClass = myAction.getClass(); - if (myAction instanceof QuickFixWrapper) { - aClass = ((QuickFixWrapper)myAction).getFix().getClass(); - } - newOptions.add(new CleanupInspectionIntention(toolWrapper, aClass)); - } - else if (toolWrapper instanceof GlobalInspectionToolWrapper) { - wrappedTool = ((GlobalInspectionToolWrapper)toolWrapper).getTool(); - if (wrappedTool instanceof GlobalSimpleInspectionTool && (myAction instanceof LocalQuickFix || myAction instanceof QuickFixWrapper)) { - Class aClass = myAction.getClass(); - if (myAction instanceof QuickFixWrapper) { - aClass = ((QuickFixWrapper)myAction).getFix().getClass(); - } - newOptions.add(new CleanupInspectionIntention(toolWrapper, aClass)); - } - } - else { - throw new AssertionError("unknown tool: " + toolWrapper+"; key: "+myKey); - } - + ContainerUtil.addIfNotNull(newOptions, intentionManager.createFixAllIntention(toolWrapper, myAction)); + InspectionProfileEntry wrappedTool = toolWrapper instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)toolWrapper).getTool() + : ((GlobalInspectionToolWrapper)toolWrapper).getTool(); if (wrappedTool instanceof CustomSuppressableInspectionTool) { final IntentionAction[] suppressActions = ((CustomSuppressableInspectionTool)wrappedTool).getSuppressActions(element); if (suppressActions != null) { @@ -868,6 +846,7 @@ public class HighlightInfo implements Segment { return myDisplayName; } + @Override @NonNls public String toString() { String text = getAction().getText(); |