Java Code Examples for com.intellij.execution.configurations.RunProfileState

The following are top voted examples for showing how to use com.intellij.execution.configurations.RunProfileState. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: mule-intellij-plugins   File: WeaveDebuggerRunner.java   View source code 6 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(final RunProfileState state, final @NotNull ExecutionEnvironment env)
        throws ExecutionException
{

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter()
    {
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException
        {
            WeaveRunnerCommandLine weaveRunnerCommandLine = (WeaveRunnerCommandLine) state;
            final String weaveFile = weaveRunnerCommandLine.getModel().getWeaveFile();
            final Project project = weaveRunnerCommandLine.getEnvironment().getProject();
            final VirtualFile projectFile = project.getBaseDir();
            final String path = project.getBasePath();
            final String relativePath = weaveFile.substring(path.length());
            final VirtualFile fileByRelativePath = projectFile.findFileByRelativePath(relativePath);
            final DebuggerClient localhost = new DebuggerClient(new WeaveDebuggerClientListener(session, fileByRelativePath), new TcpClientDebuggerProtocol("localhost", 6565));
            final ExecutionResult result = state.execute(env.getExecutor(), WeaveDebuggerRunner.this);
            new DebuggerConnector(localhost).start();
            return new WeaveDebugProcess(session, localhost, result);
        }
    }).getRunContentDescriptor();

}
 
Example 2
Project: intellij-ce-playground   File: ExternalSystemTaskDebugRunner.java   View source code 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
  if (state instanceof ExternalSystemRunConfiguration.MyRunnableState) {
    int port = ((ExternalSystemRunConfiguration.MyRunnableState)state).getDebugPort();
    if (port > 0) {
      RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(port), true);
      return attachVirtualMachine(state, environment, connection, true);
    }
    else {
      LOG.warn("Can't attach debugger to external system task execution. Reason: target debug port is unknown");
    }
  }
  else {
    LOG.warn(String.format(
      "Can't attach debugger to external system task execution. Reason: invalid run profile state is provided"
      + "- expected '%s' but got '%s'",
      ExternalSystemRunConfiguration.MyRunnableState.class.getName(), state.getClass().getName()
    ));
  }
  return null;
}
 
Example 3
Project: intellij-ce-playground   File: RemoteExternalSystemCommunicationManager.java   View source code 6 votes vote down vote up
public RemoteExternalSystemCommunicationManager(@NotNull ExternalSystemProgressNotificationManager notificationManager) {
  myProgressManager = (ExternalSystemProgressNotificationManagerImpl)notificationManager;
  mySupport = new RemoteProcessSupport<Object, RemoteExternalSystemFacade, String>(RemoteExternalSystemFacade.class) {
    @Override
    protected void fireModificationCountChanged() {
    }

    @Override
    protected String getName(Object o) {
      return RemoteExternalSystemFacade.class.getName();
    }

    @Override
    protected RunProfileState getRunProfileState(Object o, String configuration, Executor executor) throws ExecutionException {
      return createRunProfileState(configuration);
    }
  };

  ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
    public void run() {
      shutdown(false);
    }
  });
}
 
Example 4
Project: intellij-ce-playground   File: AsyncGenericProgramRunner.java   View source code 6 votes vote down vote up
@Override
protected final void execute(@NotNull final ExecutionEnvironment environment,
                             @Nullable final Callback callback,
                             @NotNull final RunProfileState state) throws ExecutionException {
  prepare(environment, state)
    .done(new Consumer<RunProfileStarter>() {
      @Override
      public void consume(@Nullable final RunProfileStarter result) {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
          @Override
          public void run() {
            if (!environment.getProject().isDisposed()) {
              startRunProfile(environment, state, callback, result);
            }
          }
        });
      }
    });
}
 
