Search in sources :

Example 1 with AnnotationModel

use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel 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 AnnotationModel

use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel in project che by eclipse.

the class OrionEditorWidget method showErrors.

public void showErrors(AnnotationModelEvent event) {
    List<Annotation> addedAnnotations = event.getAddedAnnotations();
    JsArray<OrionProblemOverlay> jsArray = JsArray.createArray().cast();
    AnnotationModel annotationModel = event.getAnnotationModel();
    OrionAnnotationSeverityProvider severityProvider = null;
    if (annotationModel instanceof OrionAnnotationSeverityProvider) {
        severityProvider = (OrionAnnotationSeverityProvider) annotationModel;
    }
    for (Annotation annotation : addedAnnotations) {
        Position position = annotationModel.getPosition(annotation);
        OrionProblemOverlay problem = JavaScriptObject.createObject().cast();
        problem.setDescription(annotation.getText());
        problem.setStart(position.getOffset());
        problem.setEnd(position.getOffset() + position.getLength());
        problem.setId("che-annotation");
        problem.setSeverity(getSeverity(annotation.getType(), severityProvider));
        jsArray.push(problem);
    }
    editorOverlay.showProblems(jsArray);
}
Also used : Position(org.eclipse.che.ide.api.editor.text.Position) OrionProblemOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionProblemOverlay) AnnotationModel(org.eclipse.che.ide.api.editor.annotation.AnnotationModel) Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 3 with AnnotationModel

use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel in project che by eclipse.

the class OrionEditorInit method configureAnnotationModel.

/**
     * Configures the editor's annotation model.
     * @param documentHandle the handle on the editor
     */
private void configureAnnotationModel(final DocumentHandle documentHandle) {
    final AnnotationModel annotationModel = configuration.getAnnotationModel();
    if (annotationModel == null) {
        return;
    }
    // add the renderers (event handler) before the model (event source)
    if (textEditor instanceof HasAnnotationRendering) {
        ((HasAnnotationRendering) textEditor).configure(annotationModel, documentHandle);
    }
    annotationModel.setDocumentHandle(documentHandle);
    documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, annotationModel);
    // the model listens to QueryAnnotation events
    documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel);
}
Also used : HasAnnotationRendering(org.eclipse.che.ide.api.editor.annotation.HasAnnotationRendering) AnnotationModel(org.eclipse.che.ide.api.editor.annotation.AnnotationModel)

Aggregations

AnnotationModel (org.eclipse.che.ide.api.editor.annotation.AnnotationModel)3 DiagnosticDTO (org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 HasAnnotationRendering (org.eclipse.che.ide.api.editor.annotation.HasAnnotationRendering)1 TextEditorConfiguration (org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)1 Position (org.eclipse.che.ide.api.editor.text.Position)1 Annotation (org.eclipse.che.ide.api.editor.text.annotation.Annotation)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 OrionProblemOverlay (org.eclipse.che.ide.editor.orion.client.jso.OrionProblemOverlay)1 Path (org.eclipse.che.ide.resource.Path)1