diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java index f8cd9d74097e..492aa7872064 100644 --- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java +++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -56,7 +56,7 @@ public class HighlightDisplayLevel { for (Map.Entry entry : ourMap.entrySet()) { HighlightSeverity severity = entry.getKey(); HighlightDisplayLevel displayLevel = entry.getValue(); - if (Comparing.strEqual(severity.toString(), name)) { + if (Comparing.strEqual(severity.getName(), name)) { return displayLevel; } } @@ -82,6 +82,11 @@ public class HighlightDisplayLevel { return mySeverity.toString(); } + @NotNull + public String getName() { + return mySeverity.getName(); + } + public Icon getIcon() { return myIcon; } diff --git a/platform/analysis-api/src/com/intellij/lang/annotation/HighlightSeverity.java b/platform/analysis-api/src/com/intellij/lang/annotation/HighlightSeverity.java index ef19e0f17d43..eb375d23dea4 100644 --- a/platform/analysis-api/src/com/intellij/lang/annotation/HighlightSeverity.java +++ b/platform/analysis-api/src/com/intellij/lang/annotation/HighlightSeverity.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -76,7 +76,7 @@ public class HighlightSeverity implements Comparable { * if two annotations with different severity levels cover the same text range, only * the annotation with a higher severity level is displayed. */ - public HighlightSeverity(@NonNls String name, int val) { + public HighlightSeverity(@NonNls @NotNull String name, int val) { myName = name; myVal = val; } @@ -84,8 +84,7 @@ public class HighlightSeverity implements Comparable { //read external only public HighlightSeverity(@NotNull Element element) { - myName = JDOMExternalizerUtil.readField(element, "myName"); - myVal = Integer.valueOf(JDOMExternalizerUtil.readField(element, "myVal")); + this(JDOMExternalizerUtil.readField(element, "myName"), Integer.valueOf(JDOMExternalizerUtil.readField(element, "myVal"))); } public String toString() { @@ -113,4 +112,9 @@ public class HighlightSeverity implements Comparable { public int hashCode() { return myName.hashCode(); } + + @NotNull + public String getName() { + return myName; + } } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index b8c786952fde..e37a348a4d54 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -213,7 +213,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, Project project = element == null ? null : element.getProject(); final ToolsImpl tools = getTools(inspectionToolKey.toString(), project); HighlightDisplayLevel level = tools != null ? tools.getLevel(element) : HighlightDisplayLevel.WARNING; - if (!((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().isSeverityValid(level.getSeverity().toString())) { + if (!((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().isSeverityValid(level.getSeverity().getName())) { level = HighlightDisplayLevel.WARNING; setErrorLevel(inspectionToolKey, level, project); } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java index f8d215ceee24..b86ff683daa2 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -142,7 +142,7 @@ public class ToolsImpl implements Tools { for (ScopeToolState state : myTools) { final Element scopeElement = new Element("scope"); scopeElement.setAttribute("name", state.getScopeName()); - scopeElement.setAttribute(LEVEL_ATTRIBUTE, state.getLevel().toString()); + scopeElement.setAttribute(LEVEL_ATTRIBUTE, state.getLevel().getName()); scopeElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(state.isEnabled())); InspectionToolWrapper toolWrapper = state.getTool(); if (toolWrapper.isInitialized()) { @@ -152,7 +152,7 @@ public class ToolsImpl implements Tools { } } inspectionElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(isEnabled())); - inspectionElement.setAttribute(LEVEL_ATTRIBUTE, getLevel().toString()); + inspectionElement.setAttribute(LEVEL_ATTRIBUTE, getLevel().getName()); inspectionElement.setAttribute(ENABLED_BY_DEFAULT_ATTRIBUTE, Boolean.toString(myDefaultState.isEnabled())); InspectionToolWrapper toolWrapper = myDefaultState.getTool(); if (toolWrapper.isInitialized()) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java index 0b221e059da9..19a958a8bd71 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java @@ -229,7 +229,7 @@ public class TrafficProgressPanel extends JPanel { if (status.errorCount[i] > 0) { final HighlightSeverity severity = SeverityRegistrar.getSeverityRegistrar(myTrafficLightRenderer.getProject()).getSeverityByIndex(i); String name = - status.errorCount[i] > 1 ? StringUtil.pluralize(severity.toString().toLowerCase()) : severity.toString().toLowerCase(); + status.errorCount[i] > 1 ? StringUtil.pluralize(severity.getName().toLowerCase()) : severity.getName().toLowerCase(); text += status.errorAnalyzingFinished ? DaemonBundle.message("errors.found", status.errorCount[i], name) : DaemonBundle.message("errors.found.so.far", status.errorCount[i], name); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java index ec2974082ac7..b5333e8bd63e 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -29,7 +29,6 @@ import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -86,7 +85,7 @@ public class SeverityEditorDialog extends DialogWrapper { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof SeverityBasedTextAttributes) { - setText(((SeverityBasedTextAttributes)value).getSeverity().toString()); + setText(((SeverityBasedTextAttributes)value).getSeverity().getName()); } return rendererComponent; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index ed196a32d77e..5dffdf756cac 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -97,7 +97,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren public int compare(HighlightDisplayLevel o1, HighlightDisplayLevel o2) { final int severityDiff = o1.getSeverity().compareTo(o2.getSeverity()); if (severityDiff == 0) { - return o1.toString().compareTo(o2.toString()); + return o1.getName().compareTo(o2.getName()); } return severityDiff; } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index b512f43b247a..8b980cfd4976 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -610,7 +610,7 @@ public class SingleInspectionProfilePanel extends JPanel { } static String renderSeverity(HighlightSeverity severity) { - return StringUtil.capitalizeWords(severity.toString().toLowerCase(), true); + return StringUtil.capitalizeWords(severity.getName().toLowerCase(), true); } private void toggleToolNode(final InspectionConfigTreeNode toolNode) { @@ -1007,7 +1007,7 @@ public class SingleInspectionProfilePanel extends JPanel { final Set severities = ((InspectionProfileImpl)selectedProfile).getUsedSeverities(); for (Iterator iterator = severities.iterator(); iterator.hasNext();) { HighlightSeverity severity = iterator.next(); - if (registrar.isSeverityValid(severity.toString())) { + if (registrar.isSeverityValid(severity.getName())) { iterator.remove(); } } @@ -1015,9 +1015,9 @@ public class SingleInspectionProfilePanel extends JPanel { if (!severities.isEmpty()) { final SeverityRegistrar oppositeRegister = ((SeverityProvider)selectedProfile.getProfileManager()).getSeverityRegistrar(); for (HighlightSeverity severity : severities) { - final TextAttributesKey attributesKey = TextAttributesKey.find(severity.toString()); + final TextAttributesKey attributesKey = TextAttributesKey.find(severity.getName()); final TextAttributes textAttributes = oppositeRegister.getTextAttributesBySeverity(severity); - LOG.assertTrue(textAttributes != null, severity.toString()); + LOG.assertTrue(textAttributes != null, severity); HighlightInfoType.HighlightInfoTypeImpl info = new HighlightInfoType.HighlightInfoTypeImpl(severity, attributesKey); registrar.registerSeverity(new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes.clone(), info), textAttributes.getErrorStripeColor()); diff --git a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java index ffa6de7fba90..93de7cc42f88 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java +++ b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -138,7 +138,7 @@ public class ExpectedHighlightingData { for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) { for (HighlightInfoType type : provider.getSeveritiesHighlightInfoTypes()) { final HighlightSeverity severity = type.getSeverity(null); - highlightingTypes.put(severity.toString(), new ExpectedHighlightingSet(severity, false, true)); + highlightingTypes.put(severity.getName(), new ExpectedHighlightingSet(severity, false, true)); } } highlightingTypes.put(END_LINE_HIGHLIGHT_MARKER, new ExpectedHighlightingSet(HighlightSeverity.ERROR, true, true));