Search in sources :

Example 26 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project idea-php-typo3-plugin by cedricziel.

the class CoreServiceParser method collectServices.

private void collectServices(Project project) {
    FileBasedIndex index = FileBasedIndex.getInstance();
    Collection<VirtualFile> containingFiles = index.getContainingFiles(FileTypeIndex.NAME, PhpFileType.INSTANCE, GlobalSearchScope.allScope(project));
    containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));
    for (VirtualFile projectFile : containingFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
        if (psiFile != null) {
            psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CoreServiceDefinitionParserVisitor(com.cedricziel.idea.typo3.psi.visitor.CoreServiceDefinitionParserVisitor) PsiFile(com.intellij.psi.PsiFile) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Example 27 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project Perl5-IDEA by Camelcade.

the class Mason2Util method reindexProjectRoots.

public static void reindexProjectRoots(Project project, List<String> rootsToReindex) {
    if (rootsToReindex.isEmpty()) {
        return;
    }
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    VirtualFile projectRoot = project.getBaseDir();
    if (projectRoot != null) {
        final FileBasedIndex index = FileBasedIndex.getInstance();
        for (String root : rootsToReindex) {
            VirtualFile componentRoot = VfsUtil.findRelativeFile(root, projectRoot);
            if (componentRoot != null) {
                for (VirtualFile file : VfsUtil.collectChildrenRecursively(componentRoot)) {
                    if (file.getFileType() instanceof MasonPurePerlComponentFileType) {
                        index.requestReindex(file);
                    }
                }
            }
        }
        if (index instanceof FileBasedIndexImpl) {
            DumbModeTask changedFilesIndexingTask = FileBasedIndexProjectHandler.createChangedFilesIndexingTask(project);
            if (changedFilesIndexingTask != null) {
                DumbServiceImpl.getInstance(project).queueTask(changedFilesIndexingTask);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MasonPurePerlComponentFileType(com.perl5.lang.mason2.filetypes.MasonPurePerlComponentFileType) DumbModeTask(com.intellij.openapi.project.DumbModeTask) FileBasedIndexImpl(com.intellij.util.indexing.FileBasedIndexImpl) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Aggregations

FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)27 VirtualFile (com.intellij.openapi.vfs.VirtualFile)18 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)13 NotNull (org.jetbrains.annotations.NotNull)10 PsiFile (com.intellij.psi.PsiFile)6 Project (com.intellij.openapi.project.Project)5 PsiElement (com.intellij.psi.PsiElement)4 JSElement (com.intellij.lang.javascript.psi.JSElement)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 DetectedFrameworkDescription (com.intellij.framework.detection.DetectedFrameworkDescription)2 DetectionExcludesConfiguration (com.intellij.framework.detection.DetectionExcludesConfiguration)2 JSOffsetBasedImplicitElement (com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement)2 JSImplicitElementImpl (com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)2 Module (com.intellij.openapi.module.Module)2 PsiManager (com.intellij.psi.PsiManager)2 XmlFile (com.intellij.psi.xml.XmlFile)2 HashMap (com.intellij.util.containers.HashMap)2 HashSet (com.intellij.util.containers.HashSet)2