From 14e9b61662478d70e522d707d1f4fa2806937e0c Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Thu, 10 Oct 2013 20:22:58 +0400 Subject: [PATCH] GitRootDetector renamed to VcsRootDetector, git dependencies removed from RootDetector for further moving --- plugins/git4idea/src/git4idea/GitVcs.java | 4 +-- .../git4idea/roots/GitRootErrorsFinder.java | 2 +- .../src/git4idea/roots/GitRootFinder.java | 2 +- ...RootDetector.java => VcsRootDetector.java} | 26 +++++++++---------- .../git4idea/roots/GitRootDetectorTest.groovy | 4 +-- 5 files changed, 18 insertions(+), 20 deletions(-) rename plugins/git4idea/src/git4idea/roots/{GitRootDetector.java => VcsRootDetector.java} (81%) diff --git a/plugins/git4idea/src/git4idea/GitVcs.java b/plugins/git4idea/src/git4idea/GitVcs.java index 5a618f47b5c7..154fd62d19cd 100644 --- a/plugins/git4idea/src/git4idea/GitVcs.java +++ b/plugins/git4idea/src/git4idea/GitVcs.java @@ -79,7 +79,7 @@ import git4idea.rollback.GitRollbackEnvironment; import git4idea.roots.GitIntegrationEnabler; import git4idea.roots.GitRootChecker; import com.intellij.openapi.vcs.roots.VcsRootDetectInfo; -import git4idea.roots.GitRootDetector; +import git4idea.roots.VcsRootDetector; import git4idea.status.GitChangeProvider; import git4idea.ui.branch.GitBranchWidget; import git4idea.update.GitUpdateEnvironment; @@ -592,7 +592,7 @@ public class GitVcs extends AbstractVcs { public void enableIntegration() { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { - VcsRootDetectInfo detectInfo = new GitRootDetector(myProject, myPlatformFacade).detect(); + VcsRootDetectInfo detectInfo = new VcsRootDetector(myProject).detect(); new GitIntegrationEnabler(myProject, myGit, myPlatformFacade).enable(detectInfo); } }); diff --git a/plugins/git4idea/src/git4idea/roots/GitRootErrorsFinder.java b/plugins/git4idea/src/git4idea/roots/GitRootErrorsFinder.java index 6a1dc7fe9cc9..01c8b0e553c9 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootErrorsFinder.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootErrorsFinder.java @@ -53,7 +53,7 @@ public class GitRootErrorsFinder { @NotNull public Collection find() { List mappings = myVcsManager.getDirectoryMappings(myVcs); - Collection gitRoots = new GitRootDetector(myProject, myPlatformFacade).detect().getRoots(); + Collection gitRoots = new VcsRootDetector(myProject).detect().getRoots(); Collection errors = new ArrayList(); Collection gitPaths = rootsToPaths(gitRoots); diff --git a/plugins/git4idea/src/git4idea/roots/GitRootFinder.java b/plugins/git4idea/src/git4idea/roots/GitRootFinder.java index 196b2017ecf9..a67e63b769f5 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootFinder.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootFinder.java @@ -30,7 +30,7 @@ public class GitRootFinder implements VcsRootFinder { @NotNull @Override public Collection findRoots(@NotNull VirtualFile root) { - VcsRootDetectInfo info = new GitRootDetector(myProject, myPlatformFacade).detect(root); + VcsRootDetectInfo info = new VcsRootDetector(myProject).detect(root); Collection roots = info.getRoots(); if (roots.isEmpty()) { return Collections.emptyList(); diff --git a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java b/plugins/git4idea/src/git4idea/roots/VcsRootDetector.java similarity index 81% rename from plugins/git4idea/src/git4idea/roots/GitRootDetector.java rename to plugins/git4idea/src/git4idea/roots/VcsRootDetector.java index 8213df4f06cf..ea4e4711b7e8 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java +++ b/plugins/git4idea/src/git4idea/roots/VcsRootDetector.java @@ -16,10 +16,9 @@ package git4idea.roots; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.vcs.roots.VcsRootDetectInfo; import com.intellij.openapi.vfs.VirtualFile; -import git4idea.GitPlatformFacade; -import git4idea.GitUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,33 +28,33 @@ import java.util.Set; /** *

- * Scans the file system looking for Git roots, which contain the Project or its parts, - * and returns the information enclosed to the {@link com.intellij.openapi.vcs.roots.VcsRootDetectInfo}. - * The main part of the information are Git roots which will be proposed to the user to be added as VCS roots. + * Scans the file system looking for Git roots, which contain the Project or its parts, + * and returns the information enclosed to the {@link com.intellij.openapi.vcs.roots.VcsRootDetectInfo}. + * The main part of the information are Git roots which will be proposed to the user to be added as VCS roots. *

*

- * Linked sources are not scanned. User should add Git roots for them explicitly. + * Linked sources are not scanned. User should add Git roots for them explicitly. *

* * @author Kirill Likhodedov */ -public class GitRootDetector { +public class VcsRootDetector { private static final int MAXIMUM_SCAN_DEPTH = 2; @NotNull private final Project myProject; - @NotNull private final GitPlatformFacade myPlatformFacade; + @NotNull private final ProjectRootManager myProjectManager; - public GitRootDetector(@NotNull Project project, @NotNull GitPlatformFacade platformFacade) { + public VcsRootDetector(@NotNull Project project) { myProject = project; - myPlatformFacade = platformFacade; + myProjectManager = ProjectRootManager.getInstance(project); } @NotNull public VcsRootDetectInfo detect() { return detect(myProject.getBaseDir()); } - + @NotNull public VcsRootDetectInfo detect(@Nullable VirtualFile startDir) { if (startDir == null) { @@ -79,7 +78,7 @@ public class GitRootDetector { private Set scanForRootsInContentRoots() { Set gitRoots = new HashSet(); - VirtualFile[] roots = myPlatformFacade.getProjectRootManager(myProject).getContentRoots(); + VirtualFile[] roots = myProjectManager.getContentRoots(); for (VirtualFile contentRoot : roots) { Set rootsInsideRoot = scanForRootsInsideDir(contentRoot); if (!rootsInsideRoot.contains(contentRoot)) { @@ -135,8 +134,7 @@ public class GitRootDetector { } private static boolean hasGitDir(@NotNull VirtualFile dir) { - VirtualFile gitDir = dir.findChild(GitUtil.DOT_GIT); + VirtualFile gitDir = dir.findChild(".git"); return gitDir != null && gitDir.exists(); } - } diff --git a/plugins/git4idea/tests/git4idea/roots/GitRootDetectorTest.groovy b/plugins/git4idea/tests/git4idea/roots/GitRootDetectorTest.groovy index 34bafa92680a..d91655378052 100644 --- a/plugins/git4idea/tests/git4idea/roots/GitRootDetectorTest.groovy +++ b/plugins/git4idea/tests/git4idea/roots/GitRootDetectorTest.groovy @@ -165,7 +165,7 @@ class GitRootDetectorTest extends AbstractGitRootTest { /** * Perform test. Map contains actual Git repositories to be created on disk, - * and Git repositories expected to be detected by the GitRootDetector. + * and Git repositories expected to be detected by the VcsRootDetector. * @param map */ private void doTest(Map map) { @@ -215,7 +215,7 @@ class GitRootDetectorTest extends AbstractGitRootTest { } private VcsRootDetectInfo detect() { - new GitRootDetector(myProject, myPlatformFacade).detect() + new VcsRootDetector(myProject).detect() } } \ No newline at end of file