diff options
Diffstat (limited to 'platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java')
-rw-r--r-- | platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java index 122988896cb2..cfddcaa3e65d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java @@ -36,14 +36,17 @@ public class VcsRootIterator { // folder path to files to be excluded private final Map<String, MyRootFilter> myOtherVcsFolders; private final FileIndexFacade myExcludedFileIndex; + private final ProjectLevelVcsManager myVcsManager; + private final Project myProject; public VcsRootIterator(final Project project, final AbstractVcs vcs) { - final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project); + myProject = project; + myVcsManager = ProjectLevelVcsManager.getInstance(project); myOtherVcsFolders = new HashMap<String, MyRootFilter>(); myExcludedFileIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class); - final VcsRoot[] allRoots = plVcsManager.getAllVcsRoots(); - final VirtualFile[] roots = plVcsManager.getRootsUnderVcs(vcs); + final VcsRoot[] allRoots = myVcsManager.getAllVcsRoots(); + final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(vcs); for (VirtualFile root : roots) { final MyRootFilter rootPresentFilter = new MyRootFilter(root, vcs.getName()); rootPresentFilter.init(allRoots); @@ -57,14 +60,14 @@ public class VcsRootIterator { if ((rootFilter != null) && (!rootFilter.accept(file))) { return false; } - return !isExcluded(myExcludedFileIndex, file); + return !isIgnoredByVcs(myVcsManager, myProject, file); } - private static boolean isExcluded(final FileIndexFacade indexFacade, final VirtualFile file) { + private static boolean isIgnoredByVcs(final ProjectLevelVcsManager vcsManager, final Project project, final VirtualFile file) { return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() { @Override public Boolean compute() { - return indexFacade.isExcludedFile(file); + return !project.isDisposed() && vcsManager.isIgnored(file); } }); } @@ -140,7 +143,7 @@ public class VcsRootIterator { @Nullable private final VirtualFileFilter myDirectoryFilter; private final VirtualFile myRoot; private final MyRootFilter myRootPresentFilter; - private final FileIndexFacade myExcludedFileIndex; + private final ProjectLevelVcsManager myVcsManager; private MyRootIterator(final Project project, final VirtualFile root, @@ -153,13 +156,12 @@ public class VcsRootIterator { myDirectoryFilter = directoryFilter; myRoot = root; - final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project); - final AbstractVcs vcs = plVcsManager.getVcsFor(root); - myRootPresentFilter = (vcs == null) ? null : new MyRootFilter(root, vcs.getName()); + myVcsManager = ProjectLevelVcsManager.getInstance(project); + final AbstractVcs vcs = myVcsManager.getVcsFor(root); + myRootPresentFilter = vcs == null ? null : new MyRootFilter(root, vcs.getName()); if (myRootPresentFilter != null) { - myRootPresentFilter.init(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots()); + myRootPresentFilter.init(myVcsManager.getAllVcsRoots()); } - myExcludedFileIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class); } public void iterate() { @@ -174,7 +176,7 @@ public class VcsRootIterator { @NotNull @Override public Result visitFileEx(@NotNull VirtualFile file) { - if (isExcluded(myExcludedFileIndex, file)) return SKIP_CHILDREN; + if (isIgnoredByVcs(myVcsManager, myProject, file)) return SKIP_CHILDREN; if (myRootPresentFilter != null && !myRootPresentFilter.accept(file)) return SKIP_CHILDREN; if (myProject.isDisposed() || !process(file)) return skipTo(myRoot); if (myDirectoryFilter != null && file.isDirectory() && !myDirectoryFilter.shouldGoIntoDirectory(file)) return SKIP_CHILDREN; |