com.intellij.execution.configurations.RemoteConnection Java Examples

The following examples show how to use com.intellij.execution.configurations.RemoteConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoboVmRunner.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    if(DEBUG_EXECUTOR.equals(environment.getExecutor().getId())) {
        RoboVmRunConfiguration runConfig = (RoboVmRunConfiguration)environment.getRunProfile();
        RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", "" + runConfig.getDebugPort(), false);
        connection.setServerMode(true);
        return attachVirtualMachine(state, environment, connection, false);
    } else {
        ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
        if (executionResult == null) {
            return null;
        }
        return new RunContentBuilder(executionResult, environment).showRunContent(environment.getContentToReuse());
    }
}
 
Example #2
Source File: BlazeJavaDebuggableRunProfileState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteConnection getRemoteConnection() {
  if (!executorType.isDebugType()) {
    return null;
  }
  BlazeJavaRunConfigState state = cfg.getHandlerStateIfType(BlazeJavaRunConfigState.class);
  checkState(state != null);
  return new RemoteConnection(
      /* useSockets= */ true,
      DEBUG_HOST_NAME,
      Integer.toString(state.getDebugPortState().port),
      /* serverMode= */ false);
}
 
Example #3
Source File: BlazeJavaDebuggerRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public RunContentDescriptor createContentDescriptor(
    RunProfileState state, ExecutionEnvironment environment) throws ExecutionException {
  if (!(state instanceof BlazeJavaDebuggableRunProfileState)) {
    return null;
  }
  BlazeJavaDebuggableRunProfileState blazeState = (BlazeJavaDebuggableRunProfileState) state;
  RemoteConnection connection = blazeState.getRemoteConnection();
  return attachVirtualMachine(state, environment, connection, POLL_TIMEOUT_MILLIS);
}
 
Example #4
Source File: MultiRunDebuggerSessionListener.java    From intellij with Apache License 2.0 5 votes vote down vote up
public MultiRunDebuggerSessionListener(
    ExecutionEnvironment executionEnvironment, RemoteState state) {
  this.executionEnvironment = executionEnvironment;
  this.debuggerManager = DebuggerManagerEx.getInstanceEx(executionEnvironment.getProject());
  RemoteConnection remoteConnection = state.getRemoteConnection();
  debugEnvironment =
      new DefaultDebugEnvironment(executionEnvironment, state, remoteConnection, true);
}
 
Example #5
Source File: RoboVmRunner.java    From robovm-idea with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
                                                    @NotNull ExecutionEnvironment env,
                                                    RemoteConnection connection,
                                                    boolean pollConnection) throws ExecutionException {
    DebugEnvironment environment = new DefaultDebugUIEnvironment(env, state, connection, pollConnection).getEnvironment();
    final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
    if (debuggerSession == null) {
        return null;
    }

    final DebugProcessImpl debugProcess = debuggerSession.getProcess();
    if (debugProcess.isDetached() || debugProcess.isDetaching()) {
        debuggerSession.dispose();
        return null;
    }
    // optimization: that way BatchEvaluator will not try to lookup the class file in remote VM
    // which is an expensive operation when executed first time
    debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) {
            XDebugSessionImpl sessionImpl = (XDebugSessionImpl)session;
            ExecutionResult executionResult = debugProcess.getExecutionResult();
            sessionImpl.addExtraActions(executionResult.getActions());
            if (executionResult instanceof DefaultExecutionResult) {
                sessionImpl.addRestartActions(((DefaultExecutionResult)executionResult).getRestartActions());
                sessionImpl.addExtraStopActions(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
            }
            return JavaDebugProcess.create(session, debuggerSession);
        }
    }).getRunContentDescriptor();
}
 
Example #6
Source File: MuleRemoteDebuggerState.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public RemoteConnection getRemoteConnection() {
  return new RemoteConnection(true, host, jvmPort + "", false);
}
 
Example #7
Source File: TestExecutionState.java    From buck with Apache License 2.0 4 votes vote down vote up
private void attachDebugger(String title, String port) {
  final RemoteConnection remoteConnection =
      new RemoteConnection(/* useSockets */ true, "localhost", port, /* serverMode */ false);
  final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
  final String name = title + " debugger (" + port + ")";
  final ConfigurationFactory cfgFactory =
      ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
  RunnerAndConfigurationSettings runSettings =
      RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
  final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
  final ExecutionEnvironment env =
      new ExecutionEnvironmentBuilder(mProject, debugExecutor)
          .runProfile(runSettings.getConfiguration())
          .build();
  final int pollTimeout = 3000;
  final DebugEnvironment environment =
      new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);

  ApplicationManager.getApplication()
      .invokeLater(
          () -> {
            try {
              final DebuggerSession debuggerSession =
                  DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
              if (debuggerSession == null) {
                return;
              }
              XDebuggerManager.getInstance(mProject)
                  .startSessionAndShowTab(
                      name,
                      null,
                      new XDebugProcessStarter() {
                        @Override
                        @NotNull
                        public XDebugProcess start(@NotNull XDebugSession session) {
                          return JavaDebugProcess.create(session, debuggerSession);
                        }
                      });
            } catch (ExecutionException e) {
              LOG.error(
                  "failed to attach to debugger on port "
                      + port
                      + " with polling timeout "
                      + pollTimeout);
            }
          });
}