mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
GitRootDetector renamed to VcsRootDetector, git dependencies removed from RootDetector for further moving
This commit is contained in:
@@ -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<CommittedChangeList> {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ public class GitRootErrorsFinder {
|
||||
@NotNull
|
||||
public Collection<VcsRootError> find() {
|
||||
List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings(myVcs);
|
||||
Collection<VirtualFile> gitRoots = new GitRootDetector(myProject, myPlatformFacade).detect().getRoots();
|
||||
Collection<VirtualFile> gitRoots = new VcsRootDetector(myProject).detect().getRoots();
|
||||
|
||||
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
|
||||
Collection<String> gitPaths = rootsToPaths(gitRoots);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GitRootFinder implements VcsRootFinder {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VcsDirectoryMapping> findRoots(@NotNull VirtualFile root) {
|
||||
VcsRootDetectInfo info = new GitRootDetector(myProject, myPlatformFacade).detect(root);
|
||||
VcsRootDetectInfo info = new VcsRootDetector(myProject).detect(root);
|
||||
Collection<VirtualFile> roots = info.getRoots();
|
||||
if (roots.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
|
||||
+12
-14
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* @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<VirtualFile> scanForRootsInContentRoots() {
|
||||
Set<VirtualFile> gitRoots = new HashSet<VirtualFile>();
|
||||
VirtualFile[] roots = myPlatformFacade.getProjectRootManager(myProject).getContentRoots();
|
||||
VirtualFile[] roots = myProjectManager.getContentRoots();
|
||||
for (VirtualFile contentRoot : roots) {
|
||||
Set<VirtualFile> 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user