mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
AT-3955 [Starter]: Support split mode in refactoring commands
(cherry picked from commit 95df561094057d2bcd7116a472a8d56f6fdb33ae) IJ-CR-190174 GitOrigin-RevId: 123d0112df73978563ba426008965faa2735845a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e11747ab21
commit
5a8ca825d2
@@ -5,6 +5,7 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.application.writeIntentReadAction
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.PlaybackCommandCoroutineAdapter
|
||||
@@ -61,8 +62,10 @@ class ChangeJavaSignatureCommand(text: String, line: Int) : PlaybackCommandCorou
|
||||
if (args.size > 2) throw IllegalArgumentException("Too many arguments provided")
|
||||
|
||||
|
||||
val editor = readAction { FileEditorManager.getInstance(context.project).selectedTextEditor }
|
||||
?: throw IllegalArgumentException("There is no selected editor")
|
||||
val editor = readAction {
|
||||
val fileEditorManager = FileEditorManager.getInstance(context.project)
|
||||
fileEditorManager.selectedTextEditor ?: fileEditorManager.getAllEditors().firstNotNullOfOrNull { it as TextEditor }?.editor
|
||||
} ?: throw IllegalArgumentException("Couldn't get text editor")
|
||||
|
||||
|
||||
val elementUnderCaret = readAction {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.application.writeIntentReadAction
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.PlaybackCommandCoroutineAdapter
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
@@ -33,8 +34,10 @@ class InlineJavaMethodCommand(text: String, line: Int) : PlaybackCommandCoroutin
|
||||
val project = context.project
|
||||
|
||||
|
||||
val editor = readAction { FileEditorManager.getInstance(context.project).selectedTextEditor }
|
||||
?: throw IllegalArgumentException("There is no selected editor")
|
||||
val editor = readAction {
|
||||
val fileEditorManager = FileEditorManager.getInstance(context.project)
|
||||
fileEditorManager.selectedTextEditor ?: fileEditorManager.getAllEditors().firstNotNullOfOrNull { it as TextEditor }?.editor
|
||||
} ?: throw IllegalArgumentException("Couldn't get text editor")
|
||||
|
||||
|
||||
val elementUnderCaret = readAction {
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.application.writeIntentReadAction
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.PlaybackCommandCoroutineAdapter
|
||||
@@ -37,8 +39,10 @@ class MoveClassToPackageCommand(text: String, line: Int) : PlaybackCommandCorout
|
||||
val project = context.project
|
||||
val targetPackageName: String = extractCommandArgument(PREFIX)
|
||||
|
||||
val editor = readAction { FileEditorManager.getInstance(context.project).selectedTextEditor }
|
||||
?: throw IllegalArgumentException("There is no selected editor")
|
||||
val editor = readAction {
|
||||
val fileEditorManager = FileEditorManager.getInstance(context.project)
|
||||
fileEditorManager.selectedTextEditor ?: fileEditorManager.getAllEditors().firstNotNullOfOrNull { it as TextEditor }?.editor
|
||||
} ?: throw IllegalArgumentException("Couldn't get text editor")
|
||||
|
||||
val elementUnderCaret = readAction {
|
||||
PsiDocumentManager.getInstance(project).getPsiFile(editor.document)?.findElementAt(editor.caretModel.offset)
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.application.WriteAction
|
||||
import com.intellij.openapi.command.CommandEvent
|
||||
import com.intellij.openapi.command.CommandListener
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.AbstractCommand
|
||||
import com.intellij.refactoring.listeners.RefactoringEventData
|
||||
@@ -63,7 +64,11 @@ class FinishInlineRename(text: String, line: Int) : AbstractCommand(text, line)
|
||||
}
|
||||
})
|
||||
WriteAction.runAndWait<Throwable> {
|
||||
val templateState = TemplateManagerImpl.getTemplateState(FileEditorManager.getInstance(context.project).selectedTextEditor!!)
|
||||
val fileEditorManager = FileEditorManager.getInstance(context.project)
|
||||
val editor = fileEditorManager.selectedTextEditor
|
||||
?: fileEditorManager.getAllEditors().filterIsInstance<TextEditor>().firstOrNull()?.editor
|
||||
?: throw IllegalStateException("Couldn't get text editor")
|
||||
val templateState = TemplateManagerImpl.getTemplateState(editor)
|
||||
templateState?.nextTab()
|
||||
}
|
||||
return actionCallback.toPromise()
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.intellij.ide.DataManager
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.command.impl.UndoManagerImpl
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.AbstractCommand
|
||||
import com.intellij.openapi.wm.IdeFocusManager
|
||||
@@ -34,11 +36,16 @@ class StartInlineRenameCommand(text: String, line: Int) : AbstractCommand(text,
|
||||
UndoManagerImpl.ourNeverAskUser = true
|
||||
ApplicationManager.getApplication().invokeAndWait(Context.current().wrap(Runnable {
|
||||
val focusedComponent = IdeFocusManager.findInstance().focusOwner
|
||||
val dataContext = DataManager.getInstance().getDataContext(focusedComponent)
|
||||
val editor = dataContext.getData(CommonDataKeys.EDITOR)
|
||||
var dataContext = DataManager.getInstance().getDataContext(focusedComponent)
|
||||
var editor = dataContext.getData(CommonDataKeys.EDITOR)
|
||||
|
||||
if (editor == null) {
|
||||
actionCallback.reject("Editor is not focused")
|
||||
return@Runnable
|
||||
editor = FileEditorManager.getInstance(project).getAllEditors().filterIsInstance<TextEditor>().firstOrNull()?.editor
|
||||
if (editor == null) {
|
||||
actionCallback.reject("Couldn't get text editor")
|
||||
return@Runnable
|
||||
}
|
||||
dataContext = DataManager.getInstance().getDataContext(editor.component)
|
||||
}
|
||||
if (InplaceRefactoringContinuation.tryResumeInplaceContinuation(project, editor, RenameElementAction::class.java)) {
|
||||
actionCallback.reject("Another refactoring is in progress")
|
||||
|
||||
Reference in New Issue
Block a user