Example 5
Project: intellij-ce-playground   File: PyEduDebugRunner.java   View source code 6 votes vote down vote up
@Override
protected void initSession(XDebugSession session, RunProfileState state, Executor executor) {
  XDebugSessionTab tab = ((XDebugSessionImpl)session).getSessionTab();
  if (tab != null) {
    RunnerLayoutUi ui = tab.getUi();
    ContentManager contentManager = ui.getContentManager();
    Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    initEduConsole(session, ui);
  }
}
 
Example 6
Project: intellij-ce-playground   File: PyRerunFailedTestsAction.java   View source code 6 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final AbstractPythonRunConfiguration configuration = ((AbstractPythonRunConfiguration)getPeer());

  // If configuration wants to take care about rerun itself
  if (configuration instanceof TestRunConfigurationReRunResponsible) {
    // TODO: Extract method
    final Set<PsiElement> failedTestElements = new HashSet<PsiElement>();
    for (final AbstractTestProxy proxy : getFailedTests(getProject())) {
      final Location<?> location = proxy.getLocation(getProject(), GlobalSearchScope.allScope(getProject()));
      if (location != null) {
        failedTestElements.add(location.getPsiElement());
      }
    }
    return ((TestRunConfigurationReRunResponsible)configuration).rerunTests(executor, env, failedTestElements);
  }
  return new FailedPythonTestCommandLineStateBase(configuration, env,
                                                  (PythonTestCommandLineStateBase)configuration.getState(executor, env));
}
 
Example 7
Project: intellij-ce-playground   File: RerunFailedActionsTestTools.java   View source code 6 votes vote down vote up
/**
 * Searches for "rerun failed tests" action and fetches state from it
 *
 * @param descriptor previous run descriptor
 * @return state (if found)
 */
@Nullable
public static RunProfileState findRestartActionState(@NotNull final RunContentDescriptor descriptor) {
  final ExecutionEnvironment action = findRestartAction(descriptor);
  if (action == null) {
    return null;
  }
  final Ref<RunProfileState> stateRef = new Ref<RunProfileState>();
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    @Override
    public void run() {
      try {
        stateRef.set(action.getState());
      }
      catch (final ExecutionException e) {
        throw new IllegalStateException("Error obtaining execution state", e);
      }
    }
  }, ModalityState.NON_MODAL);

  return stateRef.get();
}
 
Example 8
Project: intellij-ce-playground   File: AndroidDebugRunner.java   View source code 6 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
  assert state instanceof AndroidRunningState;
  final AndroidRunningState runningState = (AndroidRunningState)state;
  final RunContentDescriptor[] descriptor = {null};

  runningState.addListener(new AndroidRunningStateListener() {
    @Override
    public void executionFailed() {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (descriptor[0] != null) {
            showNotification(environment.getProject(), environment.getExecutor(), descriptor[0], "error", false, NotificationType.ERROR);
          }
        }
      });
    }
  });
  descriptor[0] = doExec(runningState, environment);
  return descriptor[0];
}
 
Example 9
Project: intellij-ce-playground   File: RerunFailedTestsAction.java   View source code 6 votes vote down vote up
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
  //noinspection ConstantConditions
  final JUnitConfiguration configuration = (JUnitConfiguration)myConsoleProperties.getConfiguration();
  final TestMethods testMethods = new TestMethods(configuration, environment, getFailedTests(configuration.getProject()));
  return new MyRunProfile(configuration) {
    @Override
    @NotNull
    public Module[] getModules() {
      return testMethods.getModulesToCompile();
    }

    @Override
    public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
      testMethods.clear();
      return testMethods;
    }
  };
}
 
Example 10
Project: intellij-ce-playground   File: XsltDebuggerRunner.java   View source code 6 votes vote down vote up
protected RunContentDescriptor createContentDescriptor(final RunProfileState runProfileState, final ExecutionEnvironment environment) throws ExecutionException {
  final XDebugSession debugSession =
    XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        ACTIVE.set(Boolean.TRUE);
        try {
          final XsltCommandLineState c = (XsltCommandLineState)runProfileState;
          final ExecutionResult result = runProfileState.execute(environment.getExecutor(), XsltDebuggerRunner.this);
          return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION));
        } finally {
          ACTIVE.remove();
        }
      }
    });
  return debugSession.getRunContentDescriptor();
}
 
