org.eclipse.jface.text.Position.overlapsWith()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.eclipse.jface.text.Position.overlapsWith()方法的一些代码示例,展示了Position.overlapsWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Position.overlapsWith()方法的具体详情如下:
包路径:org.eclipse.jface.text.Position
类名称:Position
方法名:overlapsWith

Position.overlapsWith介绍

[英]Checks whether the intersection of the given text range and the text range represented by this position is empty or not.
[中]检查给定文本范围与此位置表示的文本范围的交点是否为空。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.text

/**
   * 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);
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.text

/**
   * 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);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

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;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

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;
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.jsp.core

/**
 * 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()]);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * 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()]);
}

代码示例来源:origin: RepreZen/KaiZen-OpenAPI-Editor

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;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * 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()]);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@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;
}

代码示例来源:origin: org.eclipse/org.eclipse.compare

private boolean intersectsRegion(MergeSourceViewer viewer,
    IRegion region) {
  Position p = getPosition(viewer);
  if (p != null)
    return p.overlapsWith(region.getOffset(), region.getLength());
  return false;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.compare

private boolean intersectsRegion(int contributor, IRegion region) {
  Position p = getPosition(contributor);
  if (p != null)
    return p.overlapsWith(region.getOffset(), region.getLength());
  return false;
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.text.ui

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;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@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;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

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;
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

/**
 * 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;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.text

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));
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.text

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));
  }
}

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

/**
 * 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);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.text

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);
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.text

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);
  }
}

相关文章