override fun attachDebugger()

in jetbrains-rider/src-203-212/software/aws/toolkits/jetbrains/services/clouddebug/DotNetDebuggerSupport.kt [90:135]


    override fun attachDebugger(
        context: Context,
        containerName: String,
        containerOptions: ImmutableContainerOptions,
        environment: ExecutionEnvironment,
        ports: List<Int>,
        displayName: String
    ): CompletableFuture<RunContentDescriptor?> {
        val manager = XDebuggerManager.getInstance(environment.project)
        val future = CompletableFuture<RunContentDescriptor?>()

        if (exeRemotePath.isEmpty()) {
            future.completeExceptionally(RuntimeException("DotNet executable to debug is not specified"))
            return future
        }

        if (ports.size < 2) {
            future.completeExceptionally(RuntimeException("DotNet requires two ports to be specified"))
            return future
        }

        val frontendPort = ports[0]
        val backendPort = ports[1]

        runInEdt {
            try {
                createDebugProcessAsync(environment, frontendPort, backendPort, exeRemotePath).then {
                    it?.let {
                        future.complete(
                            manager.startSessionAndShowTab(
                                displayName,
                                null,
                                it
                            ).runContentDescriptor
                        )
                    } ?: run {
                        future.complete(null)
                    }
                }
            } catch (e: Exception) {
                future.completeExceptionally(e)
            }
        }

        return future
    }