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();
}
Aggregations