use of com.intellij.lang.javascript.linter.tslint.fix.TsLintErrorFixAction in project intellij-plugins by JetBrains.
the class TsLintExternalAnnotator method apply.
@Override
public void apply(@NotNull PsiFile file, @Nullable JSLinterAnnotationResult<TsLintState> annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null)
return;
TsLintConfigurable configurable = new TsLintConfigurable(file.getProject(), true);
final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
IntentionAction fixAllFileIntention = new TsLintFileFixAction().asIntentionAction();
JSLinterStandardFixes fixes = new JSLinterStandardFixes() {
@Override
public List<IntentionAction> createListForError(@Nullable VirtualFile configFile, @NotNull UntypedJSLinterConfigurable configurable, @NotNull JSLinterErrorBase errorBase) {
List<IntentionAction> defaultIntentions = super.createListForError(configFile, configurable, errorBase);
if (errorBase instanceof TsLinterError && ((TsLinterError) errorBase).hasFix()) {
ArrayList<IntentionAction> result = ContainerUtil.newArrayList();
if (document != null && myOnTheFly) {
result.add(new TsLintErrorFixAction((TsLinterError) errorBase, document));
}
result.add(fixAllFileIntention);
result.addAll(defaultIntentions);
return result;
}
return defaultIntentions;
}
};
new JSLinterAnnotationsBuilder<>(file, annotationResult, holder, TsLintInspection.getHighlightDisplayKey(), configurable, TsLintBundle.message("tslint.framework.title") + ": ", getInspectionClass(), fixes).setHighlightingGranularity(HighlightingGranularity.element).apply(document);
}
Aggregations