com.intellij.execution.JavaExecutionUtil Java Examples

The following examples show how to use com.intellij.execution.JavaExecutionUtil. 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: ProjectExecutor.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void executeConfiguration(Project project, ModuleBasedConfiguration appCon) {
    if (noProjectsAreOpen()) {
        logger.warn("No open projects found, can't execute the project.");
        return;
    }
    logger.info("Starting to build execution environment.");
    RunManager runManager = RunManager.getInstance(project);
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    RunnerAndConfigurationSettingsImpl selectedConfiguration =
            getApplicationRunnerAndConfigurationSettings(runManager, appCon);
    ProgramRunner runner = getRunner(executor, selectedConfiguration);
    logger.info("Creating ExecutionEnvironment.");
    ExecutionEnvironment environment =
            new ExecutionEnvironment(
                    new DefaultRunExecutor(), runner, selectedConfiguration, project);
    try {
        logger.info("Executing project.");
        runner.execute(environment);
    } catch (ExecutionException e1) {
        JavaExecutionUtil.showExecutionErrorMessage(e1, "Error", project);
    }
}
 
Example #2
Source File: JavaBinaryContextProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private static PsiClass getMainClass(ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  PsiElement element = location.getPsiElement();
  if (!element.isPhysical()) {
    return null;
  }
  return ApplicationConfigurationType.getMainClass(element);
}
 
Example #3
Source File: ScalaBinaryContextProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
static ScObject getMainObject(ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(context.getLocation());
  if (location == null) {
    return null;
  }
  PsiElement element = location.getPsiElement();
  if (!(element.getContainingFile() instanceof ScalaFile)) {
    return null;
  }
  if (!element.isPhysical()) {
    return null;
  }
  return getMainObjectFromElement(element);
}
 
Example #4
Source File: ScalaTestContextProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private static ScClass getTestClass(ConfigurationContext context) {
  Location<?> location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
    // handled by a different producer
    return null;
  }
  return getTestClass(location);
}
 
Example #5
Source File: BlazeAndroidTestRunConfigurationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public String suggestedName(BlazeCommandRunConfiguration configuration) {
  Label target = getLabel();
  if (target == null) {
    return null;
  }
  BlazeConfigurationNameBuilder nameBuilder =
      new BlazeConfigurationNameBuilder(this.configuration);

  boolean isClassTest =
      configState.getTestingType() == BlazeAndroidTestRunConfigurationState.TEST_CLASS;
  boolean isMethodTest =
      configState.getTestingType() == BlazeAndroidTestRunConfigurationState.TEST_METHOD;
  if ((isClassTest || isMethodTest) && configState.getClassName() != null) {
    // Get the class name without the package.
    String className = JavaExecutionUtil.getPresentableClassName(configState.getClassName());
    if (className != null) {
      String targetString = className;
      if (isMethodTest) {
        targetString += "#" + configState.getMethodName();
      }

      if (getState().getLaunchMethod().equals(AndroidTestLaunchMethod.NON_BLAZE)) {
        return targetString;
      } else {
        return nameBuilder.setTargetString(targetString).build();
      }
    }
  }
  return nameBuilder.build();
}
 
Example #6
Source File: JavaTestContextProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private static PsiClass getSelectedTestClass(ConfigurationContext context) {
  Location<?> location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  if (JUnitConfigurationUtil.isMultipleElementsSelected(context)) {
    return null;
  }
  return ProducerUtils.getTestClass(location);
}
 
Example #7
Source File: RunConfigurationEditor.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * When you click the apply button
 * @param configuration
 * @throws ConfigurationException
 */
@Override
protected void applyEditorTo(EmbeddedLinuxJVMRunConfiguration configuration) throws ConfigurationException {
    final String className = getMainClassField().getText();
    final PsiClass aClass = myModuleSelector.findClass(className);

    configuration.getRunnerParameters().setMainclass(aClass != null ? JavaExecutionUtil.getRuntimeQualifiedName(aClass) : className);

    setSettings(configuration.getRunnerParameters());
}