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

The following are top voted examples for showing how to use com.intellij.execution.configurations.RunProfile. 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: intellij-ce-playground   File: SMTestRunnerResultsForm.java   View source code 6 votes vote down vote up
private void addToHistory(final SMTestProxy.SMRootTestProxy root,
                          TestConsoleProperties consoleProperties,
                          Disposable parentDisposable) {
  final RunProfile configuration = consoleProperties.getConfiguration();
  if (configuration instanceof RunConfiguration && 
      !(consoleProperties instanceof ImportedTestConsoleProperties) &&
      !ApplicationManager.getApplication().isUnitTestMode() &&
      !myDisposed) {
    final MySaveHistoryTask backgroundable = new MySaveHistoryTask(consoleProperties, root, (RunConfiguration)configuration);
    final BackgroundableProcessIndicator processIndicator = new BackgroundableProcessIndicator(backgroundable);
    Disposer.register(parentDisposable, new Disposable() {
      @Override
      public void dispose() {
        processIndicator.cancel();
        backgroundable.dispose();
      }
    });
    Disposer.register(parentDisposable, processIndicator);
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, processIndicator);
  }
}
 
Example 2
Project: intellij-ce-playground   File: ExecutionEnvironment.java   View source code 6 votes vote down vote up
ExecutionEnvironment(@NotNull RunProfile runProfile,
                     @NotNull Executor executor,
                     @NotNull ExecutionTarget target,
                     @NotNull Project project,
                     @Nullable RunnerSettings runnerSettings,
                     @Nullable ConfigurationPerRunnerSettings configurationSettings,
                     @Nullable RunContentDescriptor contentToReuse,
                     @Nullable RunnerAndConfigurationSettings settings,
                     @NotNull ProgramRunner<?> runner) {
  myExecutor = executor;
  myTarget = target;
  myRunProfile = runProfile;
  myRunnerSettings = runnerSettings;
  myConfigurationSettings = configurationSettings;
  myProject = project;
  setContentToReuse(contentToReuse);
  myRunnerAndConfigurationSettings = settings;

  myRunner = runner;
}
 
Example 3
Project: intellij-ce-playground   File: TestConsoleProperties.java   View source code 6 votes vote down vote up
@NotNull
protected GlobalSearchScope initScope() {
  RunProfile configuration = getConfiguration();
  if (!(configuration instanceof ModuleRunProfile)) {
    return GlobalSearchScope.allScope(myProject);
  }

  Module[] modules = ((ModuleRunProfile)configuration).getModules();
  if (modules.length == 0) {
    return GlobalSearchScope.allScope(myProject);
  }

  GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
  for (Module each : modules) {
    scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
  }
  return scope;
}
 
Example 4
Project: intellij-ce-playground   File: TestsUIUtil.java   View source code 6 votes vote down vote up
@Nullable
public static Object getData(final AbstractTestProxy testProxy, final String dataId, final TestFrameworkRunningModel model) {
  final TestConsoleProperties properties = model.getProperties();
  final Project project = properties.getProject();
  if (testProxy == null) return null;
  if (AbstractTestProxy.DATA_KEY.is(dataId)) return testProxy;
  if (CommonDataKeys.NAVIGATABLE.is(dataId)) return getOpenFileDescriptor(testProxy, model);
  if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
    final Location location = testProxy.getLocation(project, properties.getScope());
    if (location != null) {
      final PsiElement element = location.getPsiElement();
      return element.isValid() ? element : null;
    }
    else {
      return null;
    }
  }
  if (Location.DATA_KEY.is(dataId)) return testProxy.getLocation(project, properties.getScope());
  if (RunConfiguration.DATA_KEY.is(dataId)) {
    final RunProfile configuration = properties.getConfiguration();
    if (configuration instanceof RunConfiguration) {
      return configuration;
    }
  }
  return null;
}
 
