mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
vcs: cleanup 'uiDataSnapshot' usages
GitOrigin-RevId: 6596ef771caa53b55005d17503cd6c41291d9145
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b8839cab8b
commit
a5e0c521f5
@@ -17,7 +17,6 @@ import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil
|
||||
import com.intellij.openapi.vcs.changes.ui.*
|
||||
import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.selected
|
||||
import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.uiDataSnapshot
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.ui.ClientProperty
|
||||
import com.intellij.ui.ExpandableItemsHandler
|
||||
@@ -102,7 +101,7 @@ object CodeReviewChangeListComponentFactory {
|
||||
|
||||
override fun uiDataSnapshot(sink: DataSink) {
|
||||
super.uiDataSnapshot(sink)
|
||||
uiDataSnapshot(sink, project, this)
|
||||
VcsTreeModelData.uiDataSnapshot(sink, project, this)
|
||||
sink[CommonDataKeys.NAVIGATABLE] = getSelectedFiles().singleOrNull()?.let { OpenFileDescriptor(project, it) }
|
||||
sink[CommonDataKeys.NAVIGATABLE_ARRAY] = ChangesUtil.getNavigatableArray(project, getSelectedFiles())
|
||||
sink[SELECTED_CHANGES] = getSelectedChanges()
|
||||
|
||||
@@ -178,15 +178,14 @@ abstract class SpecificFilesViewDialog extends DialogWrapper {
|
||||
@Override
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
super.uiDataSnapshot(sink);
|
||||
VcsTreeModelData.uiDataSnapshot(sink, myProject, this);
|
||||
|
||||
VcsTreeModelData treeSelection = VcsTreeModelData.selected(this);
|
||||
VcsTreeModelData exactSelection = VcsTreeModelData.exactlySelected(this);
|
||||
VcsTreeModelData.uiDataSnapshot(sink, myProject, this);
|
||||
sink.lazy(ChangesListView.EXACTLY_SELECTED_FILES_DATA_KEY, () ->
|
||||
VcsTreeModelData.mapToExactVirtualFile(exactSelection));
|
||||
sink.set(myShownDataKey,
|
||||
treeSelection.iterateUserObjects(FilePath.class));
|
||||
sink.set(VcsDataKeys.FILE_PATHS,
|
||||
treeSelection.iterateUserObjects(FilePath.class));
|
||||
sink.set(myShownDataKey, treeSelection.iterateUserObjects(FilePath.class));
|
||||
sink.set(VcsDataKeys.FILE_PATHS, treeSelection.iterateUserObjects(FilePath.class));
|
||||
sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, new VirtualFileDeleteProvider());
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, ChangesListView.HELP_ID);
|
||||
}
|
||||
|
||||
@@ -141,8 +141,7 @@ class SavedPatchesChangesBrowser(project: Project, internal val isShowDiffWithLo
|
||||
|
||||
val changeObjects = selection.iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java)
|
||||
sink[CommonDataKeys.VIRTUAL_FILE_ARRAY] = changeObjects
|
||||
.map { it.filePath.virtualFile }
|
||||
.filterNotNull()
|
||||
.filterMap { it.filePath.virtualFile }
|
||||
.toList().toTypedArray()
|
||||
sink[VcsDataKeys.FILE_PATHS] = changeObjects.map { it.filePath }
|
||||
sink[CommonDataKeys.NAVIGATABLE_ARRAY] = changeObjects
|
||||
|
||||
@@ -507,18 +507,15 @@ public class ShelvedChangesViewManager implements Disposable {
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
super.uiDataSnapshot(sink);
|
||||
sink.set(SHELVED_CHANGES_TREE, this);
|
||||
sink.set(SHELVED_CHANGELIST_KEY, new ArrayList<>(
|
||||
getSelectedLists(this, l -> !l.isRecycled() && !l.isDeleted())));
|
||||
sink.set(SHELVED_RECYCLED_CHANGELIST_KEY, new ArrayList<>(
|
||||
getSelectedLists(this, l -> l.isRecycled() && !l.isDeleted())));
|
||||
sink.set(SHELVED_DELETED_CHANGELIST_KEY, new ArrayList<>(
|
||||
getSelectedLists(this, l -> l.isDeleted())));
|
||||
sink.set(SHELVED_CHANGELIST_KEY, new ArrayList<>(getSelectedLists(this, l -> !l.isRecycled() && !l.isDeleted())));
|
||||
sink.set(SHELVED_RECYCLED_CHANGELIST_KEY, new ArrayList<>(getSelectedLists(this, l -> l.isRecycled() && !l.isDeleted())));
|
||||
sink.set(SHELVED_DELETED_CHANGELIST_KEY, new ArrayList<>(getSelectedLists(this, l -> l.isDeleted())));
|
||||
sink.set(SHELVED_CHANGE_KEY, VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class)
|
||||
.map(s -> s.getShelvedChange())
|
||||
.filterNotNull().toList());
|
||||
.filterMap(s -> s.getShelvedChange())
|
||||
.toList());
|
||||
sink.set(SHELVED_BINARY_FILE_KEY, VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class)
|
||||
.map(s -> s.getBinaryFile())
|
||||
.filterNotNull().toList());
|
||||
.filterMap(s -> s.getBinaryFile())
|
||||
.toList());
|
||||
if (!isEditing()) {
|
||||
sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.intellij.ide.SelectInContext;
|
||||
import com.intellij.openapi.ListSelection;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
@@ -315,34 +314,26 @@ public abstract class VcsTreeModelData {
|
||||
sink.set(VcsDataKeys.CHANGE_LEAD_SELECTION,
|
||||
mapToChange(exactlySelected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY));
|
||||
sink.set(VcsDataKeys.FILE_PATHS, mapToFilePath(selected(tree)));
|
||||
|
||||
VcsTreeModelData treeSelection = selected(tree);
|
||||
VcsTreeModelData exactSelection = exactlySelected(tree);
|
||||
sink.set(PlatformCoreDataKeys.BGT_DATA_PROVIDER,
|
||||
slowId -> getSlowData(project, treeSelection, exactSelection, slowId));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Object getSlowData(@Nullable Project project,
|
||||
@NotNull VcsTreeModelData treeSelection,
|
||||
@NotNull VcsTreeModelData exactSelection,
|
||||
@NotNull String slowId) {
|
||||
if (SelectInContext.DATA_KEY.is(slowId)) {
|
||||
sink.lazy(SelectInContext.DATA_KEY, () -> {
|
||||
if (project == null) return null;
|
||||
VirtualFile file = mapObjectToVirtualFile(exactSelection.iterateRawUserObjects()).first();
|
||||
if (file == null) return null;
|
||||
return new FileSelectInContext(project, file, null);
|
||||
}
|
||||
else if (VcsDataKeys.VIRTUAL_FILES.is(slowId)) {
|
||||
});
|
||||
sink.lazy(VcsDataKeys.VIRTUAL_FILES, () -> {
|
||||
return mapToVirtualFile(treeSelection);
|
||||
}
|
||||
else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(slowId)) {
|
||||
});
|
||||
sink.lazy(CommonDataKeys.VIRTUAL_FILE_ARRAY, () -> {
|
||||
return mapToVirtualFile(treeSelection).toArray(VirtualFile.EMPTY_ARRAY);
|
||||
});
|
||||
if (project != null) {
|
||||
sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY, () -> {
|
||||
return ChangesUtil.getNavigatableArray(project, mapToNavigatableFile(treeSelection));
|
||||
});
|
||||
}
|
||||
else if (CommonDataKeys.NAVIGATABLE_ARRAY.is(slowId)) {
|
||||
if (project == null) return null;
|
||||
return ChangesUtil.getNavigatableArray(project, mapToNavigatableFile(treeSelection));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -10,7 +10,10 @@ import com.intellij.diff.util.DiffPlaces
|
||||
import com.intellij.diff.util.DiffUserDataKeysEx
|
||||
import com.intellij.ide.ui.customization.CustomActionsSchema.Companion.getInstance
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.DataKey
|
||||
import com.intellij.openapi.actionSystem.DataSink
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
@@ -276,20 +279,28 @@ class VcsLogChangesBrowser internal constructor(project: Project,
|
||||
val roots = HashSet(commitModel.roots)
|
||||
val selectedData = VcsTreeModelData.selected(myViewer)
|
||||
sink.lazy(VcsDataKeys.VCS) {
|
||||
val rootsVcs = JBIterable.from<VirtualFile>(roots)
|
||||
.map<AbstractVcs?> { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) }
|
||||
.filterNotNull()
|
||||
.unique()
|
||||
.single()
|
||||
rootsVcs?.keyInstanceMethod ?: selectedData.iterateUserObjects<Change>(Change::class.java)
|
||||
.map<FilePath> { change -> ChangesUtil.getFilePath(change) }
|
||||
.map<AbstractVcs?> { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) }
|
||||
.filterNotNull()
|
||||
.unique()
|
||||
.single()?.keyInstanceMethod
|
||||
getSelectedVcs(roots, selectedData)?.keyInstanceMethod
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSelectedVcs(
|
||||
roots: Set<VirtualFile>,
|
||||
selectedData: VcsTreeModelData,
|
||||
): AbstractVcs? {
|
||||
val rootsVcs = JBIterable.from(roots)
|
||||
.filterMap { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) }
|
||||
.unique()
|
||||
.single()
|
||||
if (rootsVcs != null) return rootsVcs
|
||||
|
||||
val selectionVcs = selectedData.iterateUserObjects(Change::class.java)
|
||||
.map { change -> ChangesUtil.getFilePath(change) }
|
||||
.filterMap { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) }
|
||||
.unique()
|
||||
.single()
|
||||
return selectionVcs
|
||||
}
|
||||
|
||||
public override fun getDiffRequestProducer(userObject: Any): ChangeDiffRequestChain.Producer? {
|
||||
return getDiffRequestProducer(userObject, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user