mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make program HighlightSeverity.toString()-independent
This commit is contained in:
@@ -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<HighlightSeverity, HighlightDisplayLevel> 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;
|
||||
}
|
||||
|
||||
@@ -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<HighlightSeverity> {
|
||||
* 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<HighlightSeverity> {
|
||||
|
||||
//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<HighlightSeverity> {
|
||||
public int hashCode() {
|
||||
return myName.hashCode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+4
-4
@@ -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<HighlightSeverity> severities = ((InspectionProfileImpl)selectedProfile).getUsedSeverities();
|
||||
for (Iterator<HighlightSeverity> 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());
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user