generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Jozott00/move-to-executor
Remove Custom Run Tool-Window
- Loading branch information
Showing
43 changed files
with
810 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,8 @@ jobs: | |
# Run Qodana inspections | ||
- name: Qodana - Code Inspection | ||
uses: JetBrains/[email protected] | ||
env: | ||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} | ||
with: | ||
cache-default-branch-only: true | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/github/jozott00/wokwiintellij/actions/WokwiRestartAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package com.github.jozott00.wokwiintellij.actions | ||
|
||
import com.github.jozott00.wokwiintellij.services.WokwiProjectService | ||
import com.github.jozott00.wokwiintellij.services.WokwiSimulatorService | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
|
||
class WokwiRestartAction : AnAction() { | ||
override fun actionPerformed(p0: AnActionEvent) { | ||
p0.project?.service<WokwiProjectService>()?.startSimulator() | ||
p0.project?.service<WokwiSimulatorService>()?.startSimulator() | ||
} | ||
|
||
} |
21 changes: 11 additions & 10 deletions
21
src/main/kotlin/com/github/jozott00/wokwiintellij/actions/WokwiStartAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.github.jozott00.wokwiintellij.actions | ||
|
||
|
||
import com.github.jozott00.wokwiintellij.services.WokwiProjectService | ||
import com.github.jozott00.wokwiintellij.services.WokwiSimulatorService | ||
import com.github.jozott00.wokwiintellij.utils.simulation.SimulatorRunUtils | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
|
||
class WokwiStartAction : AnAction() { | ||
|
||
|
||
// TODO: Consider run configuration instead of custom run handling | ||
override fun update(e: AnActionEvent) { | ||
e.project?.let { | ||
e.presentation.isEnabled = !it.service<WokwiSimulatorService>().isSimulatorRunning() | ||
} | ||
} | ||
override fun actionPerformed(event: AnActionEvent) { | ||
// event.project?.let { | ||
// val config = RunManager.getInstance(it).createConfiguration("Wokwi Runner", WokwiConfigurationFactory(WokwiRunConfigType())) | ||
// ProgramRunnerUtil.executeConfiguration(config, DefaultRunExecutor.getRunExecutorInstance()) | ||
// } | ||
val s = event.project?.service<WokwiProjectService>() | ||
s?.startSimulator() | ||
event.project?.let { SimulatorRunUtils.startExecution(it) } | ||
} | ||
|
||
override fun getActionUpdateThread() = ActionUpdateThread.EDT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...kwiintellij/runner/macros/ElfPathMacro.kt → ...intellij/execution/macros/ElfPathMacro.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...kwiintellij/runner/WokwiProcessHandler.kt → ...ion/processHandler/WokwiProcessHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...tlin/com/github/jozott00/wokwiintellij/execution/processHandler/WokwiRunProcessHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.jozott00.wokwiintellij.execution.processHandler | ||
|
||
import com.github.jozott00.wokwiintellij.services.WokwiSimulatorService | ||
import com.github.jozott00.wokwiintellij.simulator.SimExitCode | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.Key | ||
import java.io.OutputStream | ||
|
||
class WokwiRunProcessHandler(project: Project): WokwiProcessHandler() { | ||
|
||
private val projectService: WokwiSimulatorService = project.service() | ||
|
||
override fun destroyProcessImpl() { | ||
projectService.stopSimulator() | ||
notifyProcessTerminated(0) | ||
} | ||
|
||
override fun detachProcessImpl() { | ||
notifyProcessDetached() | ||
} | ||
|
||
override fun detachIsDefault(): Boolean = false | ||
|
||
override fun getProcessInput(): OutputStream? { | ||
return null | ||
} | ||
|
||
override fun onTextAvailable(text: String, outputType: Key<*>) { | ||
notifyTextAvailable(text, outputType) | ||
} | ||
|
||
override fun onShutdown(exitCode: SimExitCode) { | ||
if (!isProcessTerminated) { | ||
notifyProcessTerminated(exitCode.int) | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...in/com/github/jozott00/wokwiintellij/execution/profileStates/WokwiSimulatorRunnerState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.jozott00.wokwiintellij.execution.profileStates | ||
|
||
import com.github.jozott00.wokwiintellij.services.WokwiSimulatorService | ||
import com.intellij.execution.Executor | ||
import com.intellij.execution.configurations.CommandLineState | ||
import com.intellij.execution.process.ProcessHandler | ||
import com.intellij.execution.runners.ExecutionEnvironment | ||
import com.intellij.execution.ui.ConsoleView | ||
import com.intellij.openapi.actionSystem.ActionManager | ||
import com.intellij.openapi.actionSystem.Separator | ||
import com.intellij.openapi.components.service | ||
|
||
class WokwiSimulatorRunnerState(myEnvironment: ExecutionEnvironment) : CommandLineState(myEnvironment) { | ||
private val projectService = myEnvironment.project.service<WokwiSimulatorService>() | ||
private val am = ActionManager.getInstance() | ||
override fun startProcess() = projectService.startSimulator(false) | ||
|
||
override fun createActions(console: ConsoleView?, processHandler: ProcessHandler?, executor: Executor?) = arrayOf( | ||
Separator(), | ||
am.getAction("com.github.jozott00.wokwiintellij.actions.WokwiWatchAction") | ||
) | ||
|
||
override fun createConsole(executor: Executor): ConsoleView? { | ||
val builder = consoleBuilder ?: return null | ||
builder.setViewer(true) // make it readonly | ||
return builder.console | ||
} | ||
|
||
} | ||
|
106 changes: 106 additions & 0 deletions
106
...lin/com/github/jozott00/wokwiintellij/execution/runBefore/WokwiStartDebugBeforeRunTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.github.jozott00.wokwiintellij.execution.runBefore | ||
|
||
import com.github.jozott00.wokwiintellij.services.WokwiSimulatorService | ||
import com.github.jozott00.wokwiintellij.simulator.WokwiSimulatorListener | ||
import com.github.jozott00.wokwiintellij.ui.WokwiIcons | ||
import com.github.jozott00.wokwiintellij.utils.simulation.SimulatorRunUtils | ||
import com.intellij.execution.BeforeRunTask | ||
import com.intellij.execution.BeforeRunTaskProvider | ||
import com.intellij.execution.configurations.RunConfiguration | ||
import com.intellij.execution.runners.ExecutionEnvironment | ||
import com.intellij.openapi.actionSystem.DataContext | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.util.Key | ||
import kotlinx.coroutines.* | ||
import javax.swing.Icon | ||
|
||
/** | ||
* A [BeforeRunTaskProvider] implementation that initiates a debug session by starting the Wokwi | ||
* simulator in debug mode before executing the main run configuration. | ||
* | ||
* This is required when debugging with CLion's `Remote Debug` configuration. | ||
*/ | ||
class WokwiStartDebugBeforeRunTaskProvider : BeforeRunTaskProvider<WokwiStartDebugBeforeRunTask>() { | ||
|
||
override fun getId(): Key<WokwiStartDebugBeforeRunTask> = ID | ||
|
||
override fun getName() = "Start Wokwi Debug" | ||
|
||
override fun getIcon(): Icon = WokwiIcons.Debug | ||
|
||
override fun createTask(runConfiguration: RunConfiguration): WokwiStartDebugBeforeRunTask = | ||
WokwiStartDebugBeforeRunTask() | ||
|
||
|
||
/** | ||
* Executes the task to start the Wokwi simulator in debug mode before the main run configuration. | ||
* It ensures the simulator is running and ready for debugging. The additional execution of the | ||
* run configuration is required to provide simulation output in a Run-window. | ||
* | ||
* @param context The data context in which the task is executed. | ||
* @param configuration The run configuration associated with the task. | ||
* @param environment The execution environment for the task. | ||
* @param task The [WokwiStartDebugBeforeRunTask] to be executed. | ||
* @return `true` if the task was successfully executed, `false` otherwise. | ||
*/ | ||
override fun executeTask( | ||
context: DataContext, | ||
configuration: RunConfiguration, | ||
environment: ExecutionEnvironment, | ||
task: WokwiStartDebugBeforeRunTask | ||
): Boolean { | ||
val projectService = environment.project.service<WokwiSimulatorService>() | ||
return runBlocking(Dispatchers.IO) { | ||
// start child scope to make cancellation on dispose possible. | ||
val job = projectService.childScope().async { | ||
val result = projectService.startSimulatorAsync(task, true) | ||
task.waitForSimulatorToBeRunning() | ||
result | ||
} | ||
try { | ||
val result = job.await() | ||
|
||
// start run execution for additional log output | ||
SimulatorRunUtils.startExecutionIfNotRunning(environment.project) | ||
|
||
result | ||
} catch (e: CancellationException) { | ||
false | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* A [BeforeRunTask] implementation that waits for the Wokwi simulator to start and reach a running state | ||
* before allowing the debug session to proceed. It implements the [WokwiSimulatorListener] interface | ||
* to receive notifications about the simulator's state. | ||
*/ | ||
class WokwiStartDebugBeforeRunTask : | ||
BeforeRunTask<WokwiStartDebugBeforeRunTask>(ID), WokwiSimulatorListener { | ||
|
||
private val simulatorRunning = CompletableDeferred<Unit>() | ||
|
||
/** | ||
* Suspends the current coroutine until the Wokwi simulator has been reported as running. | ||
* This method waits for the [onRunning] event to be called, indicating that the simulator | ||
* is ready. | ||
*/ | ||
suspend fun waitForSimulatorToBeRunning() { | ||
simulatorRunning.await() | ||
} | ||
|
||
/** | ||
* Callback method from the [WokwiSimulatorListener] interface. It is called when the simulator | ||
* changes its state to running. | ||
* | ||
* This method completes the [simulatorRunning] deferred, allowing any suspended coroutines | ||
* waiting for the simulator to start to resume execution. | ||
*/ | ||
override fun onRunning() { | ||
simulatorRunning.complete(Unit) | ||
} | ||
} | ||
|
||
val ID: Key<WokwiStartDebugBeforeRunTask> = Key.create("WokwiStartDebug.Before.Run") |
File renamed without changes.
Oops, something went wrong.