use of com.intellij.execution.RunnerAndConfigurationSettings in project buck by facebook.
the class TestExecutionState method attachDebugger.
private void attachDebugger(String title, String port) {
final RemoteConnection remoteConnection = new RemoteConnection(/* useSockets */
true, "localhost", port, /* serverMode */
false);
final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
final String name = title + " debugger (" + port + ")";
final ConfigurationFactory cfgFactory = ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
RunnerAndConfigurationSettings runSettings = RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
final ExecutionEnvironment env = new ExecutionEnvironmentBuilder(mProject, debugExecutor).runProfile(runSettings.getConfiguration()).build();
final int pollTimeout = 3000;
final DebugEnvironment environment = new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);
ApplicationManager.getApplication().invokeLater(() -> {
try {
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
if (debuggerSession == null) {
return;
}
XDebuggerManager.getInstance(mProject).startSessionAndShowTab(name, null, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
return JavaDebugProcess.create(session, debuggerSession);
}
});
} catch (ExecutionException e) {
LOG.error("failed to attach to debugger on port " + port + " with polling timeout " + pollTimeout);
}
});
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project buck by facebook.
the class AndroidDebugger method createRunConfiguration.
private static RunnerAndConfigurationSettings createRunConfiguration(Project project, String debugPort) {
final RemoteConfigurationType remoteConfigurationType = RemoteConfigurationType.getInstance();
final ConfigurationFactory factory = remoteConfigurationType.getFactory();
final RunnerAndConfigurationSettings runSettings = RunManager.getInstance(project).createRunConfiguration(getRunConfigurationName(debugPort), factory);
final RemoteConfiguration configuration = (RemoteConfiguration) runSettings.getConfiguration();
configuration.HOST = "localhost";
configuration.PORT = debugPort;
configuration.USE_SOCKET_TRANSPORT = true;
configuration.SERVER_MODE = false;
return runSettings;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project android by JetBrains.
the class AndroidRunConfigurations method addRunConfiguration.
public void addRunConfiguration(@NotNull AndroidFacet facet, @Nullable String activityClass, @Nullable TargetSelectionMode targetSelectionMode, @Nullable String preferredAvdName) {
Module module = facet.getModule();
RunManager runManager = RunManager.getInstance(module.getProject());
AndroidRunConfigurationType runConfigurationType = AndroidRunConfigurationType.getInstance();
RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(), runConfigurationType.getFactory());
AndroidRunConfiguration configuration = (AndroidRunConfiguration) settings.getConfiguration();
configuration.setModule(module);
if (activityClass != null) {
configuration.setLaunchActivity(activityClass);
} else if (facet.getProjectType() == PROJECT_TYPE_INSTANTAPP) {
configuration.setLaunchUrl(getDefaultRunConfigurationUrl(facet));
} else if (isWatchFaceApp(facet)) {
// In case of a watch face app, there is only a service and no default activity that can be launched
// Eventually, we'd need to support launching a service, but currently you cannot launch a watch face service as well.
// See https://code.google.com/p/android/issues/detail?id=151353
configuration.MODE = DO_NOTHING;
} else {
configuration.MODE = LAUNCH_DEFAULT_ACTIVITY;
}
if (targetSelectionMode != null) {
configuration.getDeployTargetContext().setTargetSelectionMode(targetSelectionMode);
}
if (preferredAvdName != null) {
configuration.PREFERRED_AVD = preferredAvdName;
}
runManager.addConfiguration(settings, false);
runManager.setSelectedConfiguration(settings);
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project android by JetBrains.
the class PostSyncProjectSetup method setMakeStepInJunitRunConfigurations.
private void setMakeStepInJunitRunConfigurations(@NotNull String makeTaskName) {
ConfigurationType junitConfigurationType = AndroidJUnitConfigurationType.getInstance();
BeforeRunTaskProvider<BeforeRunTask>[] taskProviders = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject);
BeforeRunTaskProvider targetProvider = null;
for (BeforeRunTaskProvider<? extends BeforeRunTask> provider : taskProviders) {
if (makeTaskName.equals(provider.getName())) {
targetProvider = provider;
break;
}
}
if (targetProvider != null) {
RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
// Set the correct "Make step" in the "JUnit Run Configuration" template.
for (ConfigurationFactory configurationFactory : junitConfigurationType.getConfigurationFactories()) {
RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configurationFactory);
RunConfiguration runConfiguration = template.getConfiguration();
setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
}
// Set the correct "Make step" in existing JUnit Configurations.
for (RunConfiguration runConfiguration : runManager.getConfigurationsList(junitConfigurationType)) {
setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
}
}
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project android by JetBrains.
the class AndroidJUnitConfigurations method isFromContext.
// Copy of JUnitConfigurationProducer#isConfigurationFromContext using AndroidJUnitConfigurationType instead of JUnitConfigurationType
public static boolean isFromContext(@NotNull JUnitConfiguration unitConfiguration, @NotNull ConfigurationContext context, @NotNull ConfigurationFactory configurationFactory) {
if (RunConfigurationProducer.getInstance(PatternConfigurationProducer.class).isMultipleElementsSelected(context)) {
return false;
}
RunConfiguration predefinedConfiguration = context.getOriginalConfiguration(AndroidJUnitConfigurationType.getInstance());
Location contextLocation = context.getLocation();
String paramSetName = contextLocation instanceof PsiMemberParameterizedLocation ? ((PsiMemberParameterizedLocation) contextLocation).getParamSetName() : null;
assert contextLocation != null;
Location location = JavaExecutionUtil.stepIntoSingleClass(contextLocation);
if (location == null) {
return false;
}
PsiElement element = location.getPsiElement();
PsiClass testClass = getTestClass(element);
PsiMethod testMethod = getTestMethod(element, false);
PsiPackage testPackage;
if (element instanceof PsiPackage) {
testPackage = (PsiPackage) element;
} else {
if (element instanceof PsiDirectory) {
testPackage = JavaDirectoryService.getInstance().getPackage(((PsiDirectory) element));
} else {
testPackage = null;
}
}
PsiDirectory testDir = element instanceof PsiDirectory ? (PsiDirectory) element : null;
RunnerAndConfigurationSettings template = RunManager.getInstance(location.getProject()).getConfigurationTemplate(configurationFactory);
Module predefinedModule = ((JUnitConfiguration) template.getConfiguration()).getConfigurationModule().getModule();
String vmParameters = predefinedConfiguration instanceof JUnitConfiguration ? ((JUnitConfiguration) predefinedConfiguration).getVMParameters() : null;
if (vmParameters != null && !Comparing.strEqual(vmParameters, unitConfiguration.getVMParameters())) {
return false;
}
if (paramSetName != null && !Comparing.strEqual(paramSetName, unitConfiguration.getProgramParameters())) {
return false;
}
TestObject testobject = unitConfiguration.getTestObject();
if (testobject != null) {
if (testobject.isConfiguredByElement(unitConfiguration, testClass, testMethod, testPackage, testDir)) {
Module configurationModule = unitConfiguration.getConfigurationModule().getModule();
if (Comparing.equal(location.getModule(), configurationModule)) {
return true;
}
if (Comparing.equal(predefinedModule, configurationModule)) {
return true;
}
}
}
return false;
}
Aggregations