Example 11
Project: intellij   File: BlazeAndroidBinaryProgramRunner.java   View source code 6 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(
    final RunProfileState state, final ExecutionEnvironment env) throws ExecutionException {
  RunContentDescriptor descriptor = super.doExecute(state, env);
  if (descriptor != null) {
    ProcessHandler processHandler = descriptor.getProcessHandler();
    assert processHandler != null;

    RunProfile runProfile = env.getRunProfile();
    int uniqueId =
        (runProfile instanceof RunConfigurationBase)
            ? ((RunConfigurationBase) runProfile).getUniqueID()
            : -1;
    AndroidSessionInfo sessionInfo =
        new AndroidSessionInfo(
            processHandler,
            descriptor,
            uniqueId,
            env.getExecutor().getId(),
            env.getExecutor().getActionName(),
            InstantRunUtils.isInstantRunEnabled(env));
    processHandler.putUserData(AndroidSessionInfo.KEY, sessionInfo);
  }

  return descriptor;
}
 
Example 12
Project: robovm-idea   File: RoboVmRunner.java   View source code 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 13
Project: MayaCharm   File: MayaCharmRunner.java   View source code 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull Project project, @NotNull RunProfileState state,
                                         @Nullable RunContentDescriptor contentToReuse, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    final MayaCharmRunProfile configuration = (MayaCharmRunProfile) environment.getRunProfile();
    final MCSettingsProvider settingsProvider = MCSettingsProvider.getInstance(project);
    final MayaCommInterface mayaCommInterface = new MayaCommInterface(settingsProvider.getHost(), settingsProvider.getPort());

    ToolWindow mayaLogWindow = ToolWindowManager.getInstance(project).getToolWindow("Maya Log");
    mayaLogWindow.activate(null, true, true);

    mayaCommInterface.connectMayaLog();

    switch (configuration.getExecutionType()) {
        case CODE:
            mayaCommInterface.sendCodeToMaya(configuration.getScriptCodeText());
            break;
        case FILE:
            mayaCommInterface.sendFileToMaya(configuration.getScriptFilePath());
            break;
    }
    return null;
}
 
Example 14
Project: consulo-unity3d   File: Unity3dTestDebuggerRunner.java   View source code 6 votes vote down vote up
@Override
@RequiredDispatchThread
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException
{
	UnityProcess editorProcess = UnityEditorCommunication.findEditorProcess();
	if(editorProcess == null)
	{
		throw new ExecutionException("Editor is not responding");
	}
	FileDocumentManager.getInstance().saveAllDocuments();

	ExecutionResult executionResult = state.execute(env.getExecutor(), this);
	if(executionResult == null)
	{
		return null;
	}
	return Unity3dAttachRunner.runContentDescriptor(executionResult, env, editorProcess, (ConsoleView) executionResult.getExecutionConsole(), true);
}
 
Example 15
Project: MvnRunner   File: MvnRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public RunProfileState getState(@NotNull Executor executor, final @NotNull ExecutionEnvironment env) throws ExecutionException {
    if (DefaultDebugExecutor.EXECUTOR_ID.equals(executor.getId())) {
        List<String> goals = null;
        if (RunType.Test.equals(runType)) {
            RunnerAndConfigurationSettings settings = env.getRunnerAndConfigurationSettings();
            if (settings != null && settings.getConfiguration() instanceof MvnRunConfiguration) {
                goals = disableFork(((MvnRunConfiguration) settings.getConfiguration()).getGoals());
            }
        }
        if ((RunType.Jetty.equals(runType) || RunType.Tomcat.equals(runType)) || goals != null) {
            return new DebugServerCommandLineState(env, this, goals);
        }
    }
    return super.getState(executor, env);
}
 
