use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class ContextConfigurationTest method testMethodInAbstractJUnit3TestCase.
public void testMethodInAbstractJUnit3TestCase() throws Exception {
String packageName = "abstractTests";
String shortName = "AbstractTestImpl1";
String qualifiedName = StringUtil.getQualifiedName(packageName, shortName);
PsiClass psiClass = findClass(getModule1(), qualifiedName);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, true)[0];
MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.PROJECT, myProject);
if (LangDataKeys.MODULE.getData(dataContext) == null) {
dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(testMethod));
}
dataContext.put(Location.DATA_KEY, MethodLocation.elementInClass(testMethod, psiClass));
ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
RunnerAndConfigurationSettings settings = context.getConfiguration();
JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration();
checkClassName(qualifiedName, configuration);
checkMethodName(METHOD_NAME, configuration);
checkPackage(packageName, configuration);
checkGeneretedName(configuration, shortName + "." + METHOD_NAME);
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class ContextConfigurationTest method testReusingConfiguration.
public void testReusingConfiguration() {
RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
ConfigurationContext context = createContext(psiClass);
assertEquals(null, context.findExisting());
RunnerAndConfigurationSettings testClass = context.getConfiguration();
runManager.addConfiguration(testClass, false);
context = createContext(psiClass);
assertSame(testClass, context.findExisting());
runManager.setSelectedConfiguration(testClass);
context = createContext(psiPackage);
assertEquals(null, context.findExisting());
RunnerAndConfigurationSettings testPackage = context.getConfiguration();
runManager.addConfiguration(testPackage, false);
context = createContext(psiPackage);
assertSame(testPackage, context.findExisting());
assertSame(testClass, runManager.getSelectedConfiguration());
runManager.setSelectedConfiguration(context.findExisting());
assertSame(testPackage, runManager.getSelectedConfiguration());
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class AppletConfigurationProducer method createConfigurationByElement.
@Override
protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) {
location = JavaExecutionUtil.stepIntoSingleClass(location);
if (location == null)
return null;
final Project project = location.getProject();
final PsiElement element = location.getPsiElement();
myPsiClass = getAppletClass(element, PsiManager.getInstance(project));
if (myPsiClass == null)
return null;
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
final AppletConfiguration configuration = (AppletConfiguration) settings.getConfiguration();
configuration.MAIN_CLASS_NAME = JavaExecutionUtil.getRuntimeQualifiedName(myPsiClass);
configuration.setModule(myPsiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(myPsiClass) : null);
configuration.setGeneratedName();
return settings;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.
the class RubyMotionUtilExt method createMotionRunConfiguration.
public static void createMotionRunConfiguration(final Module module) {
final Project project = module.getProject();
final String title = RBundle.message("rails.facet.builder.run.configuration.server.creating");
final Task task = new Task.Backgroundable(project, title, true) {
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText(RBundle.message("progress.backgnd.indicator.title.please.wait", getTitle()));
final RunManager runManager = RunManager.getInstance(project);
ApplicationManager.getApplication().runReadAction(() -> {
// requires read action
// Rake : "simulator"
final String taskName = RubyMotionUtil.getInstance().getMainRakeTask(module);
final RunnerAndConfigurationSettings simulator = createAndAddRakeConfiguration(taskName, module, runManager);
// Rake : "spec"
createAndAddRakeConfiguration(RakeUtilBase.TASKS_SPEC_FULLCMD, module, runManager);
// make development config active
runManager.setSelectedConfiguration(simulator);
});
}
};
final Runnable taskRunner = () -> ProgressManager.getInstance().run(task);
if (!project.isInitialized()) {
StartupManager.getInstance(project).registerPostStartupActivity(taskRunner);
} else {
taskRunner.run();
}
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.
the class DartProjectTemplate method createWebRunConfiguration.
static void createWebRunConfiguration(@NotNull final Module module, @NotNull final VirtualFile htmlFile) {
DartModuleBuilder.runWhenNonModalIfModuleNotDisposed(() -> {
final WebBrowser dartium = DartiumUtil.getDartiumBrowser();
if (dartium == null)
return;
final Url url = WebBrowserServiceImpl.getDebuggableUrl(PsiManager.getInstance(module.getProject()).findFile(htmlFile));
if (url == null)
return;
final RunManager runManager = RunManager.getInstance(module.getProject());
try {
final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration("", JavascriptDebugConfigurationType.getTypeInstance().getFactory());
((JavaScriptDebugConfiguration) settings.getConfiguration()).setUri(url.toDecodedForm());
((JavaScriptDebugConfiguration) settings.getConfiguration()).setEngineId(dartium.getId().toString());
settings.setName(((JavaScriptDebugConfiguration) settings.getConfiguration()).suggestedName());
runManager.addConfiguration(settings, false);
runManager.setSelectedConfiguration(settings);
} catch (Throwable t) {
/* ClassNotFound in IDEA Community or if JS Debugger plugin disabled */
}
}, module);
}
Aggregations