IDEA-119822 - Support Heroku Debug

This commit is contained in:
Michael Golubev
2014-03-10 16:33:10 +01:00
parent 52a92f2125
commit 8e482449cf
3 changed files with 55 additions and 1 deletions
@@ -2,6 +2,9 @@ package com.intellij.remoteServer.impl.runtime.deployment.debug;
import com.intellij.debugger.DebugEnvironment;
import com.intellij.debugger.DebugUIEnvironment;
import com.intellij.debugger.DebuggerManager;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.DebugProcessAdapter;
import com.intellij.debugger.engine.RemoteDebugProcessHandler;
import com.intellij.debugger.ui.DebuggerPanelsManager;
import com.intellij.diagnostic.logging.LogFilesManager;
@@ -21,6 +24,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.runtime.deployment.debug.JavaDebugConnectionData;
import com.intellij.remoteServer.runtime.deployment.debug.JavaDebugServerModeHandler;
import com.intellij.remoteServer.runtime.deployment.debug.JavaDebuggerLauncher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +43,9 @@ public class JavaDebuggerLauncherImpl extends JavaDebuggerLauncher {
final Project project = executionEnvironment.getProject();
Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
final DebuggerPanelsManager manager = DebuggerPanelsManager.getInstance(project);
final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), false);
final JavaDebugServerModeHandler serverModeHandler = info.getServerModeHandler();
boolean serverMode = serverModeHandler != null;
final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), serverMode);
DebugEnvironment debugEnvironment = new RemoteServerDebugEnvironment(project, remoteConnection, executionEnvironment.getRunProfile());
DebugUIEnvironment debugUIEnvironment = new RemoteServerDebugUIEnvironment(debugEnvironment, executionEnvironment);
RunContentDescriptor debugContentDescriptor = manager.attachVirtualMachine(debugUIEnvironment);
@@ -49,6 +55,20 @@ public class JavaDebuggerLauncherImpl extends JavaDebuggerLauncher {
processHandler.startNotify();
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, debugContentDescriptor,
executionEnvironment.getContentToReuse());
if (serverMode) {
serverModeHandler.attachRemote();
DebuggerManager.getInstance(executionEnvironment.getProject())
.addDebugProcessListener(processHandler, new DebugProcessAdapter() {
public void processDetached(DebugProcess process, boolean closedByUser) {
try {
serverModeHandler.detachRemote();
}
catch (ExecutionException e) {
LOG.info(e);
}
}
});
}
}
private static class RemoteServerDebugUIEnvironment implements DebugUIEnvironment {
@@ -1,6 +1,7 @@
package com.intellij.remoteServer.runtime.deployment.debug;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
@@ -22,4 +23,9 @@ public class JavaDebugConnectionData implements DebugConnectionData {
public int getPort() {
return myPort;
}
@Nullable
public JavaDebugServerModeHandler getServerModeHandler() {
return null;
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.runtime.deployment.debug;
import com.intellij.execution.ExecutionException;
/**
* @author michael.golubev
*/
public interface JavaDebugServerModeHandler {
void attachRemote() throws ExecutionException;
void detachRemote() throws ExecutionException;
}