Example 5
Project: intellij-ce-playground   File: DebuggerSessionTabBase.java   View source code 6 votes vote down vote up
protected void attachNotificationTo(final Content content) {
  if (myConsole instanceof ObservableConsoleView) {
    ObservableConsoleView observable = (ObservableConsoleView)myConsole;
    observable.addChangeListener(new ObservableConsoleView.ChangeListener() {
      @Override
      public void contentAdded(final Collection<ConsoleViewContentType> types) {
        if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
          content.fireAlert();
        }
      }
    }, content);
    RunProfile profile = getRunProfile();
    if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
      observable.addChangeListener(new RunContentBuilder.ConsoleToFrontListener((RunConfigurationBase)profile,
                                                                                myProject,
                                                                                DefaultDebugExecutor.getDebugExecutorInstance(),
                                                                                myRunContentDescriptor,
                                                                                myUi),
                                   content);
    }
  }
}
 
Example 6
Project: intellij-ce-playground   File: LvcsLabeler.java   View source code 6 votes vote down vote up
public void onRunnerStateChanged(final StateEvent event) {
  if (!(event instanceof CompletionEvent)) {
    return;
  }
  final boolean areTestsFailed = myModel.getRoot().isDefect();
  final CompletionEvent completion = (CompletionEvent)event;
  final RunProfile configuration = myModel.getProperties().getConfiguration();
  if (configuration == null) {
    return;
  }
  if (testsTerminatedAndNotFailed(completion, areTestsFailed)) return;

  if (completion.isNormalExit()) {
    LvcsHelper.addLabel(myModel);
  }
}
 
Example 7
Project: intellij-ce-playground   File: AntRunProfileState.java   View source code 6 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
  RunProfile profile = myEnvironment.getRunProfile();
  if (profile instanceof AntRunConfiguration) {
    AntRunConfiguration antRunConfiguration = (AntRunConfiguration)profile;
    AntBuildTarget target = antRunConfiguration.getTarget();
    if (target == null) return null;
    ProcessHandler processHandler = ExecutionHandler
      .executeRunConfiguration(antRunConfiguration, myEnvironment.getDataContext(), new ArrayList<BuildFileProperty>(),
                               new AntBuildListener() {
                                 @Override
                                 public void buildFinished(int state, int errorCount) {

                                 }
                               });
    if (processHandler == null) return null;
    return new DefaultExecutionResult(null, processHandler);
  }
  return null;
}
 
Example 8
Project: intellij-ce-playground   File: GantRunner.java   View source code 6 votes vote down vote up
@Override
public boolean ensureRunnerConfigured(@Nullable Module module, RunProfile profile, Executor executor, final Project project) {
  if (GantUtils.getSDKInstallPath(module, project).isEmpty()) {
    int result = Messages
      .showOkCancelDialog("Gant is not configured. Do you want to configure it?", "Configure Gant SDK",
                          JetgroovyIcons.Groovy.Gant_16x16);
    if (result == Messages.OK) {
      ShowSettingsUtil.getInstance().editConfigurable(project, new GantConfigurable(project));
    }
    if (GantUtils.getSDKInstallPath(module, project).isEmpty()) {
      return false;
    }
  }

  return true;
}
 
Example 9
Project: intellij-ce-playground   File: TrackCoverageAction.java   View source code 6 votes vote down vote up
@Nullable
private CoverageSuitesBundle getCurrentCoverageSuite() {
  if (myModel == null) {
    return null;
  }

  final RunProfile runConf = myModel.getProperties().getConfiguration();
  if (runConf instanceof ModuleBasedConfiguration) {

    // if coverage supported for run configuration
    if (CoverageEnabledConfiguration.isApplicableTo((ModuleBasedConfiguration) runConf)) {

      // Get coverage settings
      Executor executor = myProperties.getExecutor();
      if (executor != null && executor.getId().equals(CoverageExecutor.EXECUTOR_ID)) {
        return CoverageDataManager.getInstance(myProperties.getProject()).getCurrentSuitesBundle();
      }
    }
  }
  return null;
}
 
Example 10
Project: intellij   File: BlazeAndroidBinaryProgramRunner.java   View source code 6 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (handler == null) {
    return false;
  }
  // In practice, the stock runner will probably handle all non-incremental-install configs.
  if (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)
      || DefaultRunExecutor.EXECUTOR_ID.equals(executorId)) {
    return true;
  }
  // Otherwise, the configuration must be a Blaze incremental install configuration running with
  // an incremental install executor.
  if (!(handler instanceof BlazeAndroidBinaryRunConfigurationHandler)) {
    return false;
  }
  AndroidBinaryLaunchMethod launchMethod =
      ((BlazeAndroidBinaryRunConfigurationHandler) handler).getState().getLaunchMethod();
  return (AndroidBinaryLaunchMethod.MOBILE_INSTALL.equals(launchMethod)
          || AndroidBinaryLaunchMethod.MOBILE_INSTALL_V2.equals(launchMethod))
      && (IncrementalInstallDebugExecutor.EXECUTOR_ID.equals(executorId)
          || IncrementalInstallRunExecutor.EXECUTOR_ID.equals(executorId));
}
 
