diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java index b687ce31ac40..d58c89fcedcc 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java @@ -53,7 +53,7 @@ public class ChangesBrowserModuleNode extends ChangesBrowserNode { @Override public int getSortWeight() { - return DIRECTORY_PATH_SORT_WEIGHT; + return MODULE_SORT_WEIGHT; } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java index 9a41deb0e5da..3495617a6b35 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java @@ -47,8 +47,9 @@ public class ChangesBrowserNode extends DefaultMutableTreeNode implements Use protected static final int DEFAULT_CHANGE_LIST_SORT_WEIGHT = 1; protected static final int CHANGE_LIST_SORT_WEIGHT = 2; protected static final int REPOSITORY_SORT_WEIGHT = 3; - protected static final int DIRECTORY_PATH_SORT_WEIGHT = 4; - protected static final int FILE_PATH_SORT_WEIGHT = 5; + protected static final int MODULE_SORT_WEIGHT = 4; + protected static final int DIRECTORY_PATH_SORT_WEIGHT = 5; + protected static final int FILE_PATH_SORT_WEIGHT = 6; protected static final int CHANGE_SORT_WEIGHT = 7; protected static final int VIRTUAL_FILE_SORT_WEIGHT = 8; protected static final int UNVERSIONED_SORT_WEIGHT = 9; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt index e476ab35636b..900217e89534 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt @@ -2,72 +2,12 @@ package com.intellij.openapi.vcs.changes.ui -import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.ProjectFileIndex -import com.intellij.openapi.util.NotNullLazyKey -import com.intellij.openapi.util.registry.Registry -import com.intellij.openapi.vcs.changes.ui.DirectoryChangesGroupingPolicy.Companion.DIRECTORY_POLICY -import com.intellij.openapi.vcs.changes.ui.DirectoryChangesGroupingPolicy.Companion.GRAND_PARENT_CANDIDATE -import com.intellij.openapi.vcs.changes.ui.DirectoryChangesGroupingPolicy.Companion.HIERARCHY_UPPER_BOUND -import com.intellij.openapi.vcs.changes.ui.DirectoryChangesGroupingPolicy.Companion.getCachingRoot -import com.intellij.openapi.vcs.changes.ui.TreeModelBuilder.DIRECTORY_CACHE -import com.intellij.openapi.vfs.VirtualFile import javax.swing.tree.DefaultTreeModel -private const val PROJECT_ROOT_TAG = "" - +@Deprecated("Use ChangesGroupingPolicyFactory instead") open class ChangesModuleGroupingPolicy(val myProject: Project, val myModel: DefaultTreeModel) : ChangesGroupingPolicy { - private val myIndex = ProjectFileIndex.getInstance(myProject) - override fun getParentNodeFor(nodePath: StaticFilePath, subtreeRoot: ChangesBrowserNode<*>): ChangesBrowserNode<*>? { - if (myProject.isDefault) return null - - val vFile = nodePath.resolve() ?: return null - val contentRoot = myIndex.getContentRootForFile(vFile, HIDE_EXCLUDED_FILES) - - if (vFile == contentRoot) { - val module = myIndex.getModuleForFile(vFile, HIDE_EXCLUDED_FILES) - return getNodeForModule(module, vFile, nodePath, subtreeRoot) - } return null } - - private fun getNodeForModule(module: Module?, - vFile: VirtualFile, - nodePath: StaticFilePath, - subtreeRoot: ChangesBrowserNode<*>): ChangesBrowserNode<*> { - val cachingRoot = getCachingRoot(subtreeRoot) - - MODULE_CACHE.getValue(cachingRoot)[module]?.let { return it } - - val policy = DIRECTORY_POLICY.get(subtreeRoot) - val parent = GRAND_PARENT_CANDIDATE.get(subtreeRoot) - ?: if (policy != null && !isTopLevel(vFile)) - policy.getParentNodeInternal(nodePath, subtreeRoot) - else - HIERARCHY_UPPER_BOUND.getRequired(subtreeRoot) - val node = if (module == null) ChangesBrowserNode.createObject(PROJECT_ROOT_TAG) else ChangesBrowserModuleNode(module) - - myModel.insertNodeInto(node, parent, parent.childCount) - MODULE_CACHE.getValue(cachingRoot)[module] = node - DIRECTORY_CACHE.getValue(cachingRoot)[nodePath.key] = node - - return node - } - - private fun isTopLevel(vFile: VirtualFile): Boolean { - val parentFile = vFile.parent ?: return true - return myIndex.getContentRootForFile(parentFile, HIDE_EXCLUDED_FILES) == null - } - - class Factory(val project: Project) : ChangesGroupingPolicyFactory() { - override fun createGroupingPolicy(model: DefaultTreeModel): ChangesGroupingPolicy = ChangesModuleGroupingPolicy(project, model) - } - - companion object { - val MODULE_CACHE: NotNullLazyKey>, ChangesBrowserNode<*>> = NotNullLazyKey.create>, ChangesBrowserNode<*>>( - "ChangesTree.ModuleCache") { mutableMapOf() } - val HIDE_EXCLUDED_FILES: Boolean = Registry.`is`("ide.hide.excluded.files") - } } \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/DirectoryChangesGroupingPolicy.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/DirectoryChangesGroupingPolicy.kt index a68ffc2390c2..842d58f25900 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/DirectoryChangesGroupingPolicy.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/DirectoryChangesGroupingPolicy.kt @@ -8,7 +8,7 @@ import com.intellij.openapi.vcs.changes.ui.TreeModelBuilder.PATH_NODE_BUILDER import javax.swing.tree.DefaultTreeModel class DirectoryChangesGroupingPolicy(val project: Project, val model: DefaultTreeModel) : BaseChangesGroupingPolicy() { - private val innerPolicy = ChangesGroupingPolicyFactory.getInstance(project)?.createGroupingPolicy(model) + private val innerPolicy: ChangesGroupingPolicy? = ChangesGroupingPolicyFactory.getInstance(project)?.createGroupingPolicy(model) override fun getParentNodeFor(nodePath: StaticFilePath, subtreeRoot: ChangesBrowserNode<*>): ChangesBrowserNode<*> { DIRECTORY_POLICY.set(subtreeRoot, this) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ModuleChangesGroupingPolicy.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ModuleChangesGroupingPolicy.kt index d39147b25483..119f33a34728 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ModuleChangesGroupingPolicy.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ModuleChangesGroupingPolicy.kt @@ -1,10 +1,11 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.ui +import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectFileIndex -import com.intellij.openapi.vcs.changes.ui.ChangesModuleGroupingPolicy.Companion.HIDE_EXCLUDED_FILES -import com.intellij.openapi.vcs.changes.ui.ChangesModuleGroupingPolicy.Companion.MODULE_CACHE +import com.intellij.openapi.util.NotNullLazyKey +import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vcs.changes.ui.TreeModelBuilder.* import javax.swing.tree.DefaultTreeModel @@ -41,4 +42,10 @@ class ModuleChangesGroupingPolicy(val project: Project, val model: DefaultTreeMo class Factory(val project: Project) : ChangesGroupingPolicyFactory() { override fun createGroupingPolicy(model: DefaultTreeModel): ModuleChangesGroupingPolicy = ModuleChangesGroupingPolicy(project, model) } + + companion object { + private val MODULE_CACHE: NotNullLazyKey>, ChangesBrowserNode<*>> = + NotNullLazyKey.create("ChangesTree.ModuleCache") { mutableMapOf() } + private val HIDE_EXCLUDED_FILES: Boolean = Registry.`is`("ide.hide.excluded.files") + } } \ No newline at end of file diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 55ef8f3fbd37..03e3e1a5829b 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -183,8 +183,6 @@ -