Java Code Examples for com.intellij.execution.runners.ExecutionEnvironment.getRunProfile()

The following are Jave code examples for showing how to use getRunProfile() of the com.intellij.execution.runners.ExecutionEnvironment class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: PyDebugRunner.java   Source Code and License Vote up 6 votes
protected XDebugSession createSession(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment)
  throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  final PythonCommandLineState pyState = (PythonCommandLineState)state;
  final ServerSocket serverSocket = PythonCommandLineState.createServerSocket();
  final int serverLocalPort = serverSocket.getLocalPort();
  RunProfile profile = environment.getRunProfile();
  final ExecutionResult result =
    pyState.execute(environment.getExecutor(), createCommandLinePatchers(environment.getProject(), pyState, profile, serverLocalPort));

  return XDebuggerManager.getInstance(environment.getProject()).
    startSession(environment, new XDebugProcessStarter() {
      @Override
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) {
        PyDebugProcess pyDebugProcess =
          createDebugProcess(session, serverSocket, result, pyState);

        createConsoleCommunicationAndSetupActions(environment.getProject(), result, pyDebugProcess, session);
        return pyDebugProcess;
      }
    });
}
 
Example 2
Project: intellij   File: BlazeHotSwapManager.java   Source Code and License Vote up 6 votes
@Nullable
static HotSwappableDebugSession findHotSwappableBlazeDebuggerSession(Project project) {
  DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
  DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
  if (session == null || !session.isAttached()) {
    return null;
  }
  JavaDebugProcess process = session.getProcess().getXdebugProcess();
  if (process == null) {
    return null;
  }
  ExecutionEnvironment env = ((XDebugSessionImpl) process.getSession()).getExecutionEnvironment();
  if (env == null || ClassFileManifestBuilder.getManifest(env) == null) {
    return null;
  }
  RunProfile runProfile = env.getRunProfile();
  if (!(runProfile instanceof BlazeCommandRunConfiguration)) {
    return null;
  }
  return new HotSwappableDebugSession(session, env, (BlazeCommandRunConfiguration) runProfile);
}
 
Example 3
Project: intellij-nette-tester   File: TesterExecutionUtil.java   Source Code and License Vote up 5 votes
public static ConsoleView createConsole(Project project, ProcessHandler processHandler, ExecutionEnvironment executionEnvironment, TesterTestLocator locationProvider) {
    TesterRunConfiguration profile = (TesterRunConfiguration) executionEnvironment.getRunProfile();

    TesterConsoleProperties properties = new TesterConsoleProperties(profile, executionEnvironment.getExecutor(), locationProvider);
    properties.addStackTraceFilter(new XdebugCallStackFilter(project, locationProvider.getPathMapper()));

    BaseTestsOutputConsoleView testsOutputConsoleView = SMTestRunnerConnectionUtil.createConsole("Nette Tester", properties);
    testsOutputConsoleView.addMessageFilter(new TesterStackTraceFilter(project, locationProvider.getPathMapper()));
    testsOutputConsoleView.attachToProcess(processHandler);
    Disposer.register(project, testsOutputConsoleView);
    return testsOutputConsoleView;
}
 
