本文整理匯總了Java中org.eclipse.jface.text.Position.getLength方法的典型用法代碼示例。如果您正苦於以下問題:Java Position.getLength方法的具體用法?Java Position.getLength怎麽用?Java Position.getLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.Position
的用法示例。
在下文中一共展示了Position.getLength方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeOldAnnotation
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
private void removeOldAnnotation(final int offset) {
this.annotationModel.connect(this.document);
final Iterator<Annotation> iter = this.annotationModel.getAnnotationIterator();
Annotation beRemoved = null;
while (iter.hasNext()) {
beRemoved = iter.next();
if (!beRemoved.getType().equals(this.MME_REASON_ANNOT_TYPE)) {
continue;
}
final Position position = this.annotationModel.getPosition(beRemoved);
if (position.getOffset() + position.getLength() == offset || position.includes(offset)) {
this.annotationModel.removeAnnotation(beRemoved);
}
}
this.annotationModel.disconnect(this.document);
}
示例2: getMarkerPosition
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
/**
* Returns the actual position of <i>marker</i> or null if the marker was
* deleted. Code inspired by
* @param marker
* @param sourceViewer
* @return
*/
private static int[] getMarkerPosition(IMarker marker, ISourceViewer sourceViewer) {
int[] p = new int[2];
p[0] = marker.getAttribute(IMarker.CHAR_START, -1);
p[1] = marker.getAttribute(IMarker.CHAR_END, -1);
// look up the current range of the marker when the document has been edited
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model instanceof AbstractMarkerAnnotationModel) {
AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
Position pos= markerModel.getMarkerPosition(marker);
if (pos != null && !pos.isDeleted()) {
// use position instead of marker values
p[0] = pos.getOffset();
p[1] = pos.getOffset() + pos.getLength();
}
if (pos != null && pos.isDeleted()) {
// do nothing if position has been deleted
return null;
}
}
return p;
}
示例3: updateMarker
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
@Override
public boolean updateMarker(IMarker marker, IDocument document, Position position) {
try {
int start = position.getOffset();
int end = position.getOffset() + position.getLength();
marker.setAttribute(IMarker.CHAR_START, start);
marker.setAttribute(IMarker.CHAR_END, end);
} catch (CoreException e) {
Log.log(e);
}
return true;
}
示例4: contains
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
/**
* Checks whether the given offset is contained within this annotation
*
* @param offset The offset inside the document that this annotation belongs to
* @return True if the offset is contained, false otherwise
*/
public boolean contains(int offset) {
Position pos = node.getPosition();
if (offset >= pos.getOffset()
&& offset < (pos.getOffset() + pos.getLength()))
return true;
return false;
}
示例5: isRulerLine
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
private boolean isRulerLine(Position position, IDocument document, int line) {
if (position.getOffset() > -1 && position.getLength() > -1) {
try {
return line == document.getLineOfOffset(position.getOffset());
} catch (BadLocationException x) {
}
}
return false;
}
示例6: createStyleRange
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
private StyleRange createStyleRange(TextAttribute attr, Position position) {
StyleRange result = new StyleRange(position.getOffset(), position.getLength(), attr.getForeground(),
attr.getBackground(), attr.getStyle());
if ((attr.getStyle() & TextAttribute.UNDERLINE) != 0) {
result.underline = true;
result.fontStyle &= ~TextAttribute.UNDERLINE;
}
if ((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
result.strikeout = true;
result.fontStyle &= ~TextAttribute.STRIKETHROUGH;
}
return result;
}
開發者ID:angelozerr,項目名稱:angular-eclipse,代碼行數:14,代碼來源:HTMLAngularEditorSyntaxColoringPreferencePage.java
示例7: includesLine
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
private boolean includesLine(IDocument document, Position position, int line) {
if (position == null) {
return false;
}
try {
int line1 = document.getLineOfOffset(position.getOffset());
int line2 = position.getLength() == 0 ? line1
: document.getLineOfOffset(position.getOffset() + position.getLength() - 1);
return line >= line1 && line <= line2;
} catch (BadLocationException x) {
return false;
}
}
示例8: getFirstIndexEndingAfterOffset
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
/**
* Returns the index of the first position which ends after the given offset.
*
* @param positions the positions in linear order
* @param offset the offset
* @return the index of the first position which ends after the offset
*/
private int getFirstIndexEndingAfterOffset(Position[] positions, int offset) {
int i= -1, j= positions.length;
while (j - i > 1) {
int k= (i + j) >> 1;
Position p= positions[k];
if (p.getOffset() + p.getLength() > offset)
j= k;
else
i= k;
}
return j;
}
示例9: updateMarker
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
@Override
public boolean updateMarker(final IMarker marker, final IDocument doc, final Position position) {
try {
this.markerType = marker.getType();
final int start = position.getOffset();
final int end = position.getOffset() + position.getLength();
if (!MarkUtilities.getText(marker).equals(doc.get(start, position.getLength()))) {
// text of marker is changed
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
final IServiceLocator serviceLocator = PlatformUI.getWorkbench();
final ICommandService commandService = serviceLocator.getService(ICommandService.class);
try {
final Command command =
commandService.getCommand("eu.modelwriter.marker.command.updatechangeandimpact");
command.executeWithChecks(new ExecutionEvent());
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e1) {
e1.printStackTrace();
}
}
});
}
MarkUtilities.setStart(marker, start);
MarkUtilities.setEnd(marker, end);
MarkUtilities.setLinenumber(marker, doc.getLineOfOffset(start));
MarkUtilities.setText(marker, doc.get(start, position.getLength()));
MarkerUpdater.update(marker);
// TODO When the update action completed, you must trigger the Visualization.showViz method
// for refreshing the view.
return true;
} catch (CoreException | BadLocationException e) {
return false;
}
}
示例10: overlapsOrTouches
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
/**
* Returns <code>true</code> if the given ranges overlap with or touch each other.
*
* @param gap the first range
* @param offset the offset of the second range
* @param length the length of the second range
* @return <code>true</code> if the given ranges overlap with or touch each other
*/
private boolean overlapsOrTouches(Position gap, int offset, int length) {
return gap.getOffset() <= offset + length && offset <= gap.getOffset() + gap.getLength();
}
示例11: toString
import org.eclipse.jface.text.Position; //導入方法依賴的package包/類
/**
* 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$
}