@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); } }
@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; }
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; }
@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); }
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)); }
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; }
@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); }
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)); } }
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()); }
@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); }
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; }
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; }
@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; }
CharSequenceIterator(final char[] chars, final int offset, final int length) { this(new CharArrayCharSequence(chars, offset, offset+length)); }
@Override @NotNull public Document createDocument(@NotNull char[] text) { return createDocument(new CharArrayCharSequence(text)); }
@Override public void write(char[] chars, int off, int len) { ByteBufUtilEx.writeUtf8(buffer, new CharArrayCharSequence(chars, off, off + len)); }
@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); }
public LineTokenizer(@NotNull char[] text, int startOffset, int endOffset) { this(new CharArrayCharSequence(text, startOffset, endOffset)); }
public void start(char[] buffer, int startOffset, int endOffset, int initialState) { start(new CharArrayCharSequence(buffer), startOffset, endOffset, initialState); }
/** * 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)); } }
public static String[] tokenize(char[] chars, int startOffset, int endOffset, boolean includeSeparators, boolean skipLastEmptyLine) { return tokenize(new CharArrayCharSequence(chars, startOffset, endOffset), includeSeparators, skipLastEmptyLine); }
public LineTokenizer(char[] text, int startOffset, int endOffset) { this(new CharArrayCharSequence(text, startOffset, endOffset)); }
@Override @Nonnull public Document createDocument(@Nonnull char[] text) { return createDocument(new CharArrayCharSequence(text)); }
@Override public void write(char[] chars, int off, int len) { NettyKt.writeUtf8(buffer, new CharArrayCharSequence(chars, off, off + len)); }
@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); }
public LineTokenizer(@Nonnull char[] text, int startOffset, int endOffset) { this(new CharArrayCharSequence(text, startOffset, endOffset)); }