Example 11
Project: intellij   File: CoverageUtils.java   View source code 6 votes vote down vote up
public static boolean isApplicableTo(RunProfile runProfile) {
  BlazeCommandRunConfiguration config = toBlazeConfig(runProfile);
  if (config == null) {
    return false;
  }
  if (Blaze.getBuildSystem(config.getProject()) != BuildSystem.Blaze) {
    // temporarily disable coverage for Bazel, until we properly interface with its API and output
    // file locations
    return false;
  }
  BlazeCommandRunConfigurationCommonState handlerState =
      config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  if (handlerState == null) {
    return false;
  }
  BlazeCommandName command = handlerState.getCommandState().getCommand();
  return BlazeCommandName.TEST.equals(command) || BlazeCommandName.COVERAGE.equals(command);
}
 
Example 12
Project: intellij   File: BlazeHotSwapManager.java   View source code 6 votes vote down vote up
@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 13
Project: google-cloud-intellij   File: CloudDebugProcessStateCollector.java   View source code 6 votes vote down vote up
/** Get all the background snapshot states. */
public List<CloudDebugProcessState> getBackgroundListeningStates() {
  List<CloudDebugProcessState> states = new ArrayList<CloudDebugProcessState>();

  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    Set<RunProfile> runningProfiles = getProfilesWithActiveDebugSession(project);

    RunManager manager = RunManager.getInstance(project);

    // find all CloudDebugRunConfiguration that do not have active debug sessions but are
    // listening in the background
    for (final RunnerAndConfigurationSettings config : manager.getAllSettings()) {
      if (notRunningConfiguration(runningProfiles, config.getConfiguration())) {
        if (config.getConfiguration() instanceof CloudDebugRunConfiguration) {
          final CloudDebugRunConfiguration cloudConfig =
              (CloudDebugRunConfiguration) config.getConfiguration();
          CloudDebugProcessState state = cloudConfig.getProcessState();
          if (listensInBackground(state)) {
            states.add(state);
          }
        }
      }
    }
  }
  return states;
}
 
Example 14
Project: google-cloud-intellij   File: CloudDebugProcess.java   View source code 6 votes vote down vote up
@Override
public void stop() {
  getStateController().stopBackgroundListening();

  RunProfile profile = getXDebugSession().getRunProfile();
  if (profile instanceof CloudDebugRunConfiguration) {
    ((CloudDebugRunConfiguration) profile).setProcessState(processState);
  }

  getRepositoryValidator().restoreToOriginalState(getXDebugSession().getProject());

  XBreakpointManager breakpointManager =
      XDebuggerManager.getInstance(getXDebugSession().getProject()).getBreakpointManager();
  for (XBreakpoint bp : breakpointManager.getAllBreakpoints()) {
    com.intellij.debugger.ui.breakpoints.Breakpoint cloudBreakpoint =
        BreakpointManager.getJavaBreakpoint(bp);
    if (!(cloudBreakpoint instanceof CloudLineBreakpointType.CloudLineBreakpoint)) {
      continue;
    }
    CloudLineBreakpointType.CloudLineBreakpoint cloudLineBreakpoint =
        (CloudLineBreakpointType.CloudLineBreakpoint) cloudBreakpoint;
    cloudLineBreakpoint.setVerified(false);
    cloudLineBreakpoint.setErrorMessage(null);
    updateBreakpointPresentation(cloudLineBreakpoint);
  }
}
 
