use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method copyUsedSeveritiesIfUndefined.
private static void copyUsedSeveritiesIfUndefined(InspectionProfileImpl selectedProfile, BaseInspectionProfileManager profileManager) {
final SeverityRegistrar registrar = profileManager.getSeverityRegistrar();
final Set<HighlightSeverity> severities = selectedProfile.getUsedSeverities();
for (Iterator<HighlightSeverity> iterator = severities.iterator(); iterator.hasNext(); ) {
HighlightSeverity severity = iterator.next();
if (registrar.isSeverityValid(severity.getName())) {
iterator.remove();
}
}
if (!severities.isEmpty()) {
final SeverityRegistrar oppositeRegister = selectedProfile.getProfileManager().getSeverityRegistrar();
for (HighlightSeverity severity : severities) {
final TextAttributesKey attributesKey = TextAttributesKey.find(severity.getName());
final TextAttributes textAttributes = oppositeRegister.getTextAttributesBySeverity(severity);
if (textAttributes == null) {
continue;
}
HighlightInfoType.HighlightInfoTypeImpl info = new HighlightInfoType.HighlightInfoTypeImpl(severity, attributesKey);
registrar.registerSeverity(new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes.clone(), info), textAttributes.getErrorStripeColor());
}
}
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method compoundPopup.
private JPopupMenu compoundPopup() {
final DefaultActionGroup group = new DefaultActionGroup();
final SeverityRegistrar severityRegistrar = myProfile.getProfileManager().getOwnSeverityRegistrar();
for (HighlightSeverity severity : LevelChooserAction.getSeverities(severityRegistrar, includeDoNotShow())) {
final HighlightDisplayLevel level = HighlightDisplayLevel.find(severity);
group.add(new AnAction(renderSeverity(severity), renderSeverity(severity), level.getIcon()) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
setNewHighlightingLevel(level);
}
@Override
public boolean isDumbAware() {
return true;
}
});
}
group.add(Separator.getInstance());
ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
return menu.getComponent();
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class SeverityRegistrar method fromList.
@NotNull
private static OrderMap fromList(@NotNull List<HighlightSeverity> orderList) {
if (orderList.size() != new HashSet<>(orderList).size()) {
LOG.error("Severities order list MUST contain only unique severities: " + orderList);
}
TObjectIntHashMap<HighlightSeverity> map = new TObjectIntHashMap<>();
for (int i = 0; i < orderList.size(); i++) {
HighlightSeverity severity = orderList.get(i);
map.put(severity, i);
}
return new OrderMap(map);
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class SeverityRegistrar method registerSeverity.
public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor) {
final HighlightSeverity severity = info.getType().getSeverity(null);
myMap.put(severity.getName(), info);
if (renderColor != null) {
myRendererColors.put(severity.getName(), renderColor);
}
myOrderMap = null;
HighlightDisplayLevel.registerSeverity(severity, getHighlightInfoTypeBySeverity(severity).getAttributesKey(), null);
severitiesChanged();
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class SeverityRegistrar method readExternal.
public void readExternal(@NotNull Element element) {
myMap.clear();
myRendererColors.clear();
for (Element infoElement : element.getChildren(INFO_TAG)) {
SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes(infoElement);
String colorStr = infoElement.getAttributeValue(COLOR_ATTRIBUTE);
@SuppressWarnings("UseJBColor") Color color = colorStr == null ? null : new Color(Integer.parseInt(colorStr, 16));
registerSeverity(highlightInfo, color);
}
myReadOrder = new JDOMExternalizableStringList();
myReadOrder.readExternal(element);
List<HighlightSeverity> read = new ArrayList<>(myReadOrder.size());
final List<HighlightSeverity> knownSeverities = getDefaultOrder();
for (String name : myReadOrder) {
HighlightSeverity severity = getSeverity(name);
if (severity != null && knownSeverities.contains(severity)) {
read.add(severity);
}
}
myOrderMap = ensureAllStandardIncluded(read, knownSeverities);
severitiesChanged();
}
Aggregations