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

项目:intellij-ce-playground    文件:EditorImpl.java   
@Override
public void drawChars(@NotNull Graphics g,
                      @NotNull char[] data,
                      int start,
                      int end,
                      int x,
                      int y,
                      Color color,
                      @NotNull FontInfo fontInfo)
{
  if (myUseNewRendering) {
    myView.drawChars(g, data, start, end, x, y, color, fontInfo);
  }
  else {
    drawCharsCached(g, new CharArrayCharSequence(data), start, end, x, y, fontInfo, color, false);
  }
}
项目:intellij-ce-playground    文件:CompactSyntaxLexerAdapter.java   
@Override
public int read(char[] cbuf, int off, int len) {
  if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return 0;
  }

  if (myText instanceof CharArrayCharSequence) { // Optimization
    final int readChars = ((CharArrayCharSequence)myText).readCharsTo(myCurPos, cbuf, off, len);
    if (readChars < 0) return -1;
    myCurPos += readChars;
    return readChars;
  }

  int charsToCopy = Math.min(len, myEndOffset - myCurPos);
  if (charsToCopy <= 0) return -1;

  for (int n = 0; n < charsToCopy; n++) {
    cbuf[n + off] = myText.charAt(n + myCurPos);
  }

  myCurPos += charsToCopy;
  return charsToCopy;
}
项目:tools-idea    文件:CompactSyntaxLexerAdapter.java   
public int read(char[] cbuf, int off, int len) {
  if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return 0;
  }

  if (myText instanceof CharArrayCharSequence) { // Optimization
    final int readChars = ((CharArrayCharSequence)myText).readCharsTo(myCurPos, cbuf, off, len);
    if (readChars < 0) return -1;
    myCurPos += readChars;
    return readChars;
  }

  int charsToCopy = Math.min(len, myEndOffset - myCurPos);
  if (charsToCopy <= 0) return -1;

  for (int n = 0; n < charsToCopy; n++) {
    cbuf[n + off] = myText.charAt(n + myCurPos);
  }

  myCurPos += charsToCopy;
  return charsToCopy;
}
项目:intellij-ce-playground    文件:bigFile.java   
@Override
public void drawChars(@NotNull Graphics g,
                      @NotNull char[] data,
                      int start,
                      int end,
                      int x,
                      int y,
                      Color color,
                      @NotNull FontInfo fontInfo)
{
  drawCharsCached(g, new CharArrayCharSequence(data), start, end, x, y, fontInfo, color, false);
}
项目:intellij-ce-playground    文件:bigFile.java   
@Override
public void drawChars(@NotNull Graphics g,
                      @NotNull char[] data,
                      int start,
                      int end,
                      int x,
                      int y,
                      Color color,
                      @NotNull FontInfo fontInfo) {
  drawCharsCached(g, new CharArrayCharSequence(data), start, end, x, y, fontInfo, color, false);
}
项目:intellij-ce-playground    文件:FileBasedIndexTest.java   
public void testLargeFile() throws Exception {
  char[] text = new char[FileUtilRt.LARGE_FOR_CONTENT_LOADING + 42];
  final String clazz = "class Foo { String bar; }";
  for (int i = 0; i < text.length; i++) {
    text[i] = i < clazz.length() ? clazz.charAt(i) : ' ';
  }
  final LightVirtualFile file = new LightVirtualFile("Foo.java", new CharArrayCharSequence(text));
  assertFalse(((FileBasedIndexImpl)FileBasedIndex.getInstance()).isIndexingCandidate(file, StubUpdatingIndex.INDEX_ID));
}
项目:intellij-ce-playground    文件:ShelveChangesManager.java   
private static List<TextFilePatch> loadPatches(Project project,
                                               final String patchPath,
                                               CommitContext commitContext,
                                               boolean loadContent) throws IOException, PatchSyntaxException {
  char[] text = FileUtil.loadFileText(new File(patchPath), CharsetToolkit.UTF8);
  PatchReader reader = new PatchReader(new CharArrayCharSequence(text), loadContent);
  final List<TextFilePatch> textFilePatches = reader.readAllPatches();
  final TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo = reader.getAdditionalInfo(
    null);
  ApplyPatchDefaultExecutor.applyAdditionalInfoBefore(project, additionalInfo, commitContext);
  return textFilePatches;
}
项目:intellij-ce-playground    文件:CompactSyntaxLexerAdapter.java   
@Deprecated
public void start(char[] buffer, int startOffset, int endOffset, int initialState) {
  myBuffer = new CharArrayCharSequence(buffer, startOffset, endOffset);

  final CharArrayReader reader = new CharArrayReader(buffer, startOffset, endOffset - startOffset);
  init(startOffset, endOffset, reader, initialState);
}
项目:intellij-ce-playground    文件:GroovyEnterHandler.java   
private static void convertEndToMultiline(int caretOffset, Document document, String fileText, char c) {
  if (caretOffset < fileText.length() && fileText.charAt(caretOffset) == c ||
      caretOffset > 0 && fileText.charAt(caretOffset - 1) == c) {
    document.insertString(caretOffset, new CharArrayCharSequence(c, c));
  }
  else {
    document.insertString(caretOffset, new CharArrayCharSequence(c, c, c));
  }
}
项目:tools-idea    文件:StringUtil.java   
public static int stringHashCode(@NotNull CharSequence chars) {
  if (chars instanceof String) return chars.hashCode();
  if (chars instanceof CharSequenceWithStringHash) return chars.hashCode();
  if (chars instanceof CharArrayCharSequence) return chars.hashCode();

  return stringHashCode(chars, 0, chars.length());
}
项目:tools-idea    文件:CharArray.java   
@Override
@NotNull
public CharSequence subSequence(final int start, final int end) {
  assertReadAccess();
  assertConsistency();
  if (start == 0 && end == length()) return this;
  if (myOriginalSequence != null) {
    return myOriginalSequence.subSequence(start, end);
  }
  flushDeferredChanged();
  return new CharArrayCharSequence(myArray, start, end);
}
项目:tools-idea    文件:ShelveChangesManager.java   
public static List<TextFilePatch> loadPatches(Project project, final String patchPath, CommitContext commitContext) throws IOException, PatchSyntaxException {
  char[] text = FileUtil.loadFileText(new File(patchPath), CharsetToolkit.UTF8);
  PatchReader reader = new PatchReader(new CharArrayCharSequence(text));
  final List<TextFilePatch> textFilePatches = reader.readAllPatches();
  final TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo = reader.getAdditionalInfo(
    null);
  ApplyPatchDefaultExecutor.applyAdditionalInfoBefore(project, additionalInfo, commitContext);
  return textFilePatches;
}
项目:tools-idea    文件:CompactSyntaxLexerAdapter.java   
@Deprecated
public void start(char[] buffer, int startOffset, int endOffset, int initialState) {
  myBuffer = new CharArrayCharSequence(buffer, startOffset, endOffset);

  final CharArrayReader reader = new CharArrayReader(buffer, startOffset, endOffset - startOffset);
  init(startOffset, endOffset, reader, initialState);
}
项目:tools-idea    文件:GroovyEnterHandler.java   
private static void convertEndToMultiline(int caretOffset, Document document, String fileText, char c) {
  if (caretOffset < fileText.length() && fileText.charAt(caretOffset) == c ||
      caretOffset > 0 && fileText.charAt(caretOffset - 1) == c) {
    document.insertString(caretOffset, new CharArrayCharSequence(c, c));
  }
  else {
    document.insertString(caretOffset, new CharArrayCharSequence(c, c, c));
  }
}
项目:consulo    文件:ShelveChangesManager.java   
private static List<TextFilePatch> loadPatches(Project project, final String patchPath, CommitContext commitContext, boolean loadContent)
        throws IOException, PatchSyntaxException {
  char[] text = FileUtil.loadFileText(new File(patchPath), CharsetToolkit.UTF8);
  PatchReader reader = new PatchReader(new CharArrayCharSequence(text), loadContent);
  final List<TextFilePatch> textFilePatches = reader.readTextPatches();
  ApplyPatchDefaultExecutor.applyAdditionalInfoBefore(project, reader.getAdditionalInfo(null), commitContext);
  return textFilePatches;
}
项目:consulo-xml    文件:CompactSyntaxLexerAdapter.java   
@Deprecated
public void start(char[] buffer, int startOffset, int endOffset, int initialState)
{
    myBuffer = new CharArrayCharSequence(buffer, startOffset, endOffset);

    final CharArrayReader reader = new CharArrayReader(buffer, startOffset, endOffset - startOffset);
    init(startOffset, endOffset, reader, initialState);
}
项目:consulo-xml    文件:CompactSyntaxLexerAdapter.java   
@Override
public int read(char[] cbuf, int off, int len)
{
    if((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0))
    {
        throw new IndexOutOfBoundsException();
    }
    else if(len == 0)
    {
        return 0;
    }

    if(myText instanceof CharArrayCharSequence)
    { // Optimization
        final int readChars = ((CharArrayCharSequence) myText).readCharsTo(myCurPos, cbuf, off, len);
        if(readChars < 0)
        {
            return -1;
        }
        myCurPos += readChars;
        return readChars;
    }

    int charsToCopy = Math.min(len, myEndOffset - myCurPos);
    if(charsToCopy <= 0)
    {
        return -1;
    }

    for(int n = 0; n < charsToCopy; n++)
    {
        cbuf[n + off] = myText.charAt(n + myCurPos);
    }

    myCurPos += charsToCopy;
    return charsToCopy;
}
项目:intellij-ce-playground    文件:LineOutputWriter.java   
CharSequenceIterator(final char[] chars, final int offset, final int length) {
  this(new CharArrayCharSequence(chars, offset, offset+length));
}
项目:intellij-ce-playground    文件:MockEditorFactory.java   
@Override
@NotNull
public Document createDocument(@NotNull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:intellij-ce-playground    文件:EditorFactoryImpl.java   
@Override
@NotNull
public Document createDocument(@NotNull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:intellij-ce-playground    文件:ByteBufUtf8Writer.java   
@Override
public void write(char[] chars, int off, int len) {
  ByteBufUtilEx.writeUtf8(buffer, new CharArrayCharSequence(chars, off, off + len));
}
项目:intellij-ce-playground    文件:LineTokenizer.java   
@NotNull
public static String[] tokenize(@NotNull char[] chars, int startOffset, int endOffset, boolean includeSeparators,
                                boolean skipLastEmptyLine) {
  return tokenize(new CharArrayCharSequence(chars, startOffset, endOffset), includeSeparators, skipLastEmptyLine);
}
项目:intellij-ce-playground    文件:LineTokenizer.java   
public LineTokenizer(@NotNull char[] text, int startOffset, int endOffset) {
  this(new CharArrayCharSequence(text, startOffset, endOffset));
}
项目:form-follows-function    文件:F3Lexer.java   
public void start(char[] buffer, int startOffset, int endOffset, int initialState) {
    start(new CharArrayCharSequence(buffer), startOffset, endOffset, initialState);
}
项目:intellij-haskforce    文件:HaskellTypedHandler.java   
/**
 * this is almost complete c'n'p from TypedHandler,
 * This code should be generalized into BraceMatchingUtil to support custom matching braces for plugin developers
 *
 * @see com.intellij.codeInsight.editorActions.TypedHandler
 * @see BraceMatchingUtil
 */
private static void insertMatchedEndComment(Project project, Editor editor, PsiFile file, char c) {
    if (!(file instanceof HaskellFile)) return;

    PsiDocumentManager.getInstance(project).commitAllDocuments();

    FileType fileType = file.getFileType();
    int offset = editor.getCaretModel().getOffset();
    HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset);
    boolean atEndOfDocument = offset == editor.getDocument().getTextLength();

    if (!atEndOfDocument) iterator.retreat();
    if (iterator.atEnd()) return;
    BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator);
    if (iterator.atEnd()) return;
    IElementType braceTokenType = iterator.getTokenType();
    final CharSequence fileText = editor.getDocument().getCharsSequence();
    if (!braceMatcher.isLBraceToken(iterator, fileText, fileType)) return;

    if (!iterator.atEnd()) {
        iterator.advance();

        if (!iterator.atEnd()) {
            if (!BraceMatchingUtil.isPairedBracesAllowedBeforeTypeInFileType(braceTokenType, iterator.getTokenType(), fileType)) {
                return;
            }
            if (BraceMatchingUtil.isLBraceToken(iterator, fileText, fileType)) {
                return;
            }
        }

        iterator.retreat();
    }

    int lparenOffset = BraceMatchingUtil.findLeftmostLParen(iterator, braceTokenType, fileText, fileType);
    if (lparenOffset < 0) lparenOffset = 0;

    iterator = ((EditorEx) editor).getHighlighter().createIterator(lparenOffset);

    if (!BraceMatchingUtil.matchBrace(fileText, fileType, iterator, true, true)) {
        // Some other mechanism has put the closing '}' in the document already.
        editor.getDocument().insertString(offset, new CharArrayCharSequence(c));
    }
}
项目:tools-idea    文件:MockEditorFactory.java   
@Override
@NotNull
public Document createDocument(@NotNull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:tools-idea    文件:EditorFactoryImpl.java   
@Override
@NotNull
public Document createDocument(@NotNull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:tools-idea    文件:LineTokenizer.java   
public static String[] tokenize(char[] chars, int startOffset, int endOffset, boolean includeSeparators,
                                boolean skipLastEmptyLine) {
  return tokenize(new CharArrayCharSequence(chars, startOffset, endOffset), includeSeparators, skipLastEmptyLine);
}
项目:tools-idea    文件:LineTokenizer.java   
public LineTokenizer(char[] text, int startOffset, int endOffset) {
  this(new CharArrayCharSequence(text, startOffset, endOffset));
}
项目:consulo    文件:MockEditorFactory.java   
@Override
@Nonnull
public Document createDocument(@Nonnull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:consulo    文件:EditorFactoryImpl.java   
@Override
@Nonnull
public Document createDocument(@Nonnull char[] text) {
  return createDocument(new CharArrayCharSequence(text));
}
项目:consulo    文件:ByteBufUtf8Writer.java   
@Override
public void write(char[] chars, int off, int len) {
  NettyKt.writeUtf8(buffer, new CharArrayCharSequence(chars, off, off + len));
}
项目:consulo    文件:LineTokenizer.java   
@Nonnull
public static String[] tokenize(@Nonnull char[] chars, int startOffset, int endOffset, boolean includeSeparators,
                                boolean skipLastEmptyLine) {
  return tokenize(new CharArrayCharSequence(chars, startOffset, endOffset), includeSeparators, skipLastEmptyLine);
}
项目:consulo    文件:LineTokenizer.java   
public LineTokenizer(@Nonnull char[] text, int startOffset, int endOffset) {
  this(new CharArrayCharSequence(text, startOffset, endOffset));
}