• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TextChangeImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.editor.impl.TextChangeImpl的典型用法代码示例。如果您正苦于以下问题:Java TextChangeImpl类的具体用法?Java TextChangeImpl怎么用?Java TextChangeImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextChangeImpl类属于com.intellij.openapi.editor.impl包,在下文中一共展示了TextChangeImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: matchesOldSoftWrap

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
boolean matchesOldSoftWrap(SoftWrap newSoftWrap, int lengthDiff) {
  return Collections.binarySearch(myAffectedByUpdateSoftWraps, new SoftWrapImpl(new TextChangeImpl(newSoftWrap.getText(),
                                                                                                   newSoftWrap.getStart() - lengthDiff,
                                                                                                   newSoftWrap.getEnd() - lengthDiff),
                                                                                newSoftWrap.getIndentInColumns(),
                                                                                newSoftWrap.getIndentInPixels()),
                                  new Comparator<SoftWrapImpl>() {
                                    @Override
                                    public int compare(SoftWrapImpl o1, SoftWrapImpl o2) {
                                      int offsetDiff = o1.getStart() - o2.getStart();
                                      if (offsetDiff != 0) {
                                        return offsetDiff;
                                      }
                                      int textDiff = o1.getText().toString().compareTo(o2.getText().toString());
                                      if (textDiff != 0) {
                                        return textDiff;
                                      }
                                      int colIndentDiff = o1.getIndentInColumns() - o2.getIndentInColumns();
                                      if (colIndentDiff != 0) {
                                        return colIndentDiff;
                                      }
                                      return o1.getIndentInPixels() - o2.getIndentInPixels();
                                    }
                                  }) >= 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CachingSoftWrapDataMapper.java


示例2: doTest

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
private void doTest(String initial, String expected, TextChangeImpl ... changes) {
  if (myConfig.inplace()) {
    int diff = 0;
    for (TextChangeImpl change : changes) {
      diff += change.getDiff();
    }
    int outputUsefulLength = initial.length() + diff;
    int dataLength = myConfig.dataArrayLength();
    if (dataLength < 0) {
      dataLength = Math.max(outputUsefulLength, initial.length());
    }
    char[] data = new char[dataLength];
    System.arraycopy(initial.toCharArray(), 0, data, 0, initial.length());
    myMerger.mergeInPlace(data, initial.length(), Arrays.asList(changes));
    assertEquals(expected, new String(data, 0, outputUsefulLength));
  }
  else {
    int interestedSymbolsNumber = myConfig.initialTextLength();
    if (interestedSymbolsNumber < 0) {
      interestedSymbolsNumber = initial.length();
    }
    CharSequence actual = myMerger.mergeToCharSequence(initial.toCharArray(), interestedSymbolsNumber, Arrays.asList(changes));
    assertEquals(expected, actual.toString());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:BulkChangesMergerTest.java


示例3: 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


示例4: matchesOldSoftWrap

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
boolean matchesOldSoftWrap(SoftWrap newSoftWrap, int lengthDiff) {
  return Collections.binarySearch(myAffectedByUpdateSoftWraps, new SoftWrapImpl(new TextChangeImpl(newSoftWrap.getText(),
                                                                                                   newSoftWrap.getStart() - lengthDiff,
                                                                                                   newSoftWrap.getEnd() - lengthDiff),
                                                                                newSoftWrap.getIndentInColumns(),
                                                                                newSoftWrap.getIndentInPixels()),
                                  (o1, o2) -> {
                                    int offsetDiff = o1.getStart() - o2.getStart();
                                    if (offsetDiff != 0) {
                                      return offsetDiff;
                                    }
                                    int textDiff = o1.getText().toString().compareTo(o2.getText().toString());
                                    if (textDiff != 0) {
                                      return textDiff;
                                    }
                                    int colIndentDiff = o1.getIndentInColumns() - o2.getIndentInColumns();
                                    if (colIndentDiff != 0) {
                                      return colIndentDiff;
                                    }
                                    return o1.getIndentInPixels() - o2.getIndentInPixels();
                                  }) >= 0;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:CachingSoftWrapDataMapper.java


示例5: cutMultipleChanges

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void cutMultipleChanges() {
  populate(3, 3, "ABC");
  populate(8, 8, "DEF");
  populate(5, 9, "");
  checkResult(new TextChangeImpl("34", 3, 7));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:DocumentChangesCollectorTest.java


示例6: mergeMultipleChangesInOne

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void mergeMultipleChangesInOne() {
  populate(3, 3, "AB");
  populate(9, 9, "CD");
  populate(5, 9, "EFGH");
  checkResult(new TextChangeImpl("3456", 3, 11));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:DocumentChangesCollectorTest.java


示例7: mergeChangesSequence

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void mergeChangesSequence() {
  populate(1, 1, "AB");
  populate(3, 3, "CD");
  populate(5, 5, "EFGH");
  checkResult(new TextChangeImpl("", 1, 9));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:DocumentChangesCollectorTest.java


示例8: onSoftWrapEnd

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
public void onSoftWrapEnd() {
  myStorage.storeOrReplace(
    new SoftWrapImpl(
      new TextChangeImpl('\n' + mySoftWrapBuffer.toString(), softWrapStartOffset),
      mySoftWrapBuffer.length() + 1/* for 'after soft wrap' drawing */,
      (mySoftWrapBuffer.length() * SPACE_SIZE) + SOFT_WRAP_DRAWING_WIDTH
    ));
  mySoftWrapBuffer.setLength(0);
  insideSoftWrap = false;
  x += SOFT_WRAP_DRAWING_WIDTH;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:CachingSoftWrapDataMapperTest.java


示例9: propertiesExposing

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void propertiesExposing() {
  int start = 1;
  int end = 10;
  String text = "test";
  TextChange textChange = new TextChangeImpl(text, start, end);
  assertTrue(StringUtil.equals(text, textChange.getText()));
  assertArrayEquals(text.toCharArray(), textChange.getChars());
  assertEquals(start, textChange.getStart());
  assertEquals(end, textChange.getEnd());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TextChangeImplTest.java


示例10: 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


示例11: updateChanges

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
/**
 * Updates current object's state on the basis of the given event assuming that there are no stored change ranges that
 * start after offset denoted by the given event.
 *
 * @param event     event for just occurred document change
 * @param oldText   our main idea is to merge all changes in order to have aggregated change against original document. So, there is
 *                  a possible case that subsequent change affects text inserted by the previous one. We don't want to reflect that
 *                  at aggregated change as it didn't appear in initial document. Hence, we have a mutable symbols buffer that holds
 *                  symbols from initial document affected by the given change
 */
private void updateChanges(DocumentEvent event, StringBuilder oldText) {
  int i = findIndex(event.getOffset());
  int endOffset = event.getOffset() + event.getNewLength();
  TextChangeImpl change = new TextChangeImpl(oldText, event.getOffset(), endOffset);
  if (i < 0) {
    myChanges.add(change);
  }
  else {
    myChanges.add(i, change);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:DocumentChangesCollector.java


示例12: findIndex

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
/**
 * Finds index of the {@link #myCollectChanges first stored changed document ranges} which start offset is equal or greater to the
 * given one.
 *
 * @param offset    start offset of target document change
 * @return          non-negative value as an indication that there is not stored changed document range which start offset is equal
 *                  or greater than the given offset; negative value otherwise
 */
private int findIndex(int offset) {
  if (myChanges.isEmpty()) {
    return -1;
  }

  // We assume that document is changed sequentially from start to end, hence, it's worth to perform quick offset comparison with
  // the last stored change if any
  TextChangeImpl change = myChanges.get(myChanges.size() - 1);
  if (offset > change.getStart()) {
    return -1;
  }

  int start = 0;
  int end = myChanges.size() - 1;
  int result = -1;

  // We inline binary search here mainly because TextChange class is immutable and we don't want unnecessary expenses on
  // new key object construction on every method call.
  while (start <= end) {
    result = (end + start) >>> 1;
    change = myChanges.get(result);
    if (change.getStart() < offset) {
      start = ++result;
      continue;
    }
    if (change.getStart() > offset) {
      end = result - 1;
      continue;
    }
    break;
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:DocumentChangesCollector.java


示例13: onSoftWrapEnd

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
public void onSoftWrapEnd() {
  myStorage.storeOrReplace(
    new SoftWrapImpl(
      new TextChangeImpl('\n' + mySoftWrapBuffer.toString(), softWrapStartOffset),
      mySoftWrapBuffer.length() + 1/* for 'after soft wrap' drawing */,
      (mySoftWrapBuffer.length() * SPACE_SIZE) + SOFT_WRAP_DRAWING_WIDTH
    ),
    false
  );
  mySoftWrapBuffer.setLength(0);
  insideSoftWrap = false;
  x += SOFT_WRAP_DRAWING_WIDTH;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:CachingSoftWrapDataMapperTest.java


示例14: SoftWrapImpl

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
public SoftWrapImpl(@NotNull TextChangeImpl change, int indentInColumns, int indentInPixels) {
  myChange = change;
  myIndentInColumns = indentInColumns;
  myIndentInPixels = indentInPixels;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:SoftWrapImpl.java


示例15: getChange

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
public TextChangeImpl getChange() {
  return myChange;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:SoftWrapImpl.java


示例16: scatteredChanges

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void scatteredChanges() {
  populate(0, 0, "AB");
  populate(5, 5, "CD");
  checkResult(new TextChangeImpl("", 0, 2), new TextChangeImpl("", 5, 7));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DocumentChangesCollectorTest.java


示例17: insertAndReplaceAtEnd

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void insertAndReplaceAtEnd() {
  populate(0, 0, "AB");
  populate(1, 4, "CD");
  checkResult(new TextChangeImpl("01", 0, 3));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DocumentChangesCollectorTest.java


示例18: insertAndReplaceAtStart

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void insertAndReplaceAtStart() {
  populate(2, 2, "AB");
  populate(1, 3, "CD");
  checkResult(new TextChangeImpl("1", 1, 4));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DocumentChangesCollectorTest.java


示例19: removeAndReplace

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void removeAndReplace() {
  populate(1, 3, "");
  populate(1, 4, "ABC");
  checkResult(new TextChangeImpl("12345", 1, 4));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DocumentChangesCollectorTest.java


示例20: removedChangeWithNonStrictBoundaryMatch

import com.intellij.openapi.editor.impl.TextChangeImpl; //导入依赖的package包/类
@Test
public void removedChangeWithNonStrictBoundaryMatch() {
  populate(3, 5, "AB");
  populate(2, 4, "");
  checkResult(new TextChangeImpl("234", 2, 3));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DocumentChangesCollectorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Email类代码示例发布时间:2022-05-16
下一篇:
Java XSLParam类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap