Search in sources :

Example 1 with RemoteConfiguration

use of com.intellij.execution.remote.RemoteConfiguration 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());
}
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 2 with RemoteConfiguration

use of com.intellij.execution.remote.RemoteConfiguration in project azure-tools-for-java by Microsoft.

the class FunctionRunState method launchDebugger.

@AzureOperation(name = "function.launch_debugger", type = AzureOperation.Type.TASK)
private void launchDebugger(final Project project, int debugPort) {
    final Runnable runnable = () -> {
        final RunManagerImpl manager = new RunManagerImpl(project);
        final ConfigurationFactory configFactory = RemoteConfigurationType.getInstance().getConfigurationFactories()[0];
        final RemoteConfiguration remoteConfig = new RemoteConfiguration(project, configFactory);
        remoteConfig.PORT = String.valueOf(debugPort);
        remoteConfig.HOST = "localhost";
        remoteConfig.USE_SOCKET_TRANSPORT = true;
        remoteConfig.SERVER_MODE = false;
        remoteConfig.setName("azure functions");
        final RunnerAndConfigurationSettings configuration = new RunnerAndConfigurationSettingsImpl(manager, remoteConfig, false);
        manager.setTemporaryConfiguration(configuration);
        ExecutionUtil.runConfiguration(configuration, ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG));
    };
    AzureTaskManager.getInstance().runAndWait(runnable, AzureTask.Modality.ANY);
}
Also used : RemoteConfiguration(com.intellij.execution.remote.RemoteConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunnerAndConfigurationSettingsImpl(com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 3 with RemoteConfiguration

use of com.intellij.execution.remote.RemoteConfiguration 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());
                LOG.debug(e);
            }
        }
    };
    ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.any());
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) RemoteConfiguration(com.intellij.execution.remote.RemoteConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettingsImpl(com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl) GenericDebuggerRunner(com.intellij.debugger.impl.GenericDebuggerRunner) ExecutionException(com.intellij.execution.ExecutionException) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 4 with RemoteConfiguration

use of com.intellij.execution.remote.RemoteConfiguration 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)

Aggregations

ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)4 RemoteConfiguration (com.intellij.execution.remote.RemoteConfiguration)4 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)2 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)2 RemoteConfigurationType (com.intellij.execution.remote.RemoteConfigurationType)2 GenericDebuggerRunner (com.intellij.debugger.impl.GenericDebuggerRunner)1 ExecutionException (com.intellij.execution.ExecutionException)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1