Search in sources :

Example 1 with NocalhostRunner

use of dev.nocalhost.plugin.intellij.configuration.NocalhostRunner in project nocalhost-intellij-plugin by nocalhost.

the class NocalhostGoDlvDebugRunner method attachDlv.

private RunContentDescriptor attachDlv(RunProfileState state, @NotNull ExecutionEnvironment env, String debugPort) throws ExecutionException {
    NocalhostGoConfigurationFactory factory = (NocalhostGoConfigurationFactory) (new NocalhostGoConfigurationType().getConfigurationFactories())[0];
    NocalhostGoConfiguration configuration = (NocalhostGoConfiguration) factory.createTemplateConfiguration(env.getProject());
    Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(env.getProject(), executor, configuration).build();
    NocalhostRunner runner = Objects.requireNonNull(ProgramRunner.PROGRAM_RUNNER_EP.findExtension(NocalhostRunner.class));
    InetSocketAddress socketAddress = new InetSocketAddress("localhost", Integer.parseInt(debugPort));
    ExecutionResult executionResult = state.execute(environment.getExecutor(), runner);
    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException {
            DlvDebugProcess process = new DlvDebugProcess(session, new NocalhostGoDlvRemoteVmConnection(DlvDisconnectOption.DETACH), executionResult, true);
            process.connect(socketAddress);
            return process;
        }
    }).getRunContentDescriptor();
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DlvDebugProcess(com.goide.dlv.DlvDebugProcess) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) InetSocketAddress(java.net.InetSocketAddress) ExecutionResult(com.intellij.execution.ExecutionResult) NocalhostRunner(dev.nocalhost.plugin.intellij.configuration.NocalhostRunner) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter)

Aggregations

DlvDebugProcess (com.goide.dlv.DlvDebugProcess)1 ExecutionResult (com.intellij.execution.ExecutionResult)1 Executor (com.intellij.execution.Executor)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 NocalhostRunner (dev.nocalhost.plugin.intellij.configuration.NocalhostRunner)1 InetSocketAddress (java.net.InetSocketAddress)1 NotNull (org.jetbrains.annotations.NotNull)1