Example 16
Project: tools-idea   File: DebuggerPanelsManager.java   View source code 6 votes vote down vote up
@Nullable
public RunContentDescriptor attachVirtualMachine(Executor executor,
                                                 ProgramRunner runner,
                                                 ExecutionEnvironment environment,
                                                 RunProfileState state,
                                                 RunContentDescriptor reuseContent,
                                                 RemoteConnection remoteConnection,
                                                 boolean pollConnection) throws ExecutionException {
  return attachVirtualMachine(new DefaultDebugUIEnvironment(myProject,
                                                          executor,
                                                          runner,
                                                          environment,
                                                          state,
                                                          reuseContent,
                                                          remoteConnection,
                                                          pollConnection));
}
 
Example 17
Project: tools-idea   File: DeployToServerRunConfiguration.java   View source code 6 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  String serverName = getServerName();
  if (serverName == null) {
    throw new ExecutionException("Server is not specified");
  }

  RemoteServer<S> server = RemoteServersManager.getInstance().findByName(serverName, myServerType);
  if (server == null) {
    throw new ExecutionException("Server '" + serverName + " not found");
  }

  if (myDeploymentSource == null) {
    throw new ExecutionException("Deployment is not selected");
  }

  return new DeployToServerState(server, myDeploymentSource, myDeploymentConfiguration, env);
}
 
Example 18
Project: tools-idea   File: ExternalSystemTaskDebugRunner.java   View source code 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(Project project,
                                                       RunProfileState state,
                                                       RunContentDescriptor contentToReuse,
                                                       ExecutionEnvironment env) throws ExecutionException
{
  if (state instanceof ExternalSystemRunConfiguration.MyRunnableState) {
    int port = ((ExternalSystemRunConfiguration.MyRunnableState)state).getDebugPort();
    if (port > 0) {
      RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(port), false);
      return attachVirtualMachine(project, state, contentToReuse, env, connection, true);
    }
    else {
      LOG.warn("Can't attach debugger to external system task execution. Reason: target debug port is unknown");
    }
  }
  else {
    LOG.warn(String.format(
      "Can't attach debugger to external system task execution. Reason: invalid run profile state is provided"
      + "- expected '%s' but got '%s'",
      ExternalSystemRunConfiguration.MyRunnableState.class.getName(), state.getClass().getName()
    ));
  }
  return null;
}
 
Example 19
Project: tools-idea   File: RerunFailedTestsAction.java   View source code 6 votes vote down vote up
@Override
public MyRunProfile getRunProfile() {
  final JUnitConfiguration configuration = (JUnitConfiguration)getModel().getProperties().getConfiguration();
  final TestMethods testMethods = new TestMethods(configuration.getProject(), configuration, myEnvironment, getFailedTests(configuration.getProject()));
  return new MyRunProfile(configuration) {
    @NotNull
    public Module[] getModules() {
      return testMethods.getModulesToCompile();
    }

    public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
      testMethods.clear();
      return testMethods;
    }

    @Override
    public void clear() {
      testMethods.clear();
      super.clear();
    }
  };
}
 
Example 20
Project: tools-idea   File: XsltDebuggerRunner.java   View source code 6 votes vote down vote up
protected RunContentDescriptor createContentDescriptor(Project project,
                                                       final RunProfileState runProfileState,
                                                       RunContentDescriptor contentToReuse,
                                                       final ExecutionEnvironment executionEnvironment) throws ExecutionException {
  final XDebugSession debugSession =
    XDebuggerManager.getInstance(project).startSession(this, executionEnvironment, contentToReuse, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        ACTIVE.set(Boolean.TRUE);
        try {
          final XsltCommandLineState c = (XsltCommandLineState)runProfileState;
          final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XsltDebuggerRunner.this);
          return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION));
        } finally {
          ACTIVE.remove();
        }
      }
    });
  return debugSession.getRunContentDescriptor();
}
 
