Java 类com.intellij.util.text.MergingCharSequence 实例源码

项目:consulo    文件:LineSet.java   
@Nonnull
LineSet update(@Nonnull CharSequence prevText, int start, int end, @Nonnull CharSequence replacement, boolean wholeTextReplaced) {
  if (myLength == 0) {
    return createLineSet(replacement, !wholeTextReplaced);
  }

  LineSet result = isSingleLineChange(start, end, replacement)
                   ? updateInsideOneLine(findLineIndex(start), replacement.length() - (end - start))
                   : genericUpdate(prevText, start, end, replacement);

  if (doTest) {
    MergingCharSequence newText = new MergingCharSequence(
            new MergingCharSequence(prevText.subSequence(0, start), replacement),
            prevText.subSequence(end, prevText.length()));
    result.checkEquals(createLineSet(newText));
  }
  return wholeTextReplaced ? result.clearModificationFlags() : result;
}
项目:intellij-ce-playground    文件:ByWord.java   
@NotNull
private static Couple<FairDiffIterable> comparePunctuation2Side(@NotNull CharSequence text1,
                                                                @NotNull CharSequence text21,
                                                                @NotNull CharSequence text22,
                                                                @NotNull ProgressIndicator indicator) {
  CharSequence text2 = new MergingCharSequence(text21, text22);
  FairDiffIterable changes = ByChar.comparePunctuation(text1, text2, indicator);

  Couple<List<Range>> ranges = splitIterable2Side(changes, text21.length());

  FairDiffIterable iterable1 = fair(createUnchanged(ranges.first, text1.length(), text21.length()));
  FairDiffIterable iterable2 = fair(createUnchanged(ranges.second, text1.length(), text22.length()));
  return Couple.of(iterable1, iterable2);
}
项目:intellij-ce-playground    文件:LayeredLexerEditorHighlighter.java   
@NotNull
private MappedRange insertMapping(int tokenIndex, IElementType outerToken) {
  CharSequence tokenText = getTokenText(tokenIndex);

  final int length = tokenText.length();

  MappedRange predecessor = findPredecessor(tokenIndex);

  int insertOffset = predecessor != null ? predecessor.range.getEndOffset() : 0;
  doc.insertString(insertOffset, new MergingCharSequence(mySeparator, tokenText));
  insertOffset += mySeparator.length();

  RangeMarker marker = doc.createRangeMarker(insertOffset, insertOffset + length);
  return new MappedRange(this, marker, outerToken);
}
项目:tools-idea    文件:LayeredLexerEditorHighlighter.java   
@NotNull
private MappedRange insertMapping(int tokenIndex, IElementType outerToken) {
  CharSequence tokenText = getTokenText(tokenIndex);

  final int length = tokenText.length();

  MappedRange predecessor = findPredecessor(tokenIndex);

  int insertOffset = predecessor != null ? predecessor.range.getEndOffset() : 0;
  doc.insertString(insertOffset, new MergingCharSequence(mySeparator, tokenText));
  insertOffset += mySeparator.length();

  RangeMarker marker = doc.createRangeMarker(insertOffset, insertOffset + length);
  return new MappedRange(this, marker, outerToken);
}
项目:consulo    文件:ByWord.java   
@Nonnull
private static Couple<FairDiffIterable> comparePunctuation2Side(@Nonnull CharSequence text1,
                                                                @Nonnull CharSequence text21,
                                                                @Nonnull CharSequence text22,
                                                                @Nonnull ProgressIndicator indicator) {
  CharSequence text2 = new MergingCharSequence(text21, text22);
  FairDiffIterable changes = ByChar.comparePunctuation(text1, text2, indicator);

  Couple<List<Range>> ranges = splitIterable2Side(changes, text21.length());

  FairDiffIterable iterable1 = fair(createUnchanged(ranges.first, text1.length(), text21.length()));
  FairDiffIterable iterable2 = fair(createUnchanged(ranges.second, text1.length(), text22.length()));
  return Couple.of(iterable1, iterable2);
}
项目:consulo    文件:LexerEditorHighlighter.java   
@Nonnull
public List<TextAttributes> getAttributesForPreviousAndTypedChars(@Nonnull Document document, int offset, char c) {
  final CharSequence text = document.getImmutableCharSequence();

  final CharSequence newText =
          new MergingCharSequence(new MergingCharSequence(text.subSequence(0, offset), new SingleCharSequence(c)), text.subSequence(offset, text.length()));

  final List<IElementType> tokenTypes = getTokenType(newText, offset);

  return Arrays.asList(getAttributes(tokenTypes.get(0)).clone(), getAttributes(tokenTypes.get(1)).clone());
}
项目:consulo    文件:LayeredLexerEditorHighlighter.java   
@Nonnull
private MappedRange insertMapping(int tokenIndex, IElementType outerToken) {
  CharSequence tokenText = getTokenText(tokenIndex);

  final int length = tokenText.length();

  MappedRange predecessor = findPredecessor(tokenIndex);

  int insertOffset = predecessor != null ? predecessor.range.getEndOffset() : 0;
  doc.insertString(insertOffset, new MergingCharSequence(mySeparator, tokenText));
  insertOffset += mySeparator.length();

  RangeMarker marker = doc.createRangeMarker(insertOffset, insertOffset + length);
  return new MappedRange(this, marker, outerToken);
}