use of com.intellij.execution.configurations.ConfigurationFactory in project android by JetBrains.
the class AndroidJavaDebugger method attachToClient.
@Override
public void attachToClient(@NotNull Project project, @NotNull Client client) {
String debugPort = getClientDebugPort(client);
String runConfigName = String.format(RUN_CONFIGURATION_NAME_PATTERN, debugPort);
// Try to find existing debug session
if (hasExistingDebugSession(project, debugPort, runConfigName)) {
return;
}
// Create run configuration
RemoteConfigurationType remoteConfigurationType = RemoteConfigurationType.getInstance();
ConfigurationFactory factory = remoteConfigurationType.getFactory();
RunnerAndConfigurationSettings runSettings = RunManager.getInstance(project).createRunConfiguration(runConfigName, factory);
RemoteConfiguration configuration = (RemoteConfiguration) runSettings.getConfiguration();
configuration.HOST = "localhost";
configuration.PORT = debugPort;
configuration.USE_SOCKET_TRANSPORT = true;
configuration.SERVER_MODE = false;
ProgramRunnerUtil.executeConfiguration(project, runSettings, DefaultDebugExecutor.getDebugExecutorInstance());
}
use of com.intellij.execution.configurations.ConfigurationFactory in project Intellij-Plugin by getgauge.
the class GaugeRunProcessHandler method launchDebugger.
private static void launchDebugger(final Project project, final GaugeDebugInfo debugInfo) {
Runnable runnable = () -> {
final long startTime = System.currentTimeMillis();
GenericDebuggerRunner basicProgramRunner = new GenericDebuggerRunner();
RunManagerImpl manager = new RunManagerImpl(project);
ConfigurationFactory configFactory = RemoteConfigurationType.getInstance().getConfigurationFactories()[0];
RemoteConfiguration remoteConfig = new RemoteConfiguration(project, configFactory);
remoteConfig.PORT = debugInfo.getPort();
remoteConfig.HOST = debugInfo.getHost();
remoteConfig.USE_SOCKET_TRANSPORT = true;
remoteConfig.SERVER_MODE = false;
RunnerAndConfigurationSettingsImpl configuration = new RunnerAndConfigurationSettingsImpl(manager, remoteConfig, false);
ExecutionEnvironment environment = new ExecutionEnvironment(new DefaultDebugExecutor(), basicProgramRunner, configuration, project);
boolean debuggerConnected = false;
// Trying to connect to gauge java for 25 secs. The sleep is because it may take a few seconds for gauge to launch the java process and the jvm to load after that
while (!debuggerConnected && ((System.currentTimeMillis() - startTime) < 25000)) {
try {
Thread.sleep(5000);
basicProgramRunner.execute(environment);
debuggerConnected = true;
} catch (Exception e) {
System.err.println("Failed to connect debugger. Retrying... : " + e.getMessage());
}
}
};
ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.any());
}
use of com.intellij.execution.configurations.ConfigurationFactory 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.configurations.ConfigurationFactory 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.configurations.ConfigurationFactory in project buck by facebook.
the class TestConfigurationTest method testPersistency.
public void testPersistency() throws Exception {
final ConfigurationFactory factory = TestConfigurationType.getInstance().getConfigurationFactories()[0];
final TestConfiguration cfg = new TestConfiguration(getProject(), factory, "test serialization");
cfg.data.target = "//src/com/facebook/buck:test";
cfg.data.testSelectors = "com.facebook.buck.Test";
cfg.data.additionalParams = "--num-threads 239";
final Element testElement = new Element("test_element");
cfg.writeExternal(testElement);
final TestConfiguration cfg2 = new TestConfiguration(getProject(), factory, "test serialization");
cfg2.readExternal(testElement);
Assert.assertEquals("//src/com/facebook/buck:test", cfg2.data.target);
Assert.assertEquals("com.facebook.buck.Test", cfg2.data.testSelectors);
Assert.assertEquals("--num-threads 239", cfg2.data.additionalParams);
}
Aggregations