Example 21
Project: intellij-xquery   File: XQueryDebuggerRunner.java   View source code 6 votes vote down vote up
private XDebugProcessStarter getProcessStarter(final RunProfileState runProfileState, final ExecutionEnvironment
        executionEnvironment) throws ExecutionException {
    int port = getAvailablePort();
    ((XQueryRunProfileState) runProfileState).setPort(port);
    return new XDebugProcessStarter() {
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XQueryDebuggerRunner.this);
            XQueryDebugProcess.XQueryDebuggerIde debuggerIde = new XQueryDebugProcess.XQueryDebuggerIde(session, result.getProcessHandler());
            final DBGpIde dbgpIde = ide().withPort(port).withDebuggerIde(debuggerIde).build();
            dbgpIde.startListening();
            result.getProcessHandler().addProcessListener(new ProcessAdapter() {
                @Override
                public void processTerminated(ProcessEvent event) {
                    dbgpIde.stopListening();
                }
            });
            return new XQueryDebugProcess(session, result, dbgpIde);
        }
    };
}
 
Example 22
Project: consulo-play   File: PlayJavaGenericDebuggerRunner.java   View source code 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws
		ExecutionException
{
	final PlayJavaModuleBasedConfiguration runProfile = (PlayJavaModuleBasedConfiguration) environment.getRunProfile();

	final PropertiesFile applicationConf = PlayJavaUtil.getApplicationConf(runProfile.getConfigurationModule().getModule());
	if(applicationConf == null)
	{
		throw new ExecutionException(PlayJavaConstants.CONF__APPLICATION_CONF + " not found");
	}

	final IProperty propertyByKey = applicationConf.findPropertyByKey(PlayJavaConstants.JPDA_PORT);
	if(propertyByKey == null)
	{
		throw new ExecutionException(PlayJavaConstants.JPDA_PORT + " key not found");
	}

	RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", propertyByKey.getValue(), false);

	return attachVirtualMachine(state, environment, connection, true);
}
 
Example 23
Project: consulo   File: DeployToServerRunConfiguration.java   View source code 6 votes vote down vote up
@javax.annotation.Nullable
@Override
public RunProfileState getState(@Nonnull Executor executor, @Nonnull ExecutionEnvironment env) throws ExecutionException {
  String serverName = getServerName();
  if (serverName == null) {
    throw new ExecutionException("Server is not specified");
  }

  RemoteServer<S> server = RemoteServersManager.getInstance().findByName(serverName, myServerType);
  if (server == null) {
    throw new ExecutionException("Server '" + serverName + " not found");
  }

  if (myDeploymentSource == null) {
    throw new ExecutionException("Deployment is not selected");
  }

  return new DeployToServerState(server, myDeploymentSource, myDeploymentConfiguration, env);
}
 
Example 24
Project: consulo   File: RemoteExternalSystemCommunicationManager.java   View source code 6 votes vote down vote up
public RemoteExternalSystemCommunicationManager(@Nonnull ExternalSystemProgressNotificationManager notificationManager) {
  myProgressManager = (ExternalSystemProgressNotificationManagerImpl)notificationManager;
  mySupport = new RemoteProcessSupport<Object, RemoteExternalSystemFacade, String>(RemoteExternalSystemFacade.class) {
    @Override
    protected void fireModificationCountChanged() {
    }

    @Override
    protected String getName(Object o) {
      return RemoteExternalSystemFacade.class.getName();
    }

    @Override
    protected RunProfileState getRunProfileState(Object o, String configuration, Executor executor) throws ExecutionException {
      return createRunProfileState();
    }
  };

  ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
    public void run() {
      shutdown(false);
    }
  });
}
 
