本文整理汇总了Java中org.eclipse.jface.text.link.LinkedPosition.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedPosition.getOffset方法的具体用法?Java LinkedPosition.getOffset怎么用?Java LinkedPosition.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.link.LinkedPosition
的用法示例。
在下文中一共展示了LinkedPosition.getOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExit
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
if (position != null) {
if (event.character == SWT.BS) {
if (offset - 1 < position.getOffset()) {
//skip backspace at beginning of linked position
event.doit= false;
}
} else /* event.character == SWT.DEL */ {
if (offset + 1 > position.getOffset() + position.getLength()) {
//skip delete at end of linked position
event.doit= false;
}
}
}
}
return null; // don't change behavior
}
示例2: doExit
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
showPreview = (event.stateMask & SWT.CTRL) != 0 && (event.character == SWT.CR || event.character == SWT.LF);
if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
LinkedPosition position = model.findPosition(new LinkedPosition(document, offset, 0,
LinkedPositionGroup.NO_STOP));
if (position != null) {
if (event.character == SWT.BS) {
if (offset - 1 < position.getOffset()) {
// skip backspace at beginning of linked position
event.doit = false;
}
} else /* event.character == SWT.DEL */{
if (offset + 1 > position.getOffset() + position.getLength()) {
// skip delete at end of linked position
event.doit = false;
}
}
}
}
return null; // don't change behavior
}
示例3: sortPositions
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
protected Iterable<LinkedPosition> sortPositions(Iterable<LinkedPosition> linkedPositions,
final int invocationOffset) {
Comparator<LinkedPosition> comparator = new Comparator<LinkedPosition>() {
public int compare(LinkedPosition left, LinkedPosition right) {
return rank(left) - rank(right);
}
private int rank(LinkedPosition o1) {
int relativeRank = o1.getOffset() + o1.length - invocationOffset;
if (relativeRank < 0)
return Integer.MAX_VALUE + relativeRank;
else
return relativeRank;
}
};
return ImmutableSortedSet.copyOf(comparator, linkedPositions);
}
示例4: doExit
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
if (position != null) {
if (event.character == SWT.BS) {
if (offset - 1 < position.getOffset()) {
//skip backspace at beginning of linked position
event.doit= false;
}
} else /* event.character == SWT.DEL */ {
if (offset + 1 > position.getOffset() + position.getLength()) {
//skip delete at end of linked position
event.doit= false;
}
}
}
}
return null; // don't change behavior
}
示例5: compare
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* <p><code>o1</code> and <code>o2</code> are required to be instances
* of <code>LinkedPosition</code>.</p>
*/
public int compare(Object o1, Object o2) {
LinkedPosition p1= (LinkedPosition)o1;
LinkedPosition p2= (LinkedPosition)o2;
int i= p1.getSequenceNumber() - p2.getSequenceNumber();
if (i != 0)
return i;
return p1.getOffset() - p2.getOffset();
}
示例6: findNextPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the next position after the given position.
*
* @param position
* the current position
* @return the next position
*/
protected int findNextPosition(int position) {
ISourceViewer viewer = getSourceViewer();
int widget = -1;
int next = position;
while (next != BreakIterator.DONE && widget == -1) {
next = fIterator.following(next);
if (next != BreakIterator.DONE)
widget = modelOffset2WidgetOffset(viewer, next);
}
IDocument document = viewer.getDocument();
LinkedModeModel model = LinkedModeModel.getModel(document, position);
if (model != null) {
LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionEnd = linkedPosition.getOffset() + linkedPosition.getLength();
if (position != linkedPositionEnd && linkedPositionEnd < next)
next = linkedPositionEnd;
} else {
LinkedPosition nextLinkedPosition = model.findPosition(new LinkedPosition(document, next, 0));
if (nextLinkedPosition != null) {
int nextLinkedPositionOffset = nextLinkedPosition.getOffset();
if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next)
next = nextLinkedPositionOffset;
}
}
}
return next;
}
示例7: findPreviousPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the previous position before the given position.
*
* @param position
* the current position
* @return the previous position
*/
protected int findPreviousPosition(int position) {
ISourceViewer viewer = getSourceViewer();
int widget = -1;
int previous = position;
while (previous != BreakIterator.DONE && widget == -1) { // XXX: optimize
previous = fIterator.preceding(previous);
if (previous != BreakIterator.DONE)
widget = modelOffset2WidgetOffset(viewer, previous);
}
IDocument document = viewer.getDocument();
LinkedModeModel model = LinkedModeModel.getModel(document, position);
if (model != null) {
LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionOffset = linkedPosition.getOffset();
if (position != linkedPositionOffset && previous < linkedPositionOffset)
previous = linkedPositionOffset;
} else {
LinkedPosition previousLinkedPosition = model
.findPosition(new LinkedPosition(document, previous, 0));
if (previousLinkedPosition != null) {
int previousLinkedPositionEnd = previousLinkedPosition.getOffset()
+ previousLinkedPosition.getLength();
if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd)
previous = previousLinkedPositionEnd;
}
}
}
return previous;
}
示例8: findNextPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the next position after the given position.
*
* @param position the current position
* @return the next position
*/
protected int findNextPosition(int position) {
ISourceViewer viewer= getSourceViewer();
int widget= -1;
int next= position;
while (next != BreakIterator.DONE && widget == -1) { // XXX: optimize
next= fIterator.following(next);
if (next != BreakIterator.DONE)
widget= modelOffset2WidgetOffset(viewer, next);
}
IDocument document= viewer.getDocument();
LinkedModeModel model= LinkedModeModel.getModel(document, position);
if (model != null && next != BreakIterator.DONE) {
LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionEnd= linkedPosition.getOffset() + linkedPosition.getLength();
if (position != linkedPositionEnd && linkedPositionEnd < next)
next= linkedPositionEnd;
} else {
LinkedPosition nextLinkedPosition= model.findPosition(new LinkedPosition(document, next, 0));
if (nextLinkedPosition != null) {
int nextLinkedPositionOffset= nextLinkedPosition.getOffset();
if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next)
next= nextLinkedPositionOffset;
}
}
}
return next;
}
示例9: findPreviousPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the previous position before the given position.
*
* @param position the current position
* @return the previous position
*/
protected int findPreviousPosition(int position) {
ISourceViewer viewer= getSourceViewer();
int widget= -1;
int previous= position;
while (previous != BreakIterator.DONE && widget == -1) { // XXX: optimize
previous= fIterator.preceding(previous);
if (previous != BreakIterator.DONE)
widget= modelOffset2WidgetOffset(viewer, previous);
}
IDocument document= viewer.getDocument();
LinkedModeModel model= LinkedModeModel.getModel(document, position);
if (model != null && previous != BreakIterator.DONE) {
LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionOffset= linkedPosition.getOffset();
if (position != linkedPositionOffset && previous < linkedPositionOffset)
previous= linkedPositionOffset;
} else {
LinkedPosition previousLinkedPosition= model.findPosition(new LinkedPosition(document, previous, 0));
if (previousLinkedPosition != null) {
int previousLinkedPositionEnd= previousLinkedPosition.getOffset() + previousLinkedPosition.getLength();
if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd)
previous= previousLinkedPositionEnd;
}
}
}
return previous;
}
示例10: findNextPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the next position after the given position.
*
* @param position the current position
* @return the next position
*/
protected int findNextPosition(int position) {
ISourceViewer viewer= getSourceViewer();
int widget= -1;
int next= position;
while (next != BreakIterator.DONE && widget == -1) { // XXX: optimize
next= fIterator.following(next);
if (next != BreakIterator.DONE)
widget= modelOffset2WidgetOffset(viewer, next);
}
IDocument document= viewer.getDocument();
LinkedModeModel model= LinkedModeModel.getModel(document, position);
if (model != null) {
LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionEnd= linkedPosition.getOffset() + linkedPosition.getLength();
if (position != linkedPositionEnd && linkedPositionEnd < next)
next= linkedPositionEnd;
} else {
LinkedPosition nextLinkedPosition= model.findPosition(new LinkedPosition(document, next, 0));
if (nextLinkedPosition != null) {
int nextLinkedPositionOffset= nextLinkedPosition.getOffset();
if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next)
next= nextLinkedPositionOffset;
}
}
}
return next;
}
示例11: findPreviousPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the previous position before the given position.
*
* @param position the current position
* @return the previous position
*/
protected int findPreviousPosition(int position) {
ISourceViewer viewer= getSourceViewer();
int widget= -1;
int previous= position;
while (previous != BreakIterator.DONE && widget == -1) { // XXX: optimize
previous= fIterator.preceding(previous);
if (previous != BreakIterator.DONE)
widget= modelOffset2WidgetOffset(viewer, previous);
}
IDocument document= viewer.getDocument();
LinkedModeModel model= LinkedModeModel.getModel(document, position);
if (model != null) {
LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionOffset= linkedPosition.getOffset();
if (position != linkedPositionOffset && previous < linkedPositionOffset)
previous= linkedPositionOffset;
} else {
LinkedPosition previousLinkedPosition= model.findPosition(new LinkedPosition(document, previous, 0));
if (previousLinkedPosition != null) {
int previousLinkedPositionEnd= previousLinkedPosition.getOffset() + previousLinkedPosition.getLength();
if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd)
previous= previousLinkedPositionEnd;
}
}
}
return previous;
}
示例12: findNextPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the next position after the given position.
*
* @param position the current position
* @return the next position
*/
protected int findNextPosition(int position) {
ISourceViewer viewer = getSourceViewer();
int widget = -1;
int next = position;
while (next != BreakIterator.DONE && widget == -1) { // XXX: optimize
next = fIterator.following(next);
if (next != BreakIterator.DONE) {
widget = modelOffset2WidgetOffset(viewer, next);
}
}
IDocument document = viewer.getDocument();
LinkedModeModel model = LinkedModeModel.getModel(document, position);
if (model != null && next != BreakIterator.DONE) {
LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionEnd = linkedPosition.getOffset() + linkedPosition.getLength();
if (position != linkedPositionEnd && linkedPositionEnd < next) {
next = linkedPositionEnd;
}
} else {
LinkedPosition nextLinkedPosition = model.findPosition(new LinkedPosition(document, next, 0));
if (nextLinkedPosition != null) {
int nextLinkedPositionOffset = nextLinkedPosition.getOffset();
if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next) {
next = nextLinkedPositionOffset;
}
}
}
}
return next;
}
示例13: findPreviousPosition
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
/**
* Finds the previous position before the given position.
*
* @param position the current position
* @return the previous position
*/
protected int findPreviousPosition(int position) {
ISourceViewer viewer = getSourceViewer();
int widget = -1;
int previous = position;
while (previous != BreakIterator.DONE && widget == -1) { // XXX: optimize
previous = fIterator.preceding(previous);
if (previous != BreakIterator.DONE) {
widget = modelOffset2WidgetOffset(viewer, previous);
}
}
IDocument document = viewer.getDocument();
LinkedModeModel model = LinkedModeModel.getModel(document, position);
if (model != null && previous != BreakIterator.DONE) {
LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
if (linkedPosition != null) {
int linkedPositionOffset = linkedPosition.getOffset();
if (position != linkedPositionOffset && previous < linkedPositionOffset) {
previous = linkedPositionOffset;
}
} else {
LinkedPosition previousLinkedPosition = model
.findPosition(new LinkedPosition(document, previous, 0));
if (previousLinkedPosition != null) {
int previousLinkedPositionEnd = previousLinkedPosition.getOffset()
+ previousLinkedPosition.getLength();
if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd) {
previous = previousLinkedPositionEnd;
}
}
}
}
return previous;
}
示例14: computeEdits
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException {
return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString);
}
示例15: computeEdits
import org.eclipse.jface.text.link.LinkedPosition; //导入方法依赖的package包/类
public TextEdit computeEdits(
int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model)
throws CoreException {
return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString);
}