Example 15
Project: google-cloud-intellij   File: CloudDebugProcessStateCollectorTest.java   View source code 6 votes vote down vote up
@Test
public void testGetProfilesWithActiveDebugSession_returnsNotStoppedSessionsWithRunProfile() {
  Project project = mock(Project.class);

  XDebugSession notStoppedSession =
      createMockSession(false, mock(CloudDebugRunConfiguration.class));
  XDebugSession stoppedSession = createMockSession(true, mock(CloudDebugRunConfiguration.class));
  XDebugSession stoppedSessionWithoutRunProfile = createMockSession(true, null);

  createMockXDebuggerManager(
      project,
      new XDebugSession[] {notStoppedSession, stoppedSession, stoppedSessionWithoutRunProfile});

  Set<RunProfile> profiles =
      new CloudDebugProcessStateCollector().getProfilesWithActiveDebugSession(project);

  assertNotNull(profiles);
  assertThat(profiles).hasSize(1);
}
 
Example 16
Project: tools-idea   File: DebuggerSessionTabBase.java   View source code 6 votes vote down vote up
protected void attachNotificationTo(final Content content) {
  if (myConsole instanceof ObservableConsoleView) {
    ObservableConsoleView observable = (ObservableConsoleView)myConsole;
    observable.addChangeListener(new ObservableConsoleView.ChangeListener() {
      @Override
      public void contentAdded(final Collection<ConsoleViewContentType> types) {
        if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
          content.fireAlert();
        }
      }
    }, content);
    RunProfile profile = getRunProfile();
    if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
      final RunConfigurationBase runConfigurationBase = (RunConfigurationBase)profile;
      observable.addChangeListener(new RunContentBuilder.ConsoleToFrontListener(runConfigurationBase,
                                                                                getProject(),
                                                                                DefaultDebugExecutor.getDebugExecutorInstance(),
                                                                                myRunContentDescriptor,
                                                                                getUi()),
                                   content);
    }
  }
}
 
Example 17
Project: tools-idea   File: RunContentBuilder.java   View source code 6 votes vote down vote up
@NotNull
public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) {
  Module[] modules = null;
  if (runProfile instanceof ModuleRunProfile) {
    modules = ((ModuleRunProfile)runProfile).getModules();
  }
  if (modules == null || modules.length == 0) {
    return GlobalSearchScope.allScope(project);
  }
  else {
    GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(modules[0], true);
    for (int idx = 1; idx < modules.length; idx++) {
      Module module = modules[idx];
      scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(module, true));
    }
    return scope;
  }
}
 
Example 18
Project: tools-idea   File: GantRunner.java   View source code 6 votes vote down vote up
@Override
public boolean ensureRunnerConfigured(@Nullable Module module, RunProfile profile, Executor executor, final Project project) {
  if (!(GantUtils.getSDKInstallPath(module, project).length() > 0)) {
    int result = Messages
      .showOkCancelDialog("Gant is not configured. Do you want to configure it?", "Configure Gant SDK",
                          JetgroovyIcons.Groovy.Gant_16x16);
    if (result == 0) {
      ShowSettingsUtil.getInstance().editConfigurable(project, new GantConfigurable(project));
    }
    if (!(GantUtils.getSDKInstallPath(module, project).length() > 0)) {
      return false;
    }
  }

  return true;
}
 
Example 19
Project: jacoco-coverage   File: JaCoCoCoveragePatcher.java   View source code 6 votes vote down vote up
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
    if (!executor.getId().equals(DefaultRunExecutor.EXECUTOR_ID)) {
        return;
    }

    if ((configuration instanceof RunConfiguration)) {
        if (!isTestConfiguration(configuration)) {
            return;
        }

        RunConfiguration runConfiguration = (RunConfiguration) configuration;

        CoverageConfig instance = CoverageConfig.getInstance(runConfiguration.getProject());
        if (instance != null && instance.getState() != null && instance.getState().isEnabled) {
            javaParameters.getVMParametersList().add(computeJaCoCoParams(runConfiguration));
        }
    }
}
 
Example 20
Project: consulo-dotnet   File: DotNetCoverageProgramRunner.java   View source code 6 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile)
{
	if(!CoverageExecutor.EXECUTOR_ID.equals(executorId))
	{
		return false;
	}

	if(!(profile instanceof DotNetConfigurationWithCoverage))
	{
		return false;
	}
	CoverageEnabledConfiguration coverageEnabledConfiguration = DotNetCoverageEnabledConfiguration.getOrCreate((RunConfigurationBase) profile);
	CoverageRunner coverageRunner = coverageEnabledConfiguration.getCoverageRunner();
	if(coverageRunner == null || !coverageEnabledConfiguration.isCoverageEnabled())
	{
		return false;
	}

	if(!DotNetCoverageRunner.findAvailableRunners(profile).contains(coverageRunner))
	{
		return false;
	}
	return true;
}
 
