use of org.eclipse.che.ide.api.editor.text.TextRange in project che by eclipse.
the class OrionDocument method getSelectedTextRange.
@Override
public TextRange getSelectedTextRange() {
final OrionSelectionOverlay selection = this.textViewOverlay.getSelection();
final int start = selection.getStart();
final TextPosition startPosition = getPositionFromIndex(start);
final int end = selection.getEnd();
final TextPosition endPosition = getPositionFromIndex(end);
return new TextRange(startPosition, endPosition);
}
use of org.eclipse.che.ide.api.editor.text.TextRange in project che by eclipse.
the class OrionDocument method getTextRangeForLine.
@Override
public TextRange getTextRangeForLine(final int line) {
final int startOffset = this.textViewOverlay.getModel().getLineStart(line);
final int endOffset = this.textViewOverlay.getModel().getLineEnd(line);
final int length = endOffset - startOffset;
return new TextRange(new TextPosition(line, 0), new TextPosition(line, length));
}
use of org.eclipse.che.ide.api.editor.text.TextRange 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);
}
}
}
use of org.eclipse.che.ide.api.editor.text.TextRange in project che by eclipse.
the class SemanticHighlightRenderer method reconcile.
public void reconcile(List<HighlightedPosition> positions) {
for (HasTextMarkers.MarkerRegistration marker : markers) {
marker.clearMark();
}
markers.clear();
for (HighlightedPosition position : positions) {
final TextPosition from = this.document.getPositionFromIndex(position.getOffset());
final TextPosition to = this.document.getPositionFromIndex(position.getOffset() + position.getLength());
HasTextMarkers.MarkerRegistration registration = editor.addMarker(new TextRange(from, to), styleMap.get(position.getType()));
if (registration != null) {
markers.add(registration);
}
}
}
Aggregations