Search in sources :

Example 11 with IStubFileElementType

use of com.intellij.psi.tree.IStubFileElementType in project intellij-community by JetBrains.

the class StubUpdatingIndex method canHaveStub.

public static boolean canHaveStub(@NotNull VirtualFile file) {
    final FileType fileType = file.getFileType();
    if (fileType instanceof LanguageFileType) {
        final Language l = ((LanguageFileType) fileType).getLanguage();
        final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
        if (parserDefinition == null) {
            return false;
        }
        final IFileElementType elementType = parserDefinition.getFileNodeType();
        if (elementType instanceof IStubFileElementType) {
            if (((IStubFileElementType) elementType).shouldBuildStubFor(file)) {
                return true;
            }
            FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
            if (file instanceof NewVirtualFile && fileBasedIndex instanceof FileBasedIndexImpl && ((FileBasedIndexImpl) fileBasedIndex).getIndex(INDEX_ID).isIndexedStateForFile(((NewVirtualFile) file).getId(), file)) {
                return true;
            }
        }
    }
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    return builder != null && builder.acceptsFile(file);
}
Also used : IFileElementType(com.intellij.psi.tree.IFileElementType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) ParserDefinition(com.intellij.lang.ParserDefinition) IStubFileElementType(com.intellij.psi.tree.IStubFileElementType) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile)

Example 12 with IStubFileElementType

use of com.intellij.psi.tree.IStubFileElementType in project intellij-community by JetBrains.

the class StubVersionMap method getVersionOwner.

private static Object getVersionOwner(FileType fileType) {
    Object owner = null;
    if (fileType instanceof LanguageFileType) {
        Language l = ((LanguageFileType) fileType).getLanguage();
        ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
        if (parserDefinition != null) {
            final IFileElementType type = parserDefinition.getFileNodeType();
            if (type instanceof IStubFileElementType) {
                owner = type;
            }
        }
    }
    BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    if (builder != null) {
        owner = builder;
    }
    return owner;
}
Also used : IFileElementType(com.intellij.psi.tree.IFileElementType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) ParserDefinition(com.intellij.lang.ParserDefinition) IStubFileElementType(com.intellij.psi.tree.IStubFileElementType) Language(com.intellij.lang.Language)

Aggregations

IStubFileElementType (com.intellij.psi.tree.IStubFileElementType)12 PsiFileImpl (com.intellij.psi.impl.source.PsiFileImpl)5 Language (com.intellij.lang.Language)4 PsiFile (com.intellij.psi.PsiFile)4 IElementType (com.intellij.psi.tree.IElementType)4 ASTNode (com.intellij.lang.ASTNode)3 ParserDefinition (com.intellij.lang.ParserDefinition)3 FileType (com.intellij.openapi.fileTypes.FileType)3 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)3 StubBuilder (com.intellij.psi.StubBuilder)3 IStubElementType (com.intellij.psi.stubs.IStubElementType)3 IFileElementType (com.intellij.psi.tree.IFileElementType)3 Pair (com.intellij.openapi.util.Pair)2 FileViewProvider (com.intellij.psi.FileViewProvider)2 PsiFileWithStubSupport (com.intellij.psi.impl.source.PsiFileWithStubSupport)2 StubElement (com.intellij.psi.stubs.StubElement)2 SmartList (com.intellij.util.SmartList)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 StubBasedPsiElementBase (com.intellij.extapi.psi.StubBasedPsiElementBase)1