Example 21
Project: consulo   File: SMTestRunnerResultsForm.java   View source code 6 votes vote down vote up
private void addToHistory(final SMTestProxy.SMRootTestProxy root, TestConsoleProperties consoleProperties, Disposable parentDisposable) {
  final RunProfile configuration = consoleProperties.getConfiguration();
  if (configuration instanceof RunConfiguration &&
      !(consoleProperties instanceof ImportedTestConsoleProperties) &&
      !ApplicationManager.getApplication().isUnitTestMode() &&
      !myDisposed) {
    final MySaveHistoryTask backgroundable = new MySaveHistoryTask(consoleProperties, root, (RunConfiguration)configuration);
    final BackgroundableProcessIndicator processIndicator = new BackgroundableProcessIndicator(backgroundable);
    Disposer.register(parentDisposable, new Disposable() {
      @Override
      public void dispose() {
        processIndicator.cancel();
        backgroundable.dispose();
      }
    });
    Disposer.register(parentDisposable, processIndicator);
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, processIndicator);
  }
}
 
Example 22
Project: consulo   File: TestConsoleProperties.java   View source code 6 votes vote down vote up
@Nonnull
protected GlobalSearchScope initScope() {
  RunProfile configuration = getConfiguration();
  if (!(configuration instanceof ModuleRunProfile)) {
    return GlobalSearchScope.allScope(myProject);
  }

  Module[] modules = ((ModuleRunProfile)configuration).getModules();
  if (modules.length == 0) {
    return GlobalSearchScope.allScope(myProject);
  }

  GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
  for (Module each : modules) {
    scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
  }
  return scope;
}
 
Example 23
Project: consulo   File: TrackCoverageAction.java   View source code 6 votes vote down vote up
@javax.annotation.Nullable
private CoverageSuitesBundle getCurrentCoverageSuite() {
  if (myModel == null) {
    return null;
  }

  final RunProfile runConf = myModel.getProperties().getConfiguration();
  if (runConf instanceof ModuleBasedConfiguration) {

    // if coverage supported for run configuration
    if (CoverageEnabledConfiguration.isApplicableTo((ModuleBasedConfiguration) runConf)) {

      // Get coverage settings
      Executor executor = myProperties.getExecutor();
      if (executor != null && executor.getId().equals(CoverageExecutor.EXECUTOR_ID)) {
        return CoverageDataManager.getInstance(myProperties.getProject()).getCurrentSuitesBundle();
      }
    }
  }
  return null;
}
 
Example 24
Project: consulo   File: ExecutionEnvironment.java   View source code 6 votes vote down vote up
ExecutionEnvironment(@Nonnull RunProfile runProfile,
                     @Nonnull Executor executor,
                     @Nonnull ExecutionTarget target,
                     @Nonnull Project project,
                     @Nullable RunnerSettings runnerSettings,
                     @Nullable ConfigurationPerRunnerSettings configurationSettings,
                     @Nullable RunContentDescriptor contentToReuse,
                     @Nullable RunnerAndConfigurationSettings settings,
                     @Nonnull ProgramRunner<?> runner) {
  myExecutor = executor;
  myTarget = target;
  myRunProfile = runProfile;
  myRunnerSettings = runnerSettings;
  myConfigurationSettings = configurationSettings;
  myProject = project;
  setContentToReuse(contentToReuse);
  myRunnerAndConfigurationSettings = settings;

  myRunner = runner;
}
 
Example 25
Project: consulo   File: DebuggerSessionTabBase.java   View source code 6 votes vote down vote up
protected void attachNotificationTo(final Content content) {
  if (myConsole instanceof ObservableConsoleView) {
    ObservableConsoleView observable = (ObservableConsoleView)myConsole;
    observable.addChangeListener(types -> {
      if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
        content.fireAlert();
      }
    }, content);
    RunProfile profile = getRunProfile();
    if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
      observable.addChangeListener(
              new RunContentBuilder.ConsoleToFrontListener((RunConfigurationBase)profile, myProject, DefaultDebugExecutor.getDebugExecutorInstance(),
                                                           myRunContentDescriptor, myUi), content);
    }
  }
}
 
