Search in sources :

Example 1 with DartQuickFixSet

use of com.jetbrains.lang.dart.fixes.DartQuickFixSet in project intellij-plugins by JetBrains.

the class DartAnnotator method applyServerHighlighting.

private static void applyServerHighlighting(@NotNull final VirtualFile file, @NotNull final AnnotationHolder holder) {
    final PsiFile psiFile = holder.getCurrentAnnotationSession().getFile();
    final DartAnalysisServerService das = DartAnalysisServerService.getInstance(psiFile.getProject());
    for (DartServerData.DartError error : das.getErrors(file)) {
        if (shouldIgnoreMessageFromDartAnalyzer(file.getPath(), error.getAnalysisErrorFileSD()))
            continue;
        final Annotation annotation = createAnnotation(holder, error, psiFile.getTextLength());
        if (annotation != null) {
            final DartQuickFixSet quickFixSet = new DartQuickFixSet(psiFile.getManager(), file, error.getOffset(), error.getCode(), error.getSeverity());
            for (IntentionAction quickFix : quickFixSet.getQuickFixes()) {
                annotation.registerFix(quickFix);
            }
            if (error.getCode() != null) {
                annotation.setProblemGroup(new DartProblemGroup(error.getCode(), error.getSeverity()));
            }
        }
    }
    for (DartServerData.DartHighlightRegion region : das.getHighlight(file)) {
        final String attributeKey = HIGHLIGHTING_TYPE_MAP.get(region.getType());
        if (attributeKey != null) {
            final TextRange textRange = new TextRange(region.getOffset(), region.getOffset() + region.getLength());
            holder.createInfoAnnotation(textRange, null).setTextAttributes(TextAttributesKey.find(attributeKey));
        }
    }
}
Also used : DartQuickFixSet(com.jetbrains.lang.dart.fixes.DartQuickFixSet) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) PsiFile(com.intellij.psi.PsiFile) TextRange(com.intellij.openapi.util.TextRange) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) DartServerData(com.jetbrains.lang.dart.analyzer.DartServerData) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 Annotation (com.intellij.lang.annotation.Annotation)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiFile (com.intellij.psi.PsiFile)1 DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)1 DartServerData (com.jetbrains.lang.dart.analyzer.DartServerData)1 DartQuickFixSet (com.jetbrains.lang.dart.fixes.DartQuickFixSet)1