Search in sources :

Example 1 with TsLintConfigurable

use of com.intellij.lang.javascript.linter.tslint.ui.TsLintConfigurable 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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TsLintErrorFixAction(com.intellij.lang.javascript.linter.tslint.fix.TsLintErrorFixAction) TsLinterError(com.intellij.lang.javascript.linter.tslint.execution.TsLinterError) TsLintConfigurable(com.intellij.lang.javascript.linter.tslint.ui.TsLintConfigurable) Document(com.intellij.openapi.editor.Document) NotNull(org.jetbrains.annotations.NotNull) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) TsLintFileFixAction(com.intellij.lang.javascript.linter.tslint.fix.TsLintFileFixAction) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 TsLinterError (com.intellij.lang.javascript.linter.tslint.execution.TsLinterError)1 TsLintErrorFixAction (com.intellij.lang.javascript.linter.tslint.fix.TsLintErrorFixAction)1 TsLintFileFixAction (com.intellij.lang.javascript.linter.tslint.fix.TsLintFileFixAction)1 TsLintConfigurable (com.intellij.lang.javascript.linter.tslint.ui.TsLintConfigurable)1 Document (com.intellij.openapi.editor.Document)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1