Java 类com.intellij.psi.tree.ILightStubFileElementType 实例源码

项目:intellij-ce-playground    文件:LightStubBuilder.java   
@Override
public StubElement buildStubTree(@NotNull PsiFile file) {
  LighterAST tree = FORCED_AST.get();
  if (tree == null) {
    FileType fileType = file.getFileType();
    if (!(fileType instanceof LanguageFileType)) {
      LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
      return null;
    }
    Language language = ((LanguageFileType)fileType).getLanguage();
    final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
    if (!(contentType instanceof IStubFileElementType)) {
      LOG.error("File is not of IStubFileElementType: " + contentType + ", " + file);
      return null;
    }

    final FileASTNode node = file.getNode();
    if (contentType instanceof ILightStubFileElementType) {
      tree = node.getLighterAST();
    }
    else {
      tree = new TreeBackedLighterAST(node);
    }
  } else {
    FORCED_AST.set(null);
  }
  if (tree == null) return null;

  final StubElement rootStub = createStubForFile(file, tree);
  buildStubTree(tree, tree.getRoot(), rootStub);
  return rootStub;
}
项目:consulo    文件:LightStubBuilder.java   
@RequiredReadAction
@Override
public StubElement buildStubTree(@Nonnull PsiFile file) {
  LighterAST tree = FORCED_AST.get();
  if (tree == null) {
    FileType fileType = file.getFileType();
    if (!(fileType instanceof LanguageFileType)) {
      LOG.error("File is not of LanguageFileType: " + file + ", " + fileType);
      return null;
    }
    if (!(file instanceof PsiFileImpl)) {
      LOG.error("Unexpected PsiFile instance: " + file + ", " + file.getClass());
      return null;
    }
    if (((PsiFileImpl)file).getElementTypeForStubBuilder() == null) {
      LOG.error("File is not of IStubFileElementType: " + file);
      return null;
    }

    FileASTNode node = file.getNode();
    tree = node.getElementType() instanceof ILightStubFileElementType ? node.getLighterAST() : new TreeBackedLighterAST(node);
  }
  else {
    FORCED_AST.set(null);
  }

  StubElement rootStub = createStubForFile(file, tree);
  buildStubTree(tree, tree.getRoot(), rootStub);
  return rootStub;
}
项目:consulo    文件:FileElement.java   
@Nonnull
@Override
public LighterAST getLighterAST() {
  IElementType contentType = getElementType();
  if (!isParsed() && contentType instanceof ILightStubFileElementType) {
    return new FCTSBackedLighterAST(getCharTable(), ((ILightStubFileElementType<?>)contentType).parseContentsLight(this));
  }
  return new TreeBackedLighterAST(this);
}