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

项目:intellij-snakeyaml    文件:YamlLexer.java   
@Override
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
    myText = buffer;
    myEnd = endOffset;

    myScanner = new ErrorSkippingScanner(new CharSequenceReader(buffer.subSequence(0, endOffset)));

    myToken = myScanner.peekToken();
    myState = initialState;

    if (startOffset > 0) {
        // Here comes ugly. Emulate incremental lexer by re-lexing from start
        while (myScanner.peekToken().getStartMark().getIndex() < startOffset) {
            advance();
        }
    }
}
项目:intellij-ce-playground    文件:PythonFileType.java   
@Nullable
private static String getCharsetFromEncodingDeclaration(@Nullable CharSequence content) {
  if (content == null || content.length() == 0) {
    return null;
  }
  try {
    final BufferedReader reader = new BufferedReader(new CharSequenceReader(content));
    try {
      for (int i = 0; i < MAX_CHARSET_ENCODING_LINE; i++) {
        final String line = reader.readLine();
        if (line == null) {
          return null;
        }
        final Matcher matcher = ENCODING_PATTERN.matcher(line);
        if (matcher.find()) {
          final String charset = matcher.group(1);
          return normalizeCharset(charset);
        }
      }
    } finally {
      reader.close();
    }
  }
  catch (IOException ignored) {
  }
  return null;
}
项目:tools-idea    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:consulo-xml    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:intellij-snakeyaml    文件:ScannerAndBuilderSynchronizer.java   
public ScannerAndBuilderSynchronizer(PsiBuilder builder) {
    super(new CharSequenceReader(builder.getOriginalText()));
    this.builder = builder;
}
项目:intellij-ce-playground    文件:JDOMUtil.java   
@NotNull
public static Document loadDocument(@NotNull CharSequence seq) throws IOException, JDOMException {
  return loadDocument(new CharSequenceReader(seq));
}
项目:intellij-ce-playground    文件:NanoXmlUtil.java   
private static MyXMLReader createReader(PsiFile psiFile) {
  return new MyXMLReader(new CharSequenceReader(psiFile.getViewProvider().getContents()));
}
项目:tools-idea    文件:JDOMUtil.java   
@NotNull
public static Document loadDocument(@NotNull CharSequence seq) throws IOException, JDOMException {
  return getSaxBuilder().build(new CharSequenceReader(seq));
}
项目:consulo    文件:JDOMUtil.java   
@Nonnull
public static Document loadDocument(@Nonnull CharSequence seq) throws IOException, JDOMException {
  return loadDocument(new CharSequenceReader(seq));
}