Search in sources :

Example 6 with FileContent

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

the class CoreStubTreeLoader method readOrBuild.

@Override
public ObjectStubTree readOrBuild(Project project, VirtualFile vFile, @Nullable PsiFile psiFile) {
    if (!canHaveStub(vFile)) {
        return null;
    }
    try {
        final FileContent fc = new FileContentImpl(vFile, vFile.contentsToByteArray());
        fc.putUserData(IndexingDataKeys.PROJECT, project);
        final Stub element = StubTreeBuilder.buildStubTree(fc);
        if (element instanceof PsiFileStub) {
            return new StubTree((PsiFileStub) element);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return null;
}
Also used : FileContent(com.intellij.util.indexing.FileContent) FileContentImpl(com.intellij.util.indexing.FileContentImpl) IOException(java.io.IOException)

Aggregations

FileContent (com.intellij.util.indexing.FileContent)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Test (org.junit.Test)3 Module (com.intellij.openapi.module.Module)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 FileContentImpl (com.intellij.util.indexing.FileContentImpl)2 IOException (java.io.IOException)2 Language (com.intellij.lang.Language)1 ParserDefinition (com.intellij.lang.ParserDefinition)1 FileType (com.intellij.openapi.fileTypes.FileType)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 CustomSyntaxTableFileType (com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VirtualFileVisitor (com.intellij.openapi.vfs.VirtualFileVisitor)1 TodoIndexEntry (com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry)1 TokenSet (com.intellij.psi.tree.TokenSet)1 SubstitutedFileType (com.intellij.util.indexing.SubstitutedFileType)1 Nullable (org.jetbrains.annotations.Nullable)1