Search in sources :

Example 21 with ConfigurationFactory

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);
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XDebugProcess(com.intellij.xdebugger.XDebugProcess) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) RemoteStateState(com.intellij.debugger.engine.RemoteStateState) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DebugEnvironment(com.intellij.debugger.DebugEnvironment)

Example 22 with ConfigurationFactory

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;
}
Also used : RemoteConfiguration(com.intellij.execution.remote.RemoteConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RemoteConfigurationType(com.intellij.execution.remote.RemoteConfigurationType)

Example 23 with ConfigurationFactory

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);
}
Also used : Element(org.jdom.Element) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory)

Example 24 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project android by JetBrains.

the class AndroidRunConfigurations method createRunConfiguration.

public void createRunConfiguration(@NotNull AndroidFacet facet) {
    Module module = facet.getModule();
    ConfigurationFactory configurationFactory = AndroidRunConfigurationType.getInstance().getFactory();
    List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getConfigurationsList(configurationFactory.getType());
    for (RunConfiguration configuration : configurations) {
        if (configuration instanceof AndroidRunConfiguration && ((AndroidRunConfiguration) configuration).getConfigurationModule().getModule() == module) {
            // There is already a run configuration for this module.
            return;
        }
    }
    addRunConfiguration(facet, null, TargetSelectionMode.SHOW_DIALOG, null);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) Module(com.intellij.openapi.module.Module)

Example 25 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory 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);
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Aggregations

ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)38 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)23 Project (com.intellij.openapi.project.Project)14 RunManagerEx (com.intellij.execution.RunManagerEx)11 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)9 BeforeRunTask (com.intellij.execution.BeforeRunTask)7 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)6 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)4 RemoteConfiguration (com.intellij.execution.remote.RemoteConfiguration)4 Module (com.intellij.openapi.module.Module)4 RunManager (com.intellij.execution.RunManager)3 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)3 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)3 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)3 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)2 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)2 ExecutionException (com.intellij.execution.ExecutionException)2 ConfigurationFactoryEx (com.intellij.execution.configuration.ConfigurationFactoryEx)2