use of com.scss.utils.scssLint.Lint in project scss-lint-plugin by idok.
the class ScssLintAnnotationResult method apply.
@Override
public void apply(@NotNull PsiFile file, ScssLintAnnotationResult 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;
}
if (annotationResult.fileLevel != null) {
Annotation annotation = holder.createWarningAnnotation(file, annotationResult.fileLevel);
annotation.registerFix(new EditSettingsAction(new ScssLintSettingsPage(file.getProject())));
annotation.setFileLevelAnnotation(true);
return;
}
// TODO consider adding a fix to edit configuration file
if (annotationResult.result == null || annotationResult.result.lint == null || annotationResult.result.lint.isEmpty()) {
return;
}
// String relativeFile = FileUtils.makeRelative(file.getProject(), file.getVirtualFile());
List<Lint.Issue> issues = annotationResult.result.lint.values().iterator().next();
if (issues == null) {
return;
}
ScssLintProjectComponent component = annotationResult.input.project.getComponent(ScssLintProjectComponent.class);
int tabSize = 4;
for (Lint.Issue issue : issues) {
HighlightSeverity severity = getHighlightSeverity(issue, component.treatAsWarnings);
TextAttributes forcedTextAttributes = AnnotatorUtils.getTextAttributes(colorsScheme, severityRegistrar, severity);
Annotation annotation = createAnnotation(holder, file, document, issue, "SCSS Lint: ", tabSize, severity, forcedTextAttributes, inspectionKey, false);
if (annotation != null) {
int offset = StringUtil.lineColToOffset(document.getText(), issue.line - 1, issue.column);
PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
BaseActionFix actionFix = Fixes.getFixForRule(issue.linter, lit);
if (actionFix != null) {
annotation.registerFix(actionFix, null, inspectionKey);
}
// annotation.registerFix(new SuppressActionFix(issue.rule, lit), null, inspectionKey);
}
}
}
Aggregations