use of com.intellij.execution.configurations.RunConfiguration in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunConfigurationTestCase method doTestProducedConfigurations.
protected void doTestProducedConfigurations(@Nullable PsiElement context) {
assertNotNull(context);
ConfigurationContext configurationContext = new ConfigurationContext(context);
List<ConfigurationFromContext> configurationAndSettings = configurationContext.getConfigurationsFromContext();
Element configurationsElement = new Element("configurations");
if (configurationAndSettings != null) {
for (ConfigurationFromContext setting : configurationAndSettings) {
try {
RunConfiguration configuration = setting.getConfiguration();
Element configurationElement = new Element("configurations");
configurationElement.setAttribute("name", configuration.getName());
configurationElement.setAttribute("class", configuration.getClass().getSimpleName());
configuration.writeExternal(configurationElement);
configurationsElement.addContent(configurationElement);
} catch (WriteExternalException e) {
throw new RuntimeException(e);
}
}
}
assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + ".xml", JDOMUtil.writeElement(configurationsElement));
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class GroovyHotSwapper method patchJavaParameters.
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
ApplicationManager.getApplication().assertReadAccessAllowed();
if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
return;
}
if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
return;
}
if (hasSpringLoadedReloader(javaParameters)) {
return;
}
if (!(configuration instanceof RunConfiguration)) {
return;
}
final Project project = ((RunConfiguration) configuration).getProject();
if (project == null) {
return;
}
if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
if (configuration instanceof ModuleBasedConfiguration) {
final Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
if (module != null) {
final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
}
}
Sdk jdk = javaParameters.getJdk();
if (jdk != null) {
String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
if (vendor != null && vendor.contains("IBM")) {
LOG.info("Due to IBM JDK peculiarities (IDEA-59070) we don't add Groovy agent when running applications under it");
return;
}
}
if (!project.isDefault() && containsGroovyClasses(project)) {
final String agentPath = handleSpacesInPath(getAgentJarPath());
if (agentPath != null) {
javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
}
}
}
use of com.intellij.execution.configurations.RunConfiguration 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.configurations.RunConfiguration in project intellij-community by JetBrains.
the class InternalProjectTaskRunner method createScope.
private static CompileScope createScope(CompilerManager compilerManager, ProjectTaskContext context, Collection<Module> modules, boolean includeDependentModules, boolean includeRuntimeDependencies) {
CompileScope scope = compilerManager.createModulesCompileScope(modules.toArray(new Module[modules.size()]), includeDependentModules, includeRuntimeDependencies);
RunConfiguration configuration = context.getRunConfiguration();
if (configuration != null) {
scope.putUserData(CompilerManager.RUN_CONFIGURATION_KEY, configuration);
scope.putUserData(CompilerManager.RUN_CONFIGURATION_TYPE_ID_KEY, configuration.getType().getId());
}
ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.set(scope, context.getSessionId());
return scope;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method runTasks.
public boolean runTasks(@NotNull Collection<String> modules, @NotNull Phase... phases) {
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue = new LinkedList<>();
//noinspection MismatchedQueryAndUpdateOfCollection
Map<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>> lazyConfigurationsMap = new FactoryMap<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>>() {
@Nullable
@Override
protected Map<String, RunnerAndConfigurationSettings> create(ProjectSystemId key) {
final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(key);
if (configurationType == null)
return null;
return ContainerUtil.map2Map(RunManager.getInstance(myProject).getConfigurationSettingsList(configurationType), configurationSettings -> Pair.create(configurationSettings.getName(), configurationSettings));
}
};
for (final ExternalProjectsStateProvider.TasksActivation activation : stateProvider.getAllTasksActivation()) {
final boolean hashPath = modules.contains(activation.projectPath);
final Set<String> tasks = ContainerUtil.newLinkedHashSet();
for (Phase phase : phases) {
List<String> activationTasks = activation.state.getTasks(phase);
if (hashPath || (phase.isSyncPhase() && !activationTasks.isEmpty() && isShareSameRootPath(modules, activation))) {
ContainerUtil.addAll(tasks, activationTasks);
}
}
if (tasks.isEmpty())
continue;
for (Iterator<String> iterator = tasks.iterator(); iterator.hasNext(); ) {
String task = iterator.next();
if (task.length() > RUN_CONFIGURATION_TASK_PREFIX.length() && task.startsWith(RUN_CONFIGURATION_TASK_PREFIX)) {
iterator.remove();
final String configurationName = task.substring(RUN_CONFIGURATION_TASK_PREFIX.length());
Map<String, RunnerAndConfigurationSettings> settings = lazyConfigurationsMap.get(activation.systemId);
if (settings == null)
continue;
RunnerAndConfigurationSettings configurationSettings = settings.get(configurationName);
if (configurationSettings == null)
continue;
final RunConfiguration runConfiguration = configurationSettings.getConfiguration();
if (configurationName.equals(configurationSettings.getName()) && runConfiguration instanceof ExternalSystemRunConfiguration) {
tasksQueue.add(Pair.create(activation.systemId, ((ExternalSystemRunConfiguration) runConfiguration).getSettings()));
}
}
}
if (tasks.isEmpty())
continue;
if (ExternalProjectsManager.getInstance(myProject).isIgnored(activation.systemId, activation.projectPath))
continue;
ExternalSystemTaskExecutionSettings executionSettings = new ExternalSystemTaskExecutionSettings();
executionSettings.setExternalSystemIdString(activation.systemId.toString());
executionSettings.setExternalProjectPath(activation.projectPath);
executionSettings.getTaskNames().addAll(tasks);
tasksQueue.add(Pair.create(activation.systemId, executionSettings));
}
return runTasksQueue(tasksQueue);
}
Aggregations