Example 26
Project: consulo-java   File: DefaultDebugEnvironment.java   View source code 6 votes vote down vote up
private static GlobalSearchScope createSearchScope(@NotNull Project project, @Nullable RunProfile runProfile)
{
	GlobalSearchScope scope = SearchScopeProvider.createSearchScope(project, runProfile);
	if(scope.equals(GlobalSearchScope.allScope(project)))
	{
		// prefer sources over class files
		return new DelegatingGlobalSearchScope(scope)
		{
			final ProjectFileIndex myProjectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
			final Comparator<VirtualFile> myScopeComparator = Comparator.comparing(myProjectFileIndex::isInSource).thenComparing(myProjectFileIndex::isInLibrarySource).thenComparing
					(super::compare);

			@Override
			public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2)
			{
				return myScopeComparator.compare(file1, file2);
			}
		};
	}
	return scope;
}
 
Example 27
Project: lua-for-idea   File: LuaDebuggerController.java   View source code 5 votes vote down vote up
private String getWorkingDir() {

        String workingDir = null;
        RunProfile profile = this.session.getRunProfile();

        if (profile != null && profile instanceof LuaRunConfiguration) {
            workingDir = ((LuaRunConfiguration) profile).getWorkingDirectory();
        }
        if(StringUtil.isEmpty(workingDir)) {
            workingDir = myProject.getBaseDir().getPath();
        }
        if(!workingDir.endsWith("/")) workingDir += "/";

        return workingDir;
    }
 
Example 28
Project: tomcat-runner   File: TomcatProgramRunner.java   View source code 5 votes vote down vote up
@Override
public boolean canRun(@NotNull String value, @NotNull RunProfile runProfile) {
    // It can only run TomcatRunnerConfigurations
    if(!(runProfile instanceof TomcatRunnerConfiguration)){
        return false;
    }
    // Values passed are: Run or Debug
    if(!RUN.equals(value)) {
        // Fallback on the TomcatProgramDebugger
        return false;
    }
    return true;
}
 
Example 29
Project: intellij-ce-playground   File: JavaPatchableProgramRunner.java   View source code 5 votes vote down vote up
protected static void runCustomPatchers(JavaParameters javaParameters,
                                        Executor executor,
                                        RunProfile runProfile) {
  if (runProfile != null) {
    for (JavaProgramPatcher patcher : JavaProgramPatcher.EP_NAME.getExtensions()) {
      patcher.patchJavaParameters(executor, runProfile, javaParameters);
    }
  }
}
 
Example 30
Project: intellij-ce-playground   File: DeployToServerRunner.java   View source code 5 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
  if (!(profile instanceof DeployToServerRunConfiguration)) {
    return false;
  }
  if (executorId.equals(DefaultRunExecutor.EXECUTOR_ID)) {
    return true;
  }
  if (executorId.equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    return ((DeployToServerRunConfiguration<?, ?>)profile).getServerType().createDebugConnector() != null;
  }
  return false;
}
 
Example 31
Project: intellij-ce-playground   File: SMTRunnerConsoleProperties.java   View source code 5 votes vote down vote up
public SMTRunnerConsoleProperties(@NotNull Project project, 
                                  @NotNull RunProfile config,
                                  @NotNull String testFrameworkName, 
                                  @NotNull Executor executor) {
  super(getStorage(testFrameworkName), project, executor);
  myConfiguration = config;
  myTestFrameworkName = testFrameworkName;
  myCustomFilter = new CompositeFilter(project);
}
 
Example 32
Project: intellij-ce-playground   File: ImportedTestRunnableState.java   View source code 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
  final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
  final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
  RunProfile configuration;
  final String frameworkName;
  if (properties != null) {
    configuration = properties.getConfiguration();
    frameworkName = properties.getTestFrameworkName();
  }
  else {
    configuration = myRunProfile;
    frameworkName = "Import Test Results";
  }
  final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(),
                                                                                            configuration, frameworkName, executor);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(), 
                                                                                      consoleProperties);
  final JComponent component = console.getComponent();
  AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
  if (component instanceof TestFrameworkRunningModel) {
    rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
    if (rerunFailedTestsAction != null) {
      rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
        @Override
        public TestFrameworkRunningModel get() {
          return (TestFrameworkRunningModel)component;
        }
      });
    }
  }
  
  console.attachToProcess(handler);
  final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
  if (rerunFailedTestsAction != null) {
    result.setRestartActions(rerunFailedTestsAction);
  }
  return result;
}
 