Example 4
Project: intellij-ce-playground   File: JavaDebuggerLauncherImpl.java   Source Code and License Vote up 5 votes
@Override
public void startDebugSession(@NotNull JavaDebugConnectionData info, @NotNull ExecutionEnvironment executionEnvironment, @NotNull RemoteServer<?> server)
  throws ExecutionException {
  final Project project = executionEnvironment.getProject();
  final DebuggerPanelsManager manager = DebuggerPanelsManager.getInstance(project);
  final JavaDebugServerModeHandler serverModeHandler = info.getServerModeHandler();
  boolean serverMode = serverModeHandler != null;
  final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), serverMode);
  DebugEnvironment debugEnvironment = new RemoteServerDebugEnvironment(project, remoteConnection, executionEnvironment.getRunProfile());
  DebugUIEnvironment debugUIEnvironment = new RemoteServerDebugUIEnvironment(debugEnvironment, executionEnvironment);
  RunContentDescriptor debugContentDescriptor = manager.attachVirtualMachine(debugUIEnvironment);
  LOG.assertTrue(debugContentDescriptor != null);
  ProcessHandler processHandler = debugContentDescriptor.getProcessHandler();
  LOG.assertTrue(processHandler != null);
  if (serverMode) {
    serverModeHandler.attachRemote();
    DebuggerManager.getInstance(executionEnvironment.getProject())
      .addDebugProcessListener(processHandler, new DebugProcessAdapter() {
        public void processDetached(DebugProcess process, boolean closedByUser) {
          try {
            serverModeHandler.detachRemote();
          }
          catch (ExecutionException e) {
            LOG.info(e);
          }
        }
      });
  }
}
 
Example 5
Project: intellij-ce-playground   File: XDebuggerTree.java   Source Code and License Vote up 5 votes
public boolean isUnderRemoteDebug() {
  DataContext context = DataManager.getInstance().getDataContext(this);
  ExecutionEnvironment env = LangDataKeys.EXECUTION_ENVIRONMENT.getData(context);
  if (env != null && env.getRunProfile() instanceof RemoteRunProfile) {
    return true;
  }
  return false;
}
 
Example 6
Project: intellij-ce-playground   File: PyEduDebugRunner.java   Source Code and License Vote up 5 votes
@Nullable
private static String getScriptName(PythonCommandLineState pyState) {
  ExecutionEnvironment environment = pyState.getEnvironment();
  if (environment == null) {
    return null;
  }
  RunProfile runProfile = environment.getRunProfile();
  if (runProfile instanceof PythonRunConfiguration) {
    String name = FileUtil.toSystemIndependentName(((PythonRunConfiguration)runProfile).getScriptName());
    return SystemInfo.isWindows ? name.toLowerCase() : name;
  }
  return null;
}
 
Example 7
Project: intellij-ce-playground   File: PythonRunner.java   Source Code and License Vote up 5 votes
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  ExecutionResult executionResult;
  RunProfile profile = env.getRunProfile();
  if (state instanceof PythonCommandLineState && profile instanceof CommandLinePatcher) {
    executionResult = ((PythonCommandLineState)state).execute(env.getExecutor(), (CommandLinePatcher)profile);
  }
  else {
    executionResult = state.execute(env.getExecutor(), this);
  }
  return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse());
}
 
Example 8
Project: intellij   File: BlazeCommandGenericRunConfigurationRunner.java   Source Code and License Vote up 5 votes
private static BlazeCommandRunConfiguration getConfiguration(ExecutionEnvironment environment) {
  RunProfile runProfile = environment.getRunProfile();
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return (BlazeCommandRunConfiguration) runProfile;
}
 
Example 9
Project: intellij   File: ClassFileManifestBuilder.java   Source Code and License Vote up 5 votes
private static BlazeCommandRunConfiguration getConfiguration(ExecutionEnvironment environment) {
  RunProfile runProfile = environment.getRunProfile();
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return (BlazeCommandRunConfiguration) runProfile;
}
 
Example 10
Project: intellij   File: HotSwapUtils.java   Source Code and License Vote up 5 votes
private static BlazeCommandRunConfiguration getConfiguration(ExecutionEnvironment env) {
  RunProfile runProfile = env.getRunProfile();
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return (BlazeCommandRunConfiguration) runProfile;
}
 
