mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: try parent if content root is a file, add logging
This commit is contained in:
+11
-2
@@ -116,18 +116,27 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
|
||||
public VirtualFile getVcsRootFor(@NotNull VirtualFile file) {
|
||||
FileIndexFacade indexFacade = PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class);
|
||||
if (myBaseDir != null && indexFacade.isValidAncestor(myBaseDir, file)) {
|
||||
LOG.debug("File " + file + " is under project base dir " + myBaseDir);
|
||||
return myBaseDir;
|
||||
}
|
||||
VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file, Registry.is("ide.hide.excluded.files"));
|
||||
if (contentRoot != null && contentRoot.isDirectory()) {
|
||||
return contentRoot;
|
||||
if (contentRoot != null) {
|
||||
LOG.debug("Content root for file " + file + " is " + contentRoot);
|
||||
if (contentRoot.isDirectory()) {
|
||||
return contentRoot;
|
||||
}
|
||||
VirtualFile parent = contentRoot.getParent();
|
||||
LOG.debug("Content root is not a directory, using its parent " + parent);
|
||||
return parent;
|
||||
}
|
||||
if (ProjectKt.isDirectoryBased(myProject)) {
|
||||
VirtualFile ideaDir = ProjectKt.getStateStore(myProject).getDirectoryStoreFile();
|
||||
if (ideaDir != null && VfsUtilCore.isAncestor(ideaDir, file, false)) {
|
||||
LOG.debug("File " + file + " is under .idea");
|
||||
return ideaDir;
|
||||
}
|
||||
}
|
||||
LOG.debug("Couldn't find proper root for " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user