当前位置: 首页>>代码示例>>Java>>正文


Java TextChangeImpl.getEnd方法代码示例

本文整理汇总了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;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DocumentChangesCollector.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:TextChangeImplTest.java


注:本文中的com.intellij.openapi.editor.impl.TextChangeImpl.getEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。