Example 11
Project: intellij   File: BlazeCoverageProgramRunner.java   Source Code and License Vote up 5 votes
@Nullable
@Override
protected RunContentDescriptor doExecute(RunProfileState profile, ExecutionEnvironment env)
    throws ExecutionException {
  WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(env.getProject());
  if (root == null) {
    return null;
  }
  RunContentDescriptor result = super.doExecute(profile, env);
  if (result == null) {
    return null;
  }
  // remove any old copy of the coverage data

  // retrieve coverage data and copy locally
  BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) env.getRunProfile();
  BlazeCoverageEnabledConfiguration config =
      (BlazeCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(blazeConfig);

  String coverageFilePath = config.getCoverageFilePath();
  File blazeOutputFile = CoverageUtils.getOutputFile(root);

  ProcessHandler handler = result.getProcessHandler();
  if (handler != null) {
    ProcessHandler wrappedHandler =
        new ProcessHandlerWrapper(
            handler, exitCode -> copyCoverageOutput(blazeOutputFile, coverageFilePath, exitCode));
    CoverageHelper.attachToProcess(blazeConfig, wrappedHandler, env.getRunnerSettings());
  }
  return result;
}
 
Example 12
Project: intellij   File: BlazeJavaRunProfileState.java   Source Code and License Vote up 5 votes
private static BlazeCommandRunConfiguration getConfiguration(ExecutionEnvironment environment) {
  RunProfile runProfile = environment.getRunProfile();
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return (BlazeCommandRunConfiguration) runProfile;
}
 
Example 13
Project: intellij   File: BlazePyRunConfigurationRunner.java   Source Code and License Vote up 5 votes
private static BlazeCommandRunConfiguration getConfiguration(ExecutionEnvironment environment) {
  RunProfile runProfile = environment.getRunProfile();
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return (BlazeCommandRunConfiguration) runProfile;
}
 
Example 14
Project: intellij-ce-playground   File: AutoTestManager.java   Source Code and License Vote up 4 votes
private static boolean equals(@NotNull ExecutionEnvironment env1, @NotNull ExecutionEnvironment env2) {
  return env1.getRunProfile() == env2.getRunProfile() &&
         env1.getRunner() == env2.getRunner() &&
         env1.getExecutor() == env2.getExecutor() &&
         env1.getExecutionTarget() == env2.getExecutionTarget();
}
 
Example 15
Project: intellij-ce-playground   File: ExecutionManagerImpl.java   Source Code and License Vote up 4 votes
@Override
public void compileAndRun(@NotNull final Runnable startRunnable,
                          @NotNull final ExecutionEnvironment environment,
                          @Nullable final RunProfileState state,
                          @Nullable final Runnable onCancelRunnable) {
  long id = environment.getExecutionId();
  if (id == 0) {
    id = environment.assignNewExecutionId();
  }

  RunProfile profile = environment.getRunProfile();
  if (!(profile instanceof RunConfiguration)) {
    startRunnable.run();
    return;
  }

  final RunConfiguration runConfiguration = (RunConfiguration)profile;
  final List<BeforeRunTask> beforeRunTasks = RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(runConfiguration);
  if (beforeRunTasks.isEmpty()) {
    startRunnable.run();
  }
  else {
    DataContext context = environment.getDataContext();
    final DataContext projectContext = context != null ? context : SimpleDataContext.getProjectContext(myProject);
    final long finalId = id;
    final Long executionSessionId = new Long(id);
    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
      /**
       * @noinspection SSBasedInspection
       */
      @Override
      public void run() {
        for (BeforeRunTask task : beforeRunTasks) {
          if (myProject.isDisposed()) {
            return;
          }
          @SuppressWarnings("unchecked")
          BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
          if (provider == null) {
            LOG.warn("Cannot find BeforeRunTaskProvider for id='" + task.getProviderId() + "'");
            continue;
          }
          ExecutionEnvironment taskEnvironment = new ExecutionEnvironmentBuilder(environment).contentToReuse(null).build();
          taskEnvironment.setExecutionId(finalId);
          EXECUTION_SESSION_ID_KEY.set(taskEnvironment, executionSessionId);
          if (!provider.executeTask(projectContext, runConfiguration, taskEnvironment, task)) {
            if (onCancelRunnable != null) {
              SwingUtilities.invokeLater(onCancelRunnable);
            }
            return;
          }
        }

        doRun(environment, startRunnable);
      }
    });
  }
}