Search in sources :

Example 1 with MarkerRegistration

use of org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers.MarkerRegistration in project che by eclipse.

the class InlineAnnotationRenderer method addAnnotationItem.

/**
     * Add an inline annotation.
     *
     * @param annotationModel the annotation model
     * @param annotation the annotation to add
     * @param decorations the available decorations
     */
private void addAnnotationItem(AnnotationModel annotationModel, Annotation annotation, Map<String, String> decorations) {
    if (this.hasTextMarkers != null) {
        final String className = decorations.get(annotation.getType());
        if (className == null) {
            return;
        }
        final Position position = annotationModel.getPosition(annotation);
        if (position == null) {
            Log.warn(InlineAnnotationRenderer.class, "Can't add annotation with no position");
            return;
        }
        final TextPosition from = this.document.getPositionFromIndex(position.getOffset());
        final TextPosition to = this.document.getPositionFromIndex(position.getOffset() + position.getLength());
        final MarkerRegistration registration = this.hasTextMarkers.addMarker(new TextRange(from, to), className);
        if (registration != null) {
            this.markers.put(annotation, registration);
        }
    }
}
Also used : MarkerRegistration(org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers.MarkerRegistration) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextRange(org.eclipse.che.ide.api.editor.text.TextRange)

Aggregations

Position (org.eclipse.che.ide.api.editor.text.Position)1 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)1 TextRange (org.eclipse.che.ide.api.editor.text.TextRange)1 MarkerRegistration (org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers.MarkerRegistration)1