use of org.eclipse.jface.text.ITextViewerExtension5 in project xtext-eclipse by eclipse.
the class MarkRegionTargetWithoutStatusline method isVisible.
/**
* Tells whether the given offset is visible in the given text viewer.
*
* @param viewer
* the text viewer
* @param offset
* the offset to check
* @return <code>true</code> if the given offset is visible in the given text viewer
*/
protected boolean isVisible(ITextViewer viewer, int offset) {
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
return extension.modelOffset2WidgetOffset(offset) >= 0;
}
IRegion region = viewer.getVisibleRegion();
int vOffset = region.getOffset();
return (vOffset <= offset && offset <= vOffset + region.getLength());
}
use of org.eclipse.jface.text.ITextViewerExtension5 in project xtext-eclipse by eclipse.
the class TextViewerJoinLinesAction method adjustHighlightRange.
/**
* Adjusts the highlight range so that at least the specified range
* is highlighted.
* <p>
* Subclasses may re-implement this method.</p>
*
* @param offset the offset of the range which at least should be highlighted
* @param length the length of the range which at least should be highlighted
*/
protected void adjustHighlightRange(ITextViewer viewer, int offset, int length) {
if (viewer == null)
return;
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
extension.exposeModelRange(new Region(offset, length));
} else if (!isVisible(viewer, offset, length)) {
viewer.resetVisibleRegion();
}
}
use of org.eclipse.jface.text.ITextViewerExtension5 in project xtext-eclipse by eclipse.
the class TextViewerJoinLinesAction method isVisible.
protected boolean isVisible(ITextViewer viewer, int offset, int length) {
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
IRegion overlap = extension.modelRange2WidgetRange(new Region(offset, length));
return overlap != null;
}
return viewer.overlapsWithVisibleRegion(offset, length);
}
Aggregations