mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[undo] IJPL-201535 Refactor ActionMeta
GitOrigin-RevId: 41102bbbfe66c6e507cd530e0e1b8f37826fe0d7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8f427503f4
commit
440de44e07
@@ -211,7 +211,7 @@ final class CommandBuilder {
|
||||
private @NotNull UndoMeta createUndoMeta() {
|
||||
var actions = ContainerUtil.map(
|
||||
undoableActions,
|
||||
a -> ActionMeta.create(
|
||||
a -> UndoableActionMeta.create(
|
||||
UndoableActionType.forAction(a),
|
||||
a.getAffectedDocuments(),
|
||||
a.isGlobal()
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.openapi.project.Project
|
||||
interface UndoMeta {
|
||||
fun undoProject(): Project?
|
||||
fun focusedEditor(): FileEditor?
|
||||
fun undoableActions(): List<ActionMeta>
|
||||
fun undoableActions(): List<UndoableActionMeta>
|
||||
fun isForcedGlobal(): Boolean
|
||||
|
||||
companion object {
|
||||
@@ -19,10 +19,10 @@ interface UndoMeta {
|
||||
|
||||
@JvmStatic
|
||||
fun create(
|
||||
project: Project?,
|
||||
editor: FileEditor?,
|
||||
actions: List<ActionMeta>,
|
||||
isForcedGlobal: Boolean,
|
||||
project: Project?,
|
||||
editor: FileEditor?,
|
||||
actions: List<UndoableActionMeta>,
|
||||
isForcedGlobal: Boolean,
|
||||
): UndoMeta {
|
||||
if (project == null && editor == null && actions.isEmpty() && !isForcedGlobal) {
|
||||
return EmptyUndoMeta
|
||||
@@ -32,21 +32,21 @@ interface UndoMeta {
|
||||
}
|
||||
|
||||
private class ImmutableUndoMeta(
|
||||
private val project: Project?,
|
||||
private val editor: FileEditor?,
|
||||
private val actions: List<ActionMeta>,
|
||||
private val isForcedGlobal: Boolean,
|
||||
private val project: Project?,
|
||||
private val editor: FileEditor?,
|
||||
private val actions: List<UndoableActionMeta>,
|
||||
private val isForcedGlobal: Boolean,
|
||||
) : UndoMeta {
|
||||
override fun undoProject(): Project? = project
|
||||
override fun focusedEditor(): FileEditor? = editor
|
||||
override fun undoableActions(): List<ActionMeta> = actions
|
||||
override fun undoableActions(): List<UndoableActionMeta> = actions
|
||||
override fun isForcedGlobal(): Boolean = isForcedGlobal
|
||||
}
|
||||
|
||||
private object EmptyUndoMeta : UndoMeta {
|
||||
override fun undoProject(): Project? = null
|
||||
override fun focusedEditor(): FileEditor? = null
|
||||
override fun undoableActions(): List<ActionMeta> = emptyList()
|
||||
override fun undoableActions(): List<UndoableActionMeta> = emptyList()
|
||||
override fun isForcedGlobal(): Boolean = false
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,24 +5,24 @@ import com.intellij.openapi.command.impl.UndoableActionType
|
||||
import com.intellij.openapi.command.undo.DocumentReference
|
||||
|
||||
|
||||
interface ActionMeta {
|
||||
interface UndoableActionMeta {
|
||||
fun type(): UndoableActionType
|
||||
fun affectedDocuments(): Collection<DocumentReference>?
|
||||
fun isGlobal(): Boolean
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(type: UndoableActionType, affectedDocuments: Array<DocumentReference>?, isGlobal: Boolean): ActionMeta {
|
||||
return ActionMetaImpl(type, affectedDocuments?.toList(), isGlobal)
|
||||
fun create(type: UndoableActionType, affectedDocuments: Array<DocumentReference>?, isGlobal: Boolean): UndoableActionMeta {
|
||||
return UndoableActionMetaImpl(type, affectedDocuments?.toList(), isGlobal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ActionMetaImpl(
|
||||
private class UndoableActionMetaImpl(
|
||||
private val type: UndoableActionType,
|
||||
private val affectedDocuments: Collection<DocumentReference>?,
|
||||
private val isGlobal: Boolean,
|
||||
) : ActionMeta {
|
||||
) : UndoableActionMeta {
|
||||
override fun type(): UndoableActionType = type
|
||||
override fun affectedDocuments(): Collection<DocumentReference>? = affectedDocuments
|
||||
override fun isGlobal(): Boolean = isGlobal
|
||||
Reference in New Issue
Block a user