IDEA-349813 vcs: enable 'Rename File' and other PsiFile-dependent actions in LocalChanges tree context

PsiFileRule is a 'GetDataRuleType.PROVIDER' so it requires both VirtualFile and Project being
provided by the same DataProvider instance.

GitOrigin-RevId: 21a524e8bae47d04176cf7feb85027966cdab5d5
This commit is contained in:
Aleksey Pivovarov
2024-03-26 18:37:30 +00:00
committed by intellij-monorepo-bot
parent e0ea0e8899
commit b87e7d556d
2 changed files with 3 additions and 2 deletions
@@ -3,7 +3,6 @@ package com.intellij.openapi.vcs.changes.savedPatches
import com.intellij.ide.util.treeView.TreeState
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ClearableLazyValue
import com.intellij.openapi.util.Disposer
@@ -65,7 +64,6 @@ class SavedPatchesTree(project: Project,
val selectedObjects = selectedPatchObjects()
val data = visibleProvidersList.firstNotNullOfOrNull { provider -> provider.getData(dataId, selectedObjects) }
if (data != null) return data
if (CommonDataKeys.PROJECT.`is`(dataId)) return myProject
return super.getData(dataId)
}
@@ -814,6 +814,9 @@ public abstract class ChangesTree extends Tree implements DataProvider {
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myTreeCopyProvider;
}