Example 25
Project: consulo-xslt   File: XsltDebuggerRunner.java   View source code 6 votes vote down vote up
protected RunContentDescriptor createContentDescriptor(final RunProfileState runProfileState, final ExecutionEnvironment executionEnvironment) throws ExecutionException
{
	Project project = executionEnvironment.getProject();
	final XDebugSession debugSession = XDebuggerManager.getInstance(project).startSession(executionEnvironment, new XDebugProcessStarter()
	{
		@Override
		@NotNull
		public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException
		{
			ACTIVE.set(Boolean.TRUE);
			try
			{
				final XsltCommandLineState c = (XsltCommandLineState) runProfileState;
				final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XsltDebuggerRunner.this);
				return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION));
			}
			finally
			{
				ACTIVE.remove();
			}
		}
	});
	return debugSession.getRunContentDescriptor();
}
 
Example 26
Project: consulo-java   File: ExternalSystemTaskDebugRunner.java   View source code 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws
		ExecutionException
{
	if(state instanceof ExternalSystemRunConfiguration.MyRunnableState)
	{
		int port = ((ExternalSystemRunConfiguration.MyRunnableState) state).getDebugPort();
		if(port > 0)
		{
			RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(port), true);
			return attachVirtualMachine(state, environment, connection, true);
		}
		else
		{
			LOG.warn("Can't attach debugger to external system task execution. Reason: target debug port is unknown");
		}
	}
	else
	{
		LOG.warn(String.format("Can't attach debugger to external system task execution. Reason: invalid run profile state is provided" + "- " +
				"expected '%s' but got '%s'", ExternalSystemRunConfiguration.MyRunnableState.class.getName(), state.getClass().getName()));
	}
	return null;
}
 
Example 27
Project: consulo-java   File: JavaExecutionUtil.java   View source code 6 votes vote down vote up
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException
{
	final JavaCommandLineState state = new JavaCommandLineState(env)
	{
		@Override
		protected OwnJavaParameters createJavaParameters()
		{
			return myParameters;
		}
	};
	final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(myProject);
	if(myFilters != null)
	{
		builder.filters(myFilters);
	}
	state.setConsoleBuilder(builder);
	return state;
}
 
Example 28
Project: Goal-Intellij-Plugin   File: GoalDebugConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {


    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            GoalRuntime runtime = GoalRuntime.instance;
            System.out.println("runtime is created");

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters("-cp","-debug", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    GoalDebugConfiguration.this.runFilePath);

            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();
            return new OSProcessHandler(process, line.getCommandLineString());
        }


    };

    return state;
}
 
Example 29
Project: Goal-Intellij-Plugin   File: GoalRunConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor,
                                @NotNull ExecutionEnvironment environment)
        throws ExecutionException {
    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            final GoalRuntime runtime = GoalRuntime.getInstance();

            //TODO: MAke sure that the preferences are used when running goal.
            //final Path preferences = GoalRunConfiguration.this.writePreferences();

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters(
                    "-cp", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    //preferences.toString(),
                    GoalRunConfiguration.this.runFilePath
            );
            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();

            return new OSProcessHandler(process, line.getCommandLineString());
        }
    };

    return state;
}
 
Example 30
Project: lua-for-idea   File: LuaRunner.java   View source code 5 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    ExecutionResult executionResult = state.execute(env.getExecutor(), this);
    if (executionResult == null) return null;

    final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
    return contentBuilder.showRunContent(env.getContentToReuse());
}
 
Example 31
Project: intellij-ce-playground   File: DefaultDebugEnvironment.java   View source code 5 votes vote down vote up
public DefaultDebugEnvironment(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state, RemoteConnection remoteConnection, boolean pollConnection) {
  this.environment = environment;
  this.state = state;
  myRemoteConnection = remoteConnection;
  myPollConnection = pollConnection;

  mySearchScope = SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile());
}
 
Example 32
Project: intellij-ce-playground   File: DebuggerPanelsManager.java   View source code 5 votes vote down vote up
@Nullable
public RunContentDescriptor attachVirtualMachine(@NotNull ExecutionEnvironment environment,
                                                 RunProfileState state,
                                                 RemoteConnection remoteConnection,
                                                 boolean pollConnection) throws ExecutionException {
  return attachVirtualMachine(new DefaultDebugUIEnvironment(environment, state, remoteConnection, pollConnection));
}
 
