本文整理汇总了Java中com.intellij.openapi.editor.impl.TextChangeImpl.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java TextChangeImpl.getEnd方法的具体用法?Java TextChangeImpl.getEnd怎么用?Java TextChangeImpl.getEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.impl.TextChangeImpl
的用法示例。
在下文中一共展示了TextChangeImpl.getEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeChangesIfNecessary
import com.intellij.openapi.editor.impl.TextChangeImpl; //导入方法依赖的package包/类
private void mergeChangesIfNecessary(DocumentEvent event) {
// There is a possible case that we had more than one scattered change (e.g. (3; 5) and (8; 10)) and current document change affects
// both of them (e.g. remove all symbols from offset (4; 9)). We have two changes then: (3; 4) and (4; 5) and want to merge them
// into a single one.
if (myChanges.size() < 2) {
return;
}
TextChangeImpl next = myChanges.get(myChanges.size() - 1);
for (int i = myChanges.size() - 2; i >= 0; i--) {
TextChangeImpl current = myChanges.get(i);
if (current.getEnd() < event.getOffset()) {
// Assuming that change ranges are always kept at normalized form.
break;
}
if (current.getEnd() == next.getStart()) {
myChanges.set(i, next = new TextChangeImpl(current.getText().toString() + next.getText(), current.getStart(), next.getEnd()));
myChanges.remove(i + 1);
}
else {
next = current;
}
}
}
示例2: advance
import com.intellij.openapi.editor.impl.TextChangeImpl; //导入方法依赖的package包/类
@Test
public void advance() {
TextChangeImpl base = new TextChangeImpl("xyz", 3, 5);
int[] offsets = {5, 0, -3};
for (int offset : offsets) {
int start = base.getStart();
int end = base.getEnd();
base.advance(offset);
assertEquals(new TextChangeImpl(base.getText(), start + offset, end + offset), base);
}
}