/** * If <code>regionOffset</code> is the end of the visible region and the <code>regionLength == 0</code>, * the <code>regionOffset</code> is considered overlapping with the visible region. * * @see org.eclipse.jface.text.Position#overlapsWith(int, int) */ @Override public boolean overlapsWith(int regionOffset, int regionLength) { boolean appending= (regionOffset == offset + length) && regionLength == 0; return appending || super.overlapsWith(regionOffset, regionLength); } }
/** * If <code>regionOffset</code> is the end of the visible region and the <code>regionLength == 0</code>, * the <code>regionOffset</code> is considered overlapping with the visible region. * * @see org.eclipse.jface.text.Position#overlapsWith(int, int) */ @Override public boolean overlapsWith(int regionOffset, int regionLength) { boolean appending= (regionOffset == offset + length) && regionLength == 0; return appending || super.overlapsWith(regionOffset, regionLength); } }
private boolean touches(Point selection, Position position) { return position.overlapsWith(selection.x, selection.y) || selection.y == 0 && position.offset + position.length == selection.x + selection.y; }
private boolean touches(Point selection, Position position) { return position.overlapsWith(selection.x, selection.y) || selection.y == 0 && position.offset + position.length == selection.x + selection.y; }
/** * Returns the Java positions for the given range in the Java document. * * @param offset * @param length * @return */ public Position[] getJavaRanges(int offset, int length) { List results = new ArrayList(); Iterator it = getJava2JspMap().keySet().iterator(); Position p = null; while(it.hasNext()) { p = (Position)it.next(); if(p.overlapsWith(offset, length)) results.add(p); } return (Position[])results.toArray(new Position[results.size()]); }
/** * Returns the positions of all annotations that intersect with * <code>modelSelection</code> and that are at least partly visible. * @param modelSelection a model range * @return the positions of all annotations that intersect with * <code>modelSelection</code> * @since 3.1 */ private Position[] computeOverlappingAnnotationPositions(IRegion modelSelection) { List<Position> positions= new ArrayList<>(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); Position position= fProjectionAnnotationModel.getPosition(annotation); if (position != null && position.overlapsWith(modelSelection.getOffset(), modelSelection.getLength()) && modelRange2WidgetRange(position) != null) positions.add(position); } return positions.toArray(new Position[positions.size()]); }
protected List<IMarker> getMarkersFor(ISourceViewer sourceViewer, int lineOffset, int lineLength) { List<IMarker> result = new ArrayList<>(); IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); Iterator annotationIter = annotationModel.getAnnotationIterator(); while (annotationIter.hasNext()) { Object annotation = annotationIter.next(); if (annotation instanceof MarkerAnnotation) { MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation; IMarker marker = markerAnnotation.getMarker(); Position markerPosition = annotationModel.getPosition(markerAnnotation); if (markerPosition != null && markerPosition.overlapsWith(lineOffset, lineLength)) { result.add(marker); } } } return result; }
/** * Returns the positions of all annotations that intersect with * <code>modelSelection</code> and that are at least partly visible. * @param modelSelection a model range * @return the positions of all annotations that intersect with * <code>modelSelection</code> * @since 3.1 */ private Position[] computeOverlappingAnnotationPositions(IRegion modelSelection) { List<Position> positions= new ArrayList<>(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); Position position= fProjectionAnnotationModel.getPosition(annotation); if (position != null && position.overlapsWith(modelSelection.getOffset(), modelSelection.getLength()) && modelRange2WidgetRange(position) != null) positions.add(position); } return positions.toArray(new Position[positions.size()]); }
@Override public boolean overlapsWithVisibleRegion(int start, int length) { IDocument document= getVisibleDocument(); if (document instanceof ChildDocument) { ChildDocument cdoc= (ChildDocument) document; return cdoc.getParentDocumentRange().overlapsWith(start, length); } else if (document != null) { int size= document.getLength(); return (start >= 0 && length >= 0 && start + length <= size); } return false; }
private boolean intersectsRegion(MergeSourceViewer viewer, IRegion region) { Position p = getPosition(viewer); if (p != null) return p.overlapsWith(region.getOffset(), region.getLength()); return false; }
private boolean intersectsRegion(int contributor, IRegion region) { Position p = getPosition(contributor); if (p != null) return p.overlapsWith(region.getOffset(), region.getLength()); return false; }
public boolean overlapsWithVisibleRegion(int start, int length) { IDocument document= getVisibleDocument(); if (document instanceof ChildDocument) { ChildDocument cdoc= (ChildDocument) document; return cdoc.getParentDocumentRange().overlapsWith(start, length); } else if (document != null) { int size= document.getLength(); return (start >= 0 && length >= 0 && start + length <= size); } return false; }
@Override public boolean overlapsWithVisibleRegion(int start, int length) { IDocument document= getVisibleDocument(); if (document instanceof ChildDocument) { ChildDocument cdoc= (ChildDocument) document; return cdoc.getParentDocumentRange().overlapsWith(start, length); } else if (document != null) { int size= document.getLength(); return (start >= 0 && length >= 0 && start + length <= size); } return false; }
private String getAnnotationModelHoverMessage(IAnnotationModel model, IRegion hoverRegion) { Iterator<Annotation> e = model.getAnnotationIterator(); while (e.hasNext()) { Annotation a = e.next(); if (a instanceof XMLProblemAnnotation) { Position p = model.getPosition(a); if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) { String msg = a.getText(); if (msg != null && msg.trim().length() > 0) { return formatMessage(msg); } } } } return null; }
/** * Returns the annotation overlapping with the given range or <code>null</code>. * * @param offset the region offset * @param length the region length * @return the found annotation or <code>null</code> * @since 3.0 */ private Annotation getAnnotation(int offset, int length) { IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); Iterator e= new JavaAnnotationIterator(model, true, false); while (e.hasNext()) { Annotation a= (Annotation) e.next(); Position p= model.getPosition(a); if (p != null && p.overlapsWith(offset, length)) return a; } return null; }
private boolean isWithinRegion(int start, int length) { if (fCanStartBefore && fCanEndAfter) return fRegion.overlapsWith(start, length); else if (fCanStartBefore) return fRegion.includes(start + length - (length > 0 ? 1 : 0)); else if (fCanEndAfter) return fRegion.includes(start); else return fRegion.includes(start) && fRegion.includes(start + length - (length > 0 ? 1 : 0)); } }
private boolean isWithinRegion(int start, int length) { if (fCanStartBefore && fCanEndAfter) return fRegion.overlapsWith(start, length); else if (fCanStartBefore) return fRegion.includes(start + length - (length > 0 ? 1 : 0)); else if (fCanEndAfter) return fRegion.includes(start); else return fRegion.includes(start) && fRegion.includes(start + length - (length > 0 ? 1 : 0)); } }
/** * Deletes all the spelling annotations located inside the area marked by <code>region</code> */ private void deleteAllAnnotations(IRegion region) { IAnnotationModel model = getAnnotationModel(); if (model == null) return; Iterator<?> iter = model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation = (Annotation) iter.next(); if (annotation instanceof SpellingAnnotation) { SpellingAnnotation spellingAnnotation = (SpellingAnnotation) annotation; Position position = model.getPosition(spellingAnnotation); if (position.overlapsWith(region.getOffset(), region.getLength())) { model.removeAnnotation(spellingAnnotation); } } } }
private boolean isWithinRegion(Position region, Position position, boolean canStartBefore, boolean canEndAfter) { if (canStartBefore && canEndAfter) { return region.overlapsWith(position.getOffset(), position.getLength()); } else if (canStartBefore) { return region.includes(position.getOffset() + position.getLength() - 1); } else if (canEndAfter) { return region.includes(position.getOffset()); } else { int start= position.getOffset(); return region.includes(start) && region.includes(start + position.getLength() - 1); } }
private boolean isWithinRegion(Position region, Position position, boolean canStartBefore, boolean canEndAfter) { if (canStartBefore && canEndAfter) { return region.overlapsWith(position.getOffset(), position.getLength()); } else if (canStartBefore) { return region.includes(position.getOffset() + position.getLength() - 1); } else if (canEndAfter) { return region.includes(position.getOffset()); } else { int start= position.getOffset(); return region.includes(start) && region.includes(start + position.getLength() - 1); } }