Search in sources :

Example 6 with Annotation

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

the class GutterAnnotationRenderer method onAnnotationModel.

@Override
public void onAnnotationModel(final AnnotationModelEvent event) {
    // remove removed and changed annotations
    for (final Annotation annotation : event.getRemovedAnnotations()) {
        LOG.fine("Remove annotation: " + annotation);
        removeAnnotationItem(event, annotation);
    }
    for (final Annotation annotation : event.getChangedAnnotations()) {
        LOG.fine("Remove changed annotation: " + annotation);
        removeAnnotationItem(event, annotation);
    }
    // add new and changed (new version) annotation
    for (final Annotation annotation : event.getAddedAnnotations()) {
        LOG.fine("Add annotation: " + annotation);
        addAnnotationItem(event.getAnnotationModel(), annotation);
    }
    for (final Annotation annotation : event.getChangedAnnotations()) {
        LOG.fine("Add back changed annotation: " + annotation);
        addAnnotationItem(event.getAnnotationModel(), annotation);
    }
}
Also used : Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 7 with Annotation

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

the class MinimapAnnotationRenderer method onAnnotationModel.

@Override
public void onAnnotationModel(final AnnotationModelEvent event) {
    // annotation is mutable, not easy to use a set
    final Map<Integer, List<Annotation>> toRestore = new HashMap<>();
    // remove removed and changed annotations
    for (final Annotation annotation : event.getRemovedAnnotations()) {
        LOG.fine("Remove annotation: " + annotation);
        removeAnnotationItem(event, annotation, toRestore);
    }
    for (final Annotation annotation : event.getChangedAnnotations()) {
        LOG.fine("Remove changed annotation: " + annotation);
        removeAnnotationItem(event, annotation, toRestore);
    }
    final Map<String, String> decorations = event.getAnnotationModel().getAnnotationStyle();
    // restore annotations that were deleted but shouldn't have
    for (final List<Annotation> annotations : toRestore.values()) {
        for (final Annotation annotation : annotations) {
            addAnnotationItem(event.getAnnotationModel(), annotation, decorations);
        }
    }
    // add new and changed (new version) annotation
    for (final Annotation annotation : event.getAddedAnnotations()) {
        LOG.fine("Add annotation: " + annotation);
        addAnnotationItem(event.getAnnotationModel(), annotation, decorations);
    }
    for (final Annotation annotation : event.getChangedAnnotations()) {
        LOG.fine("Add back changed annotation: " + annotation);
        addAnnotationItem(event.getAnnotationModel(), annotation, decorations);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 8 with Annotation

use of org.eclipse.che.ide.api.editor.text.annotation.Annotation 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 9 with Annotation

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

the class RegionIterator method next.

@Override
public Annotation next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    final Annotation result = next;
    next = findNext();
    return result;
}
Also used : NoSuchElementException(java.util.NoSuchElementException) Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 10 with Annotation

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

the class AnnotationsIterator method next.

@Override
public Annotation next() {
    final Annotation result = next;
    next = findNext();
    return result;
}
Also used : Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Aggregations

Annotation (org.eclipse.che.ide.api.editor.text.annotation.Annotation)13 Position (org.eclipse.che.ide.api.editor.text.Position)8 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)5 ArrayList (java.util.ArrayList)4 LinearRange (org.eclipse.che.ide.api.editor.text.LinearRange)4 TypedPosition (org.eclipse.che.ide.api.editor.text.TypedPosition)4 HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 NoSuchElementException (java.util.NoSuchElementException)1 AnnotationModel (org.eclipse.che.ide.api.editor.annotation.AnnotationModel)1 QueryAnnotationsEvent (org.eclipse.che.ide.api.editor.annotation.QueryAnnotationsEvent)1 Document (org.eclipse.che.ide.api.editor.document.Document)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 OrionProblemOverlay (org.eclipse.che.ide.editor.orion.client.jso.OrionProblemOverlay)1 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)1