use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class ConfigurationsTest method testCreateFromContext.
@Test
public void testCreateFromContext() {
final Project project = myProjectFixture.getProject();
final PsiClass psiClass = findTestClass(project);
final TestNGInClassConfigurationProducer producer = new TestNGInClassConfigurationProducer();
final MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.PROJECT, project);
dataContext.put(LangDataKeys.MODULE, ModuleUtil.findModuleForPsiElement(psiClass));
dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass));
final ConfigurationFromContext fromContext = producer.createConfigurationFromContext(ConfigurationContext.getFromContext(dataContext));
assert fromContext != null;
final RunnerAndConfigurationSettings config = fromContext.getConfigurationSettings();
final RunConfiguration runConfiguration = config.getConfiguration();
Assert.assertTrue(runConfiguration instanceof TestNGConfiguration);
TestNGConfigurationType t = (TestNGConfigurationType) runConfiguration.getType();
Assert.assertTrue(t.isConfigurationByLocation(runConfiguration, new PsiLocation(project, psiClass)));
}
use of com.intellij.execution.RunnerAndConfigurationSettings 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;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class AbstractTestNGSuiteConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
final PsiFile containingFile = element != null ? element.getContainingFile() : null;
if (containingFile == null)
return false;
final VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile == null || !virtualFile.isValid())
return false;
if (!TestNGUtil.isTestngXML(virtualFile))
return false;
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context);
setupConfigurationModule(context, configuration);
final Module originalModule = configuration.getConfigurationModule().getModule();
configuration.getPersistantData().SUITE_NAME = virtualFile.getPath();
configuration.getPersistantData().TEST_OBJECT = TestType.SUITE.getType();
configuration.restoreOriginalModule(originalModule);
configuration.setGeneratedName();
settings.setName(configuration.getName());
sourceElement.set(containingFile);
return true;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class PyRunConfigurationFactoryImpl method createPythonScriptRunConfiguration.
@Override
public PythonRunConfigurationParams createPythonScriptRunConfiguration(Module module, String scriptName, boolean singleton) {
RunnerAndConfigurationSettings settings = createRunConfiguration(module, PythonConfigurationType.getInstance().getFactory());
settings.setSingleton(singleton);
PythonRunConfigurationParams configuration = (PythonRunConfigurationParams) settings.getConfiguration();
configuration.setScriptName(scriptName);
return configuration;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class DocutilsConfigurationProducer method findExistingByElement.
@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location, @NotNull List<RunnerAndConfigurationSettings> existingConfigurations, ConfigurationContext context) {
PsiFile script = location.getPsiElement().getContainingFile();
if (script == null) {
return null;
}
final VirtualFile vFile = script.getVirtualFile();
if (vFile == null) {
return null;
}
String path = vFile.getPath();
for (RunnerAndConfigurationSettings configuration : existingConfigurations) {
final String scriptName = ((RestRunConfiguration) configuration.getConfiguration()).getInputFile();
if (FileUtil.toSystemIndependentName(scriptName).equals(FileUtil.toSystemIndependentName(path))) {
return configuration;
}
}
return null;
}
Aggregations