Java源码示例:com.intellij.codeInsight.daemon.impl.SeverityRegistrar
示例1
@Override
public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<LintResult> annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null) {
return;
}
InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
// HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
// HighlightSeverity severity = InspectionUtil.getSeverity(inspectionProjectProfileManager, inspectionKey, file);
EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return;
}
SassLintProjectComponent component = annotationResult.input.project.getComponent(SassLintProjectComponent.class);
for (SassLint.Issue warn : annotationResult.result.sassLint.file.errors) {
HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings);
TextAttributes forcedTextAttributes = InspectionUtil.getTextAttributes(colorsScheme, severityRegistrar, severity);
Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false);
// if (annotation != null) {
// int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column);
// PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
// BaseActionFix actionFix = Fixes.getFixForRule(warn.rule, lit);
// if (actionFix != null) {
// annotation.registerFix(actionFix, null, inspectionKey);
// }
// annotation.registerFix(new SuppressActionFix(warn.rule, lit), null, inspectionKey);
// }
}
}
示例2
@Override
public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<Result> annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null) {
return;
}
InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return;
}
ESLintProjectComponent component = annotationResult.input.project.getComponent(ESLintProjectComponent.class);
for (VerifyMessage warn : annotationResult.result.warns) {
HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings);
TextAttributes forcedTextAttributes = JSLinterUtil.getTextAttributes(colorsScheme, severityRegistrar, severity);
Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false);
if (annotation != null) {
int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column);
PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
BaseActionFix actionFix = Fixes.getFixForRule(warn.ruleId, lit);
if (actionFix != null) {
annotation.registerFix(actionFix, null, inspectionKey);
}
annotation.registerFix(new SuppressActionFix(warn.ruleId, lit), null, inspectionKey);
annotation.registerFix(new SuppressLineActionFix(warn.ruleId, lit), null, inspectionKey);
}
}
}
示例3
@Nonnull
public static HighlightInfoType highlightTypeFromDescriptor(@Nonnull ProblemDescriptor problemDescriptor,
@Nonnull HighlightSeverity severity,
@Nonnull SeverityRegistrar severityRegistrar) {
final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
switch (highlightType) {
case GENERIC_ERROR_OR_WARNING:
return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
case LIKE_DEPRECATED:
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.DEPRECATED.getAttributesKey());
case LIKE_UNKNOWN_SYMBOL:
if (severity == HighlightSeverity.ERROR) {
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.WRONG_REF.getAttributesKey());
}
if (severity == HighlightSeverity.WARNING) {
return new HighlightInfoType.HighlightInfoTypeImpl(severity, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
}
return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
case LIKE_UNUSED_SYMBOL:
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
case INFO:
return HighlightInfoType.INFO;
case WEAK_WARNING:
return HighlightInfoType.WEAK_WARNING;
case ERROR:
return HighlightInfoType.WRONG_REF;
case GENERIC_ERROR:
return HighlightInfoType.ERROR;
case INFORMATION:
final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
if (attributes != null) {
return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes);
}
return HighlightInfoType.INFORMATION;
}
throw new RuntimeException("Cannot map " + highlightType);
}
示例4
@Inject
public InspectionProjectProfileManagerImpl(@Nonnull Project project,
@Nonnull InspectionProfileManager inspectionProfileManager,
@Nonnull DependencyValidationManager holder,
@Nonnull NamedScopeManager localScopesHolder) {
super(project, inspectionProfileManager, holder);
myLocalScopesHolder = localScopesHolder;
mySeverityRegistrar = new SeverityRegistrar(project.getMessageBus());
}
示例5
protected static String getTextAttributeKey(@Nonnull Project project,
@Nonnull HighlightSeverity severity,
@Nonnull ProblemHighlightType highlightType) {
if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
}
if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
}
if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
}
SeverityRegistrar registrar = InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar();
return registrar.getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
}
示例6
@Nonnull
private static Color getColor(@Nonnull Project project, @Nonnull HighlightSeverity severity) {
if (SeverityRegistrar.getSeverityRegistrar(project).compare(severity, HighlightSeverity.ERROR) >= 0) {
return LightColors.RED;
}
if (SeverityRegistrar.getSeverityRegistrar(project).compare(severity, HighlightSeverity.WARNING) >= 0) {
return LightColors.YELLOW;
}
return LightColors.GREEN;
}
示例7
private JPopupMenu compoundPopup() {
final DefaultActionGroup group = new DefaultActionGroup();
final SeverityRegistrar severityRegistrar = ((SeverityProvider)mySelectedProfile.getProfileManager()).getOwnSeverityRegistrar();
TreeSet<HighlightSeverity> severities = new TreeSet<HighlightSeverity>(severityRegistrar);
severities.add(HighlightSeverity.ERROR);
severities.add(HighlightSeverity.WARNING);
severities.add(HighlightSeverity.WEAK_WARNING);
final Collection<SeverityRegistrar.SeverityBasedTextAttributes> infoTypes =
SeverityUtil.getRegisteredHighlightingInfoTypes(severityRegistrar);
for (SeverityRegistrar.SeverityBasedTextAttributes info : infoTypes) {
severities.add(info.getSeverity());
}
for (HighlightSeverity severity : severities) {
final HighlightDisplayLevel level = HighlightDisplayLevel.find(severity);
group.add(new AnAction(renderSeverity(severity), renderSeverity(severity), level.getIcon()) {
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
setNewHighlightingLevel(level);
}
@Override
public boolean isDumbAware() {
return true;
}
});
}
group.add(AnSeparator.getInstance());
ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
return menu.getComponent();
}
示例8
public static SortedSet<HighlightSeverity> getSeverities(final SeverityRegistrar severityRegistrar) {
final SortedSet<HighlightSeverity> severities = new TreeSet<HighlightSeverity>(severityRegistrar);
for (final SeverityRegistrar.SeverityBasedTextAttributes type : SeverityUtil.getRegisteredHighlightingInfoTypes(severityRegistrar)) {
severities.add(type.getSeverity());
}
severities.add(HighlightSeverity.ERROR);
severities.add(HighlightSeverity.WARNING);
severities.add(HighlightSeverity.WEAK_WARNING);
severities.add(HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING);
return severities;
}
示例9
public static void registerProvidedSeverities() {
for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
for (HighlightInfoType t : provider.getSeveritiesHighlightInfoTypes()) {
HighlightSeverity highlightSeverity = t.getSeverity(null);
SeverityRegistrar.registerStandard(t, highlightSeverity);
TextAttributesKey attributesKey = t.getAttributesKey();
Icon icon = t instanceof HighlightInfoType.Iconable ? ((HighlightInfoType.Iconable)t).getIcon() : null;
HighlightDisplayLevel.registerSeverity(highlightSeverity, attributesKey, icon);
}
}
}
示例10
@Nonnull
@Override
public SeverityRegistrar getSeverityRegistrar() {
return mySeverityRegistrar;
}
示例11
@Nonnull
@Override
public SeverityRegistrar getOwnSeverityRegistrar() {
return mySeverityRegistrar;
}
示例12
public LevelChooserAction(final SeverityRegistrar severityRegistrar) {
mySeverityRegistrar = severityRegistrar;
}
示例13
@Nonnull
@Override
public SeverityRegistrar getSeverityRegistrar() {
return mySeverityRegistrar;
}
示例14
@Nonnull
@Override
public SeverityRegistrar getOwnSeverityRegistrar() {
return mySeverityRegistrar;
}
示例15
SeverityRegistrar getSeverityRegistrar();
示例16
SeverityRegistrar getOwnSeverityRegistrar();