Example 33
Project: intellij-ce-playground   File: DefaultDebugUIEnvironment.java   View source code 5 votes vote down vote up
public DefaultDebugUIEnvironment(@NotNull ExecutionEnvironment environment,
                                 RunProfileState state,
                                 RemoteConnection remoteConnection,
                                 boolean pollConnection) {
  myExecutionEnvironment = environment;
  myModelEnvironment = new DefaultDebugEnvironment(environment, state, remoteConnection, pollConnection);
}
 
Example 34
Project: intellij-ce-playground   File: DebuggerSession.java   View source code 5 votes vote down vote up
@Override
public void attachException(final RunProfileState state, final ExecutionException exception, final RemoteConnection remoteConnection) {
  DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
    @Override
    public void run() {
      String message = "";
      if (state instanceof RemoteState) {
        message = DebuggerBundle.message("status.connect.failed", DebuggerBundle.getAddressDisplayName(remoteConnection), DebuggerBundle.getTransportName(remoteConnection));
      }
      message += exception.getMessage();
      getContextManager().setState(SESSION_EMPTY_CONTEXT, State.STOPPED, Event.DETACHED, message);
    }
  });
}
 
Example 35
Project: intellij-ce-playground   File: GenericProgramRunner.java   View source code 5 votes vote down vote up
@Deprecated
@Nullable
/**
 * @deprecated to remove in IDEA 16
 */
protected RunContentDescriptor doExecute(@NotNull Project project,
                                         @NotNull RunProfileState state,
                                         @Nullable RunContentDescriptor contentToReuse,
                                         @NotNull ExecutionEnvironment environment) throws ExecutionException {
  throw new AbstractMethodError();
}
 
Example 36
Project: intellij-ce-playground   File: RemoteProcessSupport.java   View source code 5 votes vote down vote up
private void startProcess(Target target, Parameters configuration, @NotNull Pair<Target, Parameters> key) {
  ProgramRunner runner = new DefaultProgramRunner() {
    @Override
    @NotNull
    public String getRunnerId() {
      return "MyRunner";
    }

    @Override
    public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  ProcessHandler processHandler;
  try {
    RunProfileState state = getRunProfileState(target, configuration, executor);
    ExecutionResult result = state.execute(executor, runner);
    //noinspection ConstantConditions
    processHandler = result.getProcessHandler();
  }
  catch (Exception e) {
    dropProcessInfo(key, e instanceof ExecutionException? e.getMessage() : ExceptionUtil.getUserStackTrace(e, LOG), null);
    return;
  }
  processHandler.addProcessListener(getProcessListener(key));
  processHandler.startNotify();
}
 
Example 37
Project: intellij-ce-playground   File: DefaultProgramRunner.java   View source code 5 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();
  ExecutionResult executionResult = state.execute(env.getExecutor(), this);
  if (executionResult == null) {
    return null;
  }
  return new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse());
}
 
Example 38
Project: intellij-ce-playground   File: PythonRunner.java   View source code 5 votes vote down vote up
@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 39
Project: intellij-ce-playground   File: AntRunner.java   View source code 5 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();
  state.execute(environment.getExecutor(), this);
  return null;
}
 
Example 40
Project: intellij   File: BlazeCommandRunConfiguration.java   View source code 5 votes vote down vote up
@Override
@Nullable
public RunProfileState getState(Executor executor, ExecutionEnvironment environment)
    throws ExecutionException {
  BlazeCommandRunConfigurationRunner runner = handler.createRunner(executor, environment);
  if (runner != null) {
    environment.putCopyableUserData(BlazeCommandRunConfigurationRunner.RUNNER_KEY, runner);
    return runner.getRunProfileState(executor, environment);
  }
  return null;
}