Search in sources :

Example 1 with RunConfigurationModule

use of com.intellij.execution.configurations.RunConfigurationModule in project intellij-community by JetBrains.

the class GroovyScriptRunConfigurationProducer method createConfiguration.

@Nullable
private RunnerAndConfigurationSettings createConfiguration(@Nullable final PsiClass aClass) {
    if (aClass == null)
        return null;
    final Project project = aClass.getProject();
    RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).createConfiguration("", getConfigurationFactory());
    final GroovyScriptRunConfiguration configuration = (GroovyScriptRunConfiguration) settings.getConfiguration();
    final PsiFile file = aClass.getContainingFile().getOriginalFile();
    final PsiDirectory dir = file.getContainingDirectory();
    if (dir != null) {
        configuration.setWorkingDirectory(dir.getVirtualFile().getPath());
    }
    final VirtualFile vFile = file.getVirtualFile();
    if (vFile == null)
        return null;
    String path = ScriptFileUtil.getScriptFilePath(vFile);
    configuration.setScriptPath(path);
    RunConfigurationModule module = configuration.getConfigurationModule();
    String name = GroovyRunnerUtil.getConfigurationName(aClass, module);
    configuration.setName(StringUtil.isEmpty(name) ? vFile.getName() : name);
    configuration.setModule(JavaExecutionUtil.findModule(aClass));
    return settings;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with RunConfigurationModule

use of com.intellij.execution.configurations.RunConfigurationModule in project intellij-community by JetBrains.

the class JavaParametersUtil method getClasspathType.

@MagicConstant(valuesFromClass = JavaParameters.class)
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName, final boolean classMustHaveSource) throws CantRunException {
    final Module module = configurationModule.getModule();
    if (module == null)
        throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
    Boolean inProduction = isClassInProductionSources(mainClassName, module);
    if (inProduction == null) {
        if (!classMustHaveSource) {
            return JavaParameters.JDK_AND_CLASSES_AND_TESTS;
        }
        throw CantRunException.classNotFound(mainClassName, module);
    }
    return inProduction ? JavaParameters.JDK_AND_CLASSES : JavaParameters.JDK_AND_CLASSES_AND_TESTS;
}
Also used : Module(com.intellij.openapi.module.Module) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) MagicConstant(org.intellij.lang.annotations.MagicConstant)

Example 3 with RunConfigurationModule

use of com.intellij.execution.configurations.RunConfigurationModule in project intellij-community by JetBrains.

the class JavaParametersUtil method configureModule.

public static void configureModule(final RunConfigurationModule runConfigurationModule, final JavaParameters parameters, @MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType, @Nullable String jreHome) throws CantRunException {
    Module module = runConfigurationModule.getModule();
    if (module == null) {
        throw CantRunException.noModuleConfigured(runConfigurationModule.getModuleName());
    }
    configureModule(module, parameters, classPathType, jreHome);
}
Also used : Module(com.intellij.openapi.module.Module) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule)

Example 4 with RunConfigurationModule

use of com.intellij.execution.configurations.RunConfigurationModule in project intellij-community by JetBrains.

the class TestMethods method createJavaParameters.

@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
    final JavaParameters javaParameters = super.createDefaultJavaParameters();
    final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
    final RunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
    final Project project = configurationModule.getProject();
    final Module module = configurationModule.getModule();
    final GlobalSearchScope searchScope = module != null ? module.getModuleRuntimeScope(true) : GlobalSearchScope.allScope(project);
    addClassesListToJavaParameters(myFailedTests, testInfo -> testInfo != null ? getTestPresentation(testInfo, project, searchScope) : null, data.getPackageName(), true, javaParameters);
    return javaParameters;
}
Also used : Project(com.intellij.openapi.project.Project) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JavaParameters(com.intellij.execution.configurations.JavaParameters) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) Module(com.intellij.openapi.module.Module)

Aggregations

RunConfigurationModule (com.intellij.execution.configurations.RunConfigurationModule)4 Module (com.intellij.openapi.module.Module)3 Project (com.intellij.openapi.project.Project)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 JavaParameters (com.intellij.execution.configurations.JavaParameters)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 MagicConstant (org.intellij.lang.annotations.MagicConstant)1 Nullable (org.jetbrains.annotations.Nullable)1