Example 33
Project: intellij-ce-playground   File: ImportedTestConsoleProperties.java   View source code 5 votes vote down vote up
public ImportedTestConsoleProperties(@Nullable SMTRunnerConsoleProperties properties,
                                     File file,
                                     ProcessHandler handler,
                                     Project project, RunProfile runConfiguration,
                                     String frameworkName,
                                     Executor executor) {
  super(project, runConfiguration, frameworkName, executor);
  myProperties = properties;
  myFile = file;
  myHandler = handler;
}
 
Example 34
Project: intellij-ce-playground   File: RunContentDescriptor.java   View source code 5 votes vote down vote up
public RunContentDescriptor(@NotNull RunProfile profile, @NotNull ExecutionResult executionResult, @NotNull RunnerLayoutUi ui) {
  this(executionResult.getExecutionConsole(),
       executionResult.getProcessHandler(),
       ui.getComponent(),
       profile.getName(),
       profile.getIcon(),
       null,
       executionResult instanceof DefaultExecutionResult ? ((DefaultExecutionResult)executionResult).getRestartActions() : null);
  myRunnerLayoutUi = ui;
}
 
Example 35
Project: intellij-ce-playground   File: ExecutionEnvironmentBuilder.java   View source code 5 votes vote down vote up
@NotNull
public static ExecutionEnvironmentBuilder create(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) throws ExecutionException {
  ExecutionEnvironmentBuilder builder = createOrNull(project, executor, runProfile);
  if (builder == null) {
    throw new ExecutionException("Cannot find runner for " + runProfile.getName());
  }
  return builder;
}
 
Example 36
Project: intellij-ce-playground   File: ExecutionEnvironmentBuilder.java   View source code 5 votes vote down vote up
@Nullable
public static ExecutionEnvironmentBuilder createOrNull(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) {
  ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile);
  if (runner == null) {
    return null;
  }
  return new ExecutionEnvironmentBuilder(project, executor).runner(runner).runProfile(runProfile);
}
 
Example 37
Project: intellij-ce-playground   File: XDebugSessionImpl.java   View source code 5 votes vote down vote up
private String getWatchesKey() {
  if (myEnvironment != null) {
    RunProfile profile = myEnvironment.getRunProfile();
    if (profile instanceof RunConfiguration) {
      return ((RunConfiguration)profile).getType().getId();
    }
  }
  return getSessionName();
}
 
Example 38
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 39
Project: intellij-ce-playground   File: RunnerRegistryImpl.java   View source code 5 votes vote down vote up
@Override
public ProgramRunner getRunner(@NotNull String executorId, @Nullable RunProfile settings) {
  if (settings == null) {
    return null;
  }

  for (ProgramRunner runner : ProgramRunner.PROGRAM_RUNNER_EP.getExtensions()) {
    if (runner.canRun(executorId, settings)) {
      return runner;
    }
  }
  return null;
}
 
Example 40
Project: intellij-ce-playground   File: RunContentBuilder.java   View source code 5 votes vote down vote up
@NotNull
private RunContentDescriptor createDescriptor() {
  final RunProfile profile = myEnvironment.getRunProfile();
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return new RunContentDescriptor(profile, myExecutionResult, myUi);
  }

  final ExecutionConsole console = myExecutionResult.getExecutionConsole();
  RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
  if (console != null) {
    if (console instanceof ExecutionConsoleEx) {
      ((ExecutionConsoleEx)console).buildUi(myUi);
    }
    else {
      buildConsoleUiDefault(myUi, console);
    }
    initLogConsoles(profile, contentDescriptor, console);
  }
  myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor), ActionPlaces.UNKNOWN);

  if (profile instanceof RunConfigurationBase) {
    if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
      ((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile,
                                                                                    myProject,
                                                                                    myEnvironment.getExecutor(),
                                                                                    contentDescriptor,
                                                                                    myUi),
                                                         this);
    }
  }

  return contentDescriptor;
}