Search in sources :

Example 1 with DiagnosticDTO

use of org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO in project che by eclipse.

the class PublishDiagnosticsProcessor method processDiagnostics.

public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
    EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
    //TODO add markers
    if (openedEditor == null) {
        return;
    }
    if (openedEditor instanceof TextEditor) {
        TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
        AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
        if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
            DiagnosticCollector collector = (DiagnosticCollector) annotationModel;
            collector.beginReporting();
            try {
                for (DiagnosticDTO diagnostic : diagnosticsMessage.getDiagnostics()) {
                    collector.acceptDiagnostic(diagnostic);
                }
            } finally {
                collector.endReporting();
            }
        }
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) DiagnosticDTO(org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO) AnnotationModel(org.eclipse.che.ide.api.editor.annotation.AnnotationModel) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)

Example 2 with DiagnosticDTO

use of org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO in project che by eclipse.

the class LanguageServerAnnotationModel method reportDiagnostic.

private void reportDiagnostic() {
    boolean temporaryProblemsChanged = false;
    if (!generatedAnnotations.isEmpty()) {
        temporaryProblemsChanged = true;
        super.clear();
        generatedAnnotations.clear();
    }
    if (diagnostics != null && !diagnostics.isEmpty()) {
        for (final DiagnosticDTO diagnostic : diagnostics) {
            final Position position = createPositionFromDiagnostic(diagnostic);
            if (position != null) {
                final DiagnosticAnnotation annotation = new DiagnosticAnnotation(diagnostic);
                addAnnotation(annotation, position, false);
                generatedAnnotations.add(annotation);
                temporaryProblemsChanged = true;
            }
        }
    }
    if (temporaryProblemsChanged) {
        fireModelChanged();
    }
}
Also used : DiagnosticDTO(org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position)

Aggregations

DiagnosticDTO (org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO)2 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 AnnotationModel (org.eclipse.che.ide.api.editor.annotation.AnnotationModel)1 TextEditorConfiguration (org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)1 Position (org.eclipse.che.ide.api.editor.text.Position)1 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Path (org.eclipse.che.ide.resource.Path)1