本文整理了Java中org.eclipse.jface.text.Position.getLength()
方法的一些代码示例,展示了Position.getLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Position.getLength()
方法的具体详情如下:
包路径:org.eclipse.jface.text.Position
类名称:Position
方法名:getLength
[英]Returns the length of this position.
[中]返回此位置的长度。
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.text
/**
* Returns the end offset of the keyword.
*
* @return the end offset of the keyword
*/
public int getEnd() {
return fPosition.getOffset() + fPosition.getLength();
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.text.compat
/**
* Pretty print a <code>Position</code>.
*
* @param position the position to format
* @return a formatted string
*/
private String toString(Position position) {
return "P[" + position.getOffset() + "+" + position.getLength() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Pretty print a <code>Position</code>.
*
* @param position the position to format
* @return a formatted string
*/
private String toString(Position position) {
return "P[" + position.getOffset() + "+" + position.getLength() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
private boolean covers(List<Position> coverage, Position position) {
Iterator<Position> e= coverage.iterator();
while (e.hasNext()) {
Position p= e.next();
if (p.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= p.getOffset() + p.getLength())
return true;
}
return false;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
private boolean covers(List<Position> coverage, Position position) {
Iterator<Position> e= coverage.iterator();
while (e.hasNext()) {
Position p= e.next();
if (p.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= p.getOffset() + p.getLength())
return true;
}
return false;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@Override
public void apply(IDocument document) {
try {
document.replace(fReplacementPosition.getOffset(), fReplacementPosition.getLength(), fReplacementString);
} catch (BadLocationException x) {
// ignore
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.compare
public Diff findDiff(char contributor, Position range) {
int start= range.getOffset();
int end= start + range.getLength();
return findDiff(contributor, start, end);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
@Override
public void apply(IDocument document) {
try {
document.replace(fReplacementPosition.getOffset(), fReplacementPosition.getLength(), fReplacementString);
} catch (BadLocationException x) {
// ignore
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@Override
public IRegion getRangeIndication() {
if (fRangeIndicator != null && fVisualAnnotationModel != null) {
Position position= fVisualAnnotationModel.getPosition(fRangeIndicator);
if (position != null)
return new Region(position.getOffset(), position.getLength());
}
return null;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
@Override
public IRegion getRangeIndication() {
if (fRangeIndicator != null && fVisualAnnotationModel != null) {
Position position= fVisualAnnotationModel.getPosition(fRangeIndicator);
if (position != null)
return new Region(position.getOffset(), position.getLength());
}
return null;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
/**
* Same as {@link #modelRange2WidgetRange(IRegion)} just for a {@link org.eclipse.jface.text.Position}.
*
* @param modelPosition the position describing a range in the viewer's document
* @return a region describing a range in the viewer's widget
* @since 2.1
*/
protected IRegion modelRange2WidgetRange(Position modelPosition) {
return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength()));
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@Override
public void update(DocumentEvent event) {
int offset= event.getOffset();
int length= event.getLength();
int delta= event.getText().length() - length;
if (offset < fPosition.getOffset())
fPosition.setOffset(fPosition.getOffset() + delta);
else if (offset < fPosition.getOffset() + fPosition.getLength())
fPosition.setLength(fPosition.getLength() + delta);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Returns <code>true</code> if inlined annotation is deleted and <code>false</code> otherwise.
*
* @param annotation the inlined annotation to check
* @return <code>true</code> if inlined annotation is deleted and <code>false</code> otherwise.
*/
private static boolean isDeleted(AbstractInlinedAnnotation annotation) {
return annotation.isMarkedDeleted() || annotation.getPosition().isDeleted() || annotation.getPosition().getLength() == 0;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, boolean fireRedraw) throws BadLocationException {
for (int i= 0; i < removedAnnotations.length; i++) {
ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i];
if (annotation.isCollapsed()) {
Position expanded= event.getPositionOfRemovedAnnotation(annotation);
expand(expanded.getOffset(), expanded.getLength(), fireRedraw);
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.compare
private void add(String s, DocumentRangeNode parent, DocumentRangeNode child) {
Position p= findCorrespondingPosition(parent, child);
if (p != null) {
try {
fBaseDocument.replace(p.getOffset(), p.getLength(), s);
} catch (BadLocationException ex) {
CompareUIPlugin.log(ex);
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.compare
private void add(String s, DocumentRangeNode parent, DocumentRangeNode child) {
Position p= findCorrespondingPosition(parent, child);
if (p != null) {
try {
fBaseDocument.replace(p.getOffset(), p.getLength(), s);
} catch (BadLocationException ex) {
CompareUIPlugin.log(ex);
}
}
}
代码示例来源:origin: org.eclipse.mylyn.wikitext/ui
protected IHyperlink createHyperlink(ISourceViewer viewer, IAnnotationModel annotationModel,
AnchorHrefAnnotation anchorHrefAnnotation) {
Position position = annotationModel.getPosition(anchorHrefAnnotation);
IRegion region = new Region(position.getOffset(), position.getLength());
String href = anchorHrefAnnotation.getAnchorHref();
if (href != null && href.startsWith("#")) { //$NON-NLS-1$
return new DocumentHyperlink(viewer, region, href);
} else {
return createUrlHyperlink(region, href);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.search
public static Position convertToCharacterPosition(Position linePosition, IDocument doc) throws BadLocationException {
int lineOffset= linePosition.getOffset();
int lineLength= linePosition.getLength();
int charOffset= doc.getLineOffset(lineOffset);
int charLength= 0;
if (lineLength > 0) {
int lastLine= lineOffset+lineLength-1;
int endPosition= doc.getLineOffset(lastLine)+doc.getLineLength(lastLine);
charLength= endPosition-charOffset;
}
return new Position(charOffset, charLength);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
@Override
public IRegion getVisibleRegion() {
IDocument document= getVisibleDocument();
if (document instanceof ChildDocument) {
Position p= ((ChildDocument) document).getParentDocumentRange();
return new Region(p.getOffset(), p.getLength());
}
return new Region(0, document == null ? 0 : document.getLength());
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
private boolean includes(IRegion[] regions, Position position) {
for (int i= 0; i < regions.length; i++) {
IRegion region= regions[i];
if (position != null && !position.isDeleted()
&& region.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength())
return true;
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!