From 9714c1e16e87dd65c3d14b6ccc4c5e2eaa449ee9 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Tue, 5 Dec 2023 21:29:07 +0100 Subject: [PATCH] Add debug --- .../aspire/sessionHost/AspireSessionRunner.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/intellij/aspire/sessionHost/AspireSessionRunner.kt b/src/main/kotlin/com/intellij/aspire/sessionHost/AspireSessionRunner.kt index ca2e61c9..760dd495 100644 --- a/src/main/kotlin/com/intellij/aspire/sessionHost/AspireSessionRunner.kt +++ b/src/main/kotlin/com/intellij/aspire/sessionHost/AspireSessionRunner.kt @@ -49,14 +49,21 @@ class AspireSessionRunner(private val project: Project) { ) { LOG.info("Starting a session for the project ${session.projectPath}") - val configuration = getOrCreateConfiguration(session, hostId) + val host = AspireSessionHostService.getInstance().getHost(hostId) + if (host == null) { + LOG.warn("Unable to find Aspire host with id=$hostId") + return + } + + val configuration = getOrCreateConfiguration(session, host) if (configuration == null) { LOG.warn("Unable to find or create run configuration for the project ${session.projectPath}") return } + val isDebug = host.isDebug || session.debug val executor = - if (!session.debug) DefaultRunExecutor.getRunExecutorInstance() + if (!isDebug) DefaultRunExecutor.getRunExecutorInstance() else DefaultDebugExecutor.getDebugExecutorInstance() val environment = ExecutionEnvironmentBuilder @@ -102,19 +109,16 @@ class AspireSessionRunner(private val project: Project) { ProgramRunnerUtil.executeConfiguration(environment, false, true) } - private fun getOrCreateConfiguration(session: SessionModel, hostId: String): RunnerAndConfigurationSettings? { + private fun getOrCreateConfiguration( + session: SessionModel, + host: AspireSessionHostService.HostConfiguration + ): RunnerAndConfigurationSettings? { val projects = project.solution.runnableProjectsModel.projects.valueOrNull if (projects == null) { LOG.warn("Runnable projects model doesn't contain projects") return null } - val host = AspireSessionHostService.getInstance().getHost(hostId) - if (host == null) { - LOG.warn("Unable to find Aspire host with id=$hostId") - return null - } - val projectPath = Path(session.projectPath).systemIndependentPath val runnableProject = projects.firstOrNull { DotNetProjectConfigurationType.isTypeApplicable(it.kind) && it.projectFilePath == projectPath