mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
terminal: rename TerminalSession to BlockTerminalSession
GitOrigin-RevId: bb944813c0ca70fe5d477b3158221b906cd5d1f2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3709097ce6
commit
cf403ad5e8
@@ -18,7 +18,7 @@ import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
class BlockTerminalController(
|
||||
private val project: Project,
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val outputController: TerminalOutputController,
|
||||
private val promptController: TerminalPromptController,
|
||||
private val selectionController: TerminalSelectionController,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.intellij.terminal.JBTerminalSystemSettingsProviderBase
|
||||
import java.awt.event.KeyEvent
|
||||
|
||||
class BlockTerminalEventsHandler(
|
||||
session: TerminalSession,
|
||||
session: BlockTerminalSession,
|
||||
settings: JBTerminalSystemSettingsProviderBase,
|
||||
private val outputController: TerminalOutputController
|
||||
) : SimpleTerminalEventsHandler(session, settings, outputController.outputModel) {
|
||||
|
||||
+5
-5
@@ -18,9 +18,9 @@ import org.jetbrains.plugins.terminal.util.ShellIntegration
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
class TerminalSession(settings: JBTerminalSystemSettingsProviderBase,
|
||||
val colorPalette: TerminalColorPalette,
|
||||
val shellIntegration: ShellIntegration) : Disposable {
|
||||
class BlockTerminalSession(settings: JBTerminalSystemSettingsProviderBase,
|
||||
val colorPalette: TerminalColorPalette,
|
||||
val shellIntegration: ShellIntegration) : Disposable {
|
||||
val model: TerminalModel
|
||||
internal val terminalStarterFuture: CompletableFuture<TerminalStarter?> = CompletableFuture()
|
||||
|
||||
@@ -105,7 +105,7 @@ class TerminalSession(settings: JBTerminalSystemSettingsProviderBase,
|
||||
}
|
||||
|
||||
companion object {
|
||||
val KEY: Key<TerminalSession> = Key.create("TerminalSession")
|
||||
val DATA_KEY: DataKey<TerminalSession> = DataKey.create("TerminalSession")
|
||||
val KEY: Key<BlockTerminalSession> = Key.create("TerminalSession")
|
||||
val DATA_KEY: DataKey<BlockTerminalSession> = DataKey.create("TerminalSession")
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import javax.swing.JPanel
|
||||
|
||||
class BlockTerminalView(
|
||||
private val project: Project,
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val settings: JBTerminalSystemSettingsProviderBase,
|
||||
terminalTitle: TerminalTitle
|
||||
) : TerminalContentView, TerminalCommandExecutor {
|
||||
@@ -221,7 +221,7 @@ class BlockTerminalView(
|
||||
BlockTerminalController.KEY.name -> controller
|
||||
TerminalSelectionController.KEY.name -> selectionController
|
||||
TerminalFocusModel.KEY.name -> focusModel
|
||||
TerminalSession.DATA_KEY.name -> session
|
||||
BlockTerminalSession.DATA_KEY.name -> session
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.jetbrains.plugins.terminal.exp
|
||||
import com.intellij.openapi.util.text.Strings
|
||||
import java.util.*
|
||||
|
||||
class CommandHistoryManager(session: TerminalSession) {
|
||||
class CommandHistoryManager(session: BlockTerminalSession) {
|
||||
private val mutableHistory: MutableSet<String> = Collections.synchronizedSet(LinkedHashSet())
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ import javax.swing.JComponent
|
||||
@Suppress("unused")
|
||||
class PlainTerminalView(
|
||||
project: Project,
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
settings: JBTerminalSystemSettingsProviderBase
|
||||
) : TerminalContentView {
|
||||
override val component: JComponent
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import java.util.concurrent.CancellationException
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
internal class ShellCommandExecutionManager(private val session: TerminalSession, commandManager: ShellCommandManager) {
|
||||
internal class ShellCommandExecutionManager(private val session: BlockTerminalSession, commandManager: ShellCommandManager) {
|
||||
|
||||
private val lock: Lock = Lock()
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.*
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ShellCommandManager(session: TerminalSession) {
|
||||
class ShellCommandManager(session: BlockTerminalSession) {
|
||||
private val listeners: CopyOnWriteArrayList<ShellCommandListener> = CopyOnWriteArrayList()
|
||||
|
||||
@Volatile
|
||||
|
||||
+2
-2
@@ -13,11 +13,11 @@ import org.jetbrains.plugins.terminal.TerminalUtil
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
internal class ShellCommandOutputScraper(private val session: TerminalSession,
|
||||
internal class ShellCommandOutputScraper(private val session: BlockTerminalSession,
|
||||
private val textBuffer: TerminalTextBuffer,
|
||||
parentDisposable: Disposable) {
|
||||
|
||||
constructor(session: TerminalSession): this(session, session.model.textBuffer, session)
|
||||
constructor(session: BlockTerminalSession): this(session, session.model.textBuffer, session)
|
||||
|
||||
private val listeners: MutableList<ShellCommandOutputListener> = CopyOnWriteArrayList()
|
||||
private val contentChangedAlarm: Alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, parentDisposable)
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.plugins.terminal.exp.TerminalUiUtils.toTextAttributes
|
||||
|
||||
class SimpleTerminalController(
|
||||
settings: JBTerminalSystemSettingsProviderBase,
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val editor: EditorEx
|
||||
) : Disposable {
|
||||
val document: Document
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import kotlin.math.abs
|
||||
* Logic of mouse event handling is copied from [com.jediterm.terminal.model.JediTerminal]
|
||||
*/
|
||||
open class SimpleTerminalEventsHandler(
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val settings: JBTerminalSystemSettingsProviderBase,
|
||||
protected val outputModel: TerminalOutputModel,
|
||||
) : TerminalEventsHandler {
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.swing.JScrollPane
|
||||
class SimpleTerminalView(
|
||||
private val project: Project,
|
||||
private val settings: JBTerminalSystemSettingsProviderBase,
|
||||
session: TerminalSession,
|
||||
session: BlockTerminalSession,
|
||||
private val withVerticalScroll: Boolean = true
|
||||
) : Disposable {
|
||||
private val editor: EditorImpl
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class TerminalCaretModel(
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val outputModel: TerminalOutputModel,
|
||||
private val editor: EditorEx,
|
||||
parentDisposable: Disposable,
|
||||
|
||||
@@ -48,6 +48,6 @@ object TerminalDataContextUtils {
|
||||
get() = getData(TerminalSelectionController.KEY)
|
||||
val AnActionEvent.terminalFocusModel: TerminalFocusModel?
|
||||
get() = getData(TerminalFocusModel.KEY)
|
||||
val AnActionEvent.terminalSession: TerminalSession?
|
||||
get() = getData(TerminalSession.DATA_KEY)
|
||||
val AnActionEvent.terminalSession: BlockTerminalSession?
|
||||
get() = getData(BlockTerminalSession.DATA_KEY)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.awt.Font
|
||||
|
||||
class TerminalOutputController(
|
||||
private val editor: EditorEx,
|
||||
private val session: TerminalSession,
|
||||
private val session: BlockTerminalSession,
|
||||
private val settings: JBTerminalSystemSettingsProviderBase
|
||||
) : TerminalModel.TerminalListener {
|
||||
val outputModel: TerminalOutputModel = TerminalOutputModel(editor)
|
||||
|
||||
@@ -28,7 +28,7 @@ import kotlin.math.min
|
||||
|
||||
class TerminalOutputView(
|
||||
private val project: Project,
|
||||
session: TerminalSession,
|
||||
session: BlockTerminalSession,
|
||||
settings: JBTerminalSystemSettingsProviderBase
|
||||
) : Disposable {
|
||||
val controller: TerminalOutputController
|
||||
|
||||
@@ -21,7 +21,7 @@ import kotlin.properties.Delegates
|
||||
class TerminalPromptController(
|
||||
project: Project,
|
||||
private val editor: EditorEx,
|
||||
session: TerminalSession,
|
||||
session: BlockTerminalSession,
|
||||
private val commandExecutor: TerminalCommandExecutor
|
||||
) : ShellCommandListener {
|
||||
private val commandHistoryManager: CommandHistoryManager
|
||||
@@ -47,7 +47,7 @@ class TerminalPromptController(
|
||||
|
||||
init {
|
||||
editor.putUserData(IS_PROMPT_EDITOR_KEY, true)
|
||||
editor.putUserData(TerminalSession.KEY, session)
|
||||
editor.putUserData(BlockTerminalSession.KEY, session)
|
||||
|
||||
val runtimeDataProvider = IJShellRuntimeDataProvider(session)
|
||||
editor.putUserData(IJShellRuntimeDataProvider.KEY, runtimeDataProvider)
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.swing.JPanel
|
||||
class TerminalPromptView(
|
||||
private val project: Project,
|
||||
private val settings: JBTerminalSystemSettingsProviderBase,
|
||||
session: TerminalSession,
|
||||
session: BlockTerminalSession,
|
||||
commandExecutor: TerminalCommandExecutor
|
||||
) : PromptStateListener, Disposable {
|
||||
val controller: TerminalPromptController
|
||||
@@ -92,7 +92,7 @@ class TerminalPromptView(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createPromptTextField(session: TerminalSession): LanguageTextField {
|
||||
private fun createPromptTextField(session: BlockTerminalSession): LanguageTextField {
|
||||
val language = TerminalShellSupport.findByShellType(session.shellIntegration.shellType)?.promptLanguage
|
||||
?: PlainTextLanguage.INSTANCE
|
||||
val textField = object : LanguageTextField(language, project, "", false) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class TerminalWidgetImpl(private val project: Project,
|
||||
val oldView = view
|
||||
view = if (options.shellIntegration?.withCommandBlocks == true) {
|
||||
val colorPalette = BlockTerminalColorPalette(EditorColorsManager.getInstance().getGlobalScheme())
|
||||
val session = TerminalSession(settings, colorPalette, options.shellIntegration)
|
||||
val session = BlockTerminalSession(settings, colorPalette, options.shellIntegration)
|
||||
Disposer.register(this, session)
|
||||
BlockTerminalView(project, session, settings, terminalTitle)
|
||||
}
|
||||
|
||||
+6
-6
@@ -6,7 +6,7 @@ import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.terminal.completion.ShellEnvironment
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.BlockTerminalSession
|
||||
import org.jetbrains.plugins.terminal.util.ShellType
|
||||
|
||||
internal interface DataProviderCommand<T> {
|
||||
@@ -14,7 +14,7 @@ internal interface DataProviderCommand<T> {
|
||||
val parameters: List<String>
|
||||
val defaultResult: T
|
||||
|
||||
fun isAvailable(session: TerminalSession): Boolean
|
||||
fun isAvailable(session: BlockTerminalSession): Boolean
|
||||
fun parseResult(result: String): T
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ internal class GetFilesCommand(path: String) : DataProviderCommand<List<String>>
|
||||
override val parameters: List<String> = listOf(path)
|
||||
override val defaultResult: List<String> = emptyList()
|
||||
|
||||
override fun isAvailable(session: TerminalSession): Boolean {
|
||||
override fun isAvailable(session: BlockTerminalSession): Boolean {
|
||||
return session.isBashOrZsh()
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ internal class GetFilesCommand(path: String) : DataProviderCommand<List<String>>
|
||||
}
|
||||
}
|
||||
|
||||
internal class GetEnvironmentCommand(private val session: TerminalSession) : DataProviderCommand<ShellEnvironment?> {
|
||||
internal class GetEnvironmentCommand(private val session: BlockTerminalSession) : DataProviderCommand<ShellEnvironment?> {
|
||||
override val functionName: String = "__jetbrains_intellij_get_environment"
|
||||
override val parameters: List<String> = emptyList()
|
||||
override val defaultResult: ShellEnvironment? = null
|
||||
|
||||
override fun isAvailable(session: TerminalSession): Boolean {
|
||||
override fun isAvailable(session: BlockTerminalSession): Boolean {
|
||||
return session.isBashOrZsh()
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ internal class GetEnvironmentCommand(private val session: TerminalSession) : Dat
|
||||
}
|
||||
}
|
||||
|
||||
private fun TerminalSession.isBashOrZsh(): Boolean {
|
||||
private fun BlockTerminalSession.isBashOrZsh(): Boolean {
|
||||
return shellIntegration.shellType == ShellType.ZSH
|
||||
|| shellIntegration.shellType == ShellType.BASH
|
||||
}
|
||||
+2
-2
@@ -11,10 +11,10 @@ import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
||||
import com.intellij.terminal.completion.ShellEnvironment
|
||||
import com.intellij.terminal.completion.ShellRuntimeDataProvider
|
||||
import org.jetbrains.plugins.terminal.exp.ShellCommandListener
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.BlockTerminalSession
|
||||
import java.time.Duration
|
||||
|
||||
class IJShellRuntimeDataProvider(private val session: TerminalSession) : ShellRuntimeDataProvider {
|
||||
class IJShellRuntimeDataProvider(private val session: BlockTerminalSession) : ShellRuntimeDataProvider {
|
||||
@Volatile
|
||||
private var cachedShellEnv: ShellEnvironment? = null
|
||||
|
||||
|
||||
+3
-3
@@ -10,14 +10,14 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.terminal.completion.CommandSpecCompletion
|
||||
import com.intellij.terminal.completion.ShellRuntimeDataProvider
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.BlockTerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.completion.TerminalCompletionUtil.findIconForSuggestion
|
||||
import org.jetbrains.plugins.terminal.exp.completion.TerminalCompletionUtil.getNextSuggestionsString
|
||||
import org.jetbrains.terminal.completion.BaseSuggestion
|
||||
|
||||
internal class TerminalCommandSpecCompletionContributor : CompletionContributor(), DumbAware {
|
||||
override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
|
||||
val session = parameters.editor.getUserData(TerminalSession.KEY)
|
||||
val session = parameters.editor.getUserData(BlockTerminalSession.KEY)
|
||||
val runtimeDataProvider = parameters.editor.getUserData(IJShellRuntimeDataProvider.KEY)
|
||||
if (session == null || runtimeDataProvider == null || parameters.completionType != CompletionType.BASIC) {
|
||||
return
|
||||
@@ -115,7 +115,7 @@ internal class TerminalCommandSpecCompletionContributor : CompletionContributor(
|
||||
}
|
||||
|
||||
private class TerminalCompletionContext(
|
||||
val session: TerminalSession,
|
||||
val session: BlockTerminalSession,
|
||||
val runtimeDataProvider: ShellRuntimeDataProvider,
|
||||
val shellSupport: TerminalShellSupport,
|
||||
val parameters: CompletionParameters
|
||||
|
||||
@@ -152,7 +152,7 @@ class BlockTerminalTest(private val shellPath: String) {
|
||||
assertCommandResult(0, MoveCursorToLineEndAndPrint.Helper.getExpectedOutput(termSize, textsToPrint), outputFuture)
|
||||
}
|
||||
|
||||
private fun createCommandSentDeferred(session: TerminalSession): CompletableDeferred<Unit> {
|
||||
private fun createCommandSentDeferred(session: BlockTerminalSession): CompletableDeferred<Unit> {
|
||||
val generatorCommandSent = CompletableDeferred<Unit>()
|
||||
val generatorCommandSentDisposable = Disposer.newDisposable().also { disposable ->
|
||||
generatorCommandSent.invokeOnCompletion { Disposer.dispose(disposable) }
|
||||
@@ -175,7 +175,7 @@ class BlockTerminalTest(private val shellPath: String) {
|
||||
private fun startBlockTerminalSession(termSize: TermSize = TermSize(80, 24)) =
|
||||
TerminalSessionTestUtil.startBlockTerminalSession(projectRule.project, shellPath, disposableRule.disposable, termSize)
|
||||
|
||||
private fun TerminalSession.sendCommandToExecuteWithoutAddingToHistory(shellCommand: String) {
|
||||
private fun BlockTerminalSession.sendCommandToExecuteWithoutAddingToHistory(shellCommand: String) {
|
||||
this.sendCommandToExecute(" $shellCommand")
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ class BlockTerminalTest(private val shellPath: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun getCommandResultFuture(session: TerminalSession): CompletableFuture<CommandResult> {
|
||||
fun getCommandResultFuture(session: BlockTerminalSession): CompletableFuture<CommandResult> {
|
||||
val disposable = Disposer.newDisposable(session)
|
||||
val scraper = ShellCommandOutputScraper(session)
|
||||
val lastOutput: AtomicReference<StyledCommandOutput> = AtomicReference()
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@RunWith(JUnit4::class)
|
||||
class ShellRuntimeDataProviderTest : BasePlatformTestCase() {
|
||||
private lateinit var session: TerminalSession
|
||||
private lateinit var session: BlockTerminalSession
|
||||
private lateinit var testDirectory: Path
|
||||
|
||||
override fun tearDown() {
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ import org.jetbrains.plugins.terminal.LocalBlockTerminalRunner
|
||||
import org.jetbrains.plugins.terminal.ShellStartupOptions
|
||||
import org.jetbrains.plugins.terminal.exp.ShellCommandListener
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalModel
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.BlockTerminalSession
|
||||
import org.jetbrains.plugins.terminal.exp.ui.BlockTerminalColorPalette
|
||||
import org.junit.Assume
|
||||
import java.nio.file.Path
|
||||
@@ -28,7 +28,7 @@ object TerminalSessionTestUtil {
|
||||
fun startBlockTerminalSession(project: Project,
|
||||
shellPath: String,
|
||||
parentDisposable: Disposable,
|
||||
initialTermSize: TermSize = TermSize(200, 20)): TerminalSession {
|
||||
initialTermSize: TermSize = TermSize(200, 20)): BlockTerminalSession {
|
||||
Registry.get(LocalBlockTerminalRunner.BLOCK_TERMINAL_REGISTRY).setValue(true, parentDisposable)
|
||||
Registry.get(LocalBlockTerminalRunner.BLOCK_TERMINAL_FISH_REGISTRY).setValue(true, parentDisposable)
|
||||
Registry.get(LocalBlockTerminalRunner.BLOCK_TERMINAL_POWERSHELL_REGISTRY).setValue(true, parentDisposable)
|
||||
@@ -40,7 +40,7 @@ object TerminalSessionTestUtil {
|
||||
val ttyConnector = runner.createTtyConnector(process)
|
||||
|
||||
val colorPalette = BlockTerminalColorPalette(EditorColorsManager.getInstance().globalScheme)
|
||||
val session = TerminalSession(runner.settingsProvider, colorPalette, configuredOptions.shellIntegration!!)
|
||||
val session = BlockTerminalSession(runner.settingsProvider, colorPalette, configuredOptions.shellIntegration!!)
|
||||
Disposer.register(parentDisposable, session)
|
||||
session.controller.resize(initialTermSize, RequestOrigin.User)
|
||||
val model: TerminalModel = session.model
|
||||
|
||||
Reference in New Issue
Block a user