Java 类com.intellij.util.indexing.SubstitutedFileType 实例源码

项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);

  if (indexer != null) {
    return indexer;
  }

  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer =
      new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, virtualFile);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
  }

  return null;
}
项目:tools-idea    文件:PlatformIdTableBuilding.java   
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);

  if (indexer != null) {
    return indexer;
  }

  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer =
      new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, virtualFile);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
  }

  return null;
}
项目:consulo    文件:PlatformIdTableBuilding.java   
@javax.annotation.Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, Project project, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer = new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), project, virtualFile), getTodoIndexer(sft.getFileType(), project, virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    LanguageVersion languageVersion = LanguageVersionUtil.findLanguageVersion(lang, project, virtualFile);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens(languageVersion) : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, languageVersion, virtualFile, project);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, null, virtualFile, project);
  }

  return null;
}
项目:tools-idea    文件:StubTreeBuilder.java   
@Nullable
public static Stub buildStubTree(final FileContent inputData) {
  Stub data = inputData.getUserData(stubElementKey);
  if (data != null) return data;

  //noinspection SynchronizationOnLocalVariableOrMethodParameter
  synchronized (inputData) {
    data = inputData.getUserData(stubElementKey);
    if (data != null) return data;

    final FileType fileType = inputData.getFileType();

    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    if (builder != null) {
      data = builder.buildStubTree(inputData);
    }
    if (data == null && !fileType.isBinary()) {
      final LanguageFileType languageFileType = (LanguageFileType)fileType;
      Language l = languageFileType.getLanguage();
      final IFileElementType type = LanguageParserDefinitions.INSTANCE.forLanguage(l).getFileNodeType();

      PsiFile psi = inputData.getPsiFile();
      psi = psi.getViewProvider().getStubBindingRoot();
      CharSequence contentAsText = inputData.getContentAsText();
      psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, contentAsText);

      try {
        if (type instanceof IStubFileElementType) {
          data = ((IStubFileElementType)type).getBuilder().buildStubTree(psi);
        }
        else if (languageFileType instanceof SubstitutedFileType) {
          SubstitutedFileType substituted = (SubstitutedFileType) languageFileType;
          LanguageFileType original = (LanguageFileType)substituted.getOriginalFileType();
          final IFileElementType originalType = LanguageParserDefinitions.INSTANCE.forLanguage(original.getLanguage()).getFileNodeType();
          if (originalType instanceof IStubFileElementType) {
            data = ((IStubFileElementType)originalType).getBuilder().buildStubTree(psi);
          }
        }
      }
      finally {
        psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, null);
      }
    }

    inputData.putUserData(stubElementKey, data);
    return data;
  }
}