Search in sources :

Example 1 with SubstitutedFileType

use of com.intellij.util.indexing.SubstitutedFileType in project intellij-community by JetBrains.

the class PlatformIdTableBuilding method getTodoIndexer.

@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, 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(), 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;
}
Also used : FileContent(com.intellij.util.indexing.FileContent) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) ParserDefinition(com.intellij.lang.ParserDefinition) SubstitutedFileType(com.intellij.util.indexing.SubstitutedFileType) Language(com.intellij.lang.Language) TokenSet(com.intellij.psi.tree.TokenSet) TodoIndexEntry(com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry) CustomSyntaxTableFileType(com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Language (com.intellij.lang.Language)1 ParserDefinition (com.intellij.lang.ParserDefinition)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 CustomSyntaxTableFileType (com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType)1 TodoIndexEntry (com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry)1 TokenSet (com.intellij.psi.tree.TokenSet)1 FileContent (com.intellij.util.indexing.FileContent)1 SubstitutedFileType (com.intellij.util.indexing.SubstitutedFileType)1 Nullable (org.jetbrains.annotations.Nullable)1