Search in sources :

Example 16 with FileIndexFacade

use of com.intellij.openapi.roots.FileIndexFacade in project intellij-community by JetBrains.

the class MappingsToRoots method getDetailedVcsMappings.

// not only set mappings, but include all modules inside: modules might have different settings
public List<VirtualFile> getDetailedVcsMappings(final AbstractVcs vcs) {
    // same as above, but no compression
    final List<VirtualFile> result = myMappings.getMappingsAsFilesUnderVcs(vcs);
    boolean addInnerModules = true;
    final String vcsName = vcs.getName();
    final List<VcsDirectoryMapping> directoryMappings = myMappings.getDirectoryMappings(vcsName);
    for (VcsDirectoryMapping directoryMapping : directoryMappings) {
        if (directoryMapping.isDefaultMapping()) {
            addInnerModules = false;
            break;
        }
    }
    Collections.sort(result, FilePathComparator.getInstance());
    if (addInnerModules) {
        final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class);
        final Collection<VirtualFile> modules = DefaultVcsRootPolicy.getInstance(myProject).getDefaultVcsRoots(myMappings, vcsName);
        ApplicationManager.getApplication().runReadAction(() -> {
            Iterator<VirtualFile> iterator = modules.iterator();
            while (iterator.hasNext()) {
                final VirtualFile module = iterator.next();
                boolean included = false;
                for (VirtualFile root : result) {
                    if (facade.isValidAncestor(root, module)) {
                        included = true;
                        break;
                    }
                }
                if (!included) {
                    iterator.remove();
                }
            }
        });
        result.addAll(modules);
    }
    result.removeIf(file -> !file.isDirectory());
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) FileIndexFacade(com.intellij.openapi.roots.FileIndexFacade)

Example 17 with FileIndexFacade

use of com.intellij.openapi.roots.FileIndexFacade in project google-cloud-intellij by GoogleCloudPlatform.

the class SetupCloudRepositoryAction method filterOutIgnored.

@NotNull
private static Collection<VirtualFile> filterOutIgnored(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    final FileIndexFacade fileIndex = FileIndexFacade.getInstance(project);
    return Collections2.filter(files, file -> !changeListManager.isIgnoredFile(file) && !fileIndex.isExcludedFile(file));
}
Also used : ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) FileIndexFacade(com.intellij.openapi.roots.FileIndexFacade) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileIndexFacade (com.intellij.openapi.roots.FileIndexFacade)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 NotNull (org.jetbrains.annotations.NotNull)5 Nullable (org.jetbrains.annotations.Nullable)5 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 PsiElement (com.intellij.psi.PsiElement)2 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)2 ItemPresentation (com.intellij.navigation.ItemPresentation)1 Attachment (com.intellij.openapi.diagnostic.Attachment)1 Document (com.intellij.openapi.editor.Document)1 FileType (com.intellij.openapi.fileTypes.FileType)1 Module (com.intellij.openapi.module.Module)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 Project (com.intellij.openapi.project.Project)1 Computable (com.intellij.openapi.util.Computable)1 Ref (com.intellij.openapi.util.Ref)1 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)1 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)1