Skip to content

Commit f23bf8b

Browse files
author
ahmadsebak
committed
clean up
1 parent 2ff63a2 commit f23bf8b

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

src/com/atsebak/embeddedlinuxjvm/commandline/AppCommandLineState.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.intellij.ui.content.Content;
4545
import com.intellij.util.NotNullFunction;
4646
import com.intellij.util.PathsList;
47-
import com.jcraft.jsch.Session;
4847
import org.jetbrains.annotations.NonNls;
4948
import org.jetbrains.annotations.NotNull;
5049
import org.jetbrains.annotations.Nullable;
@@ -63,8 +62,6 @@ public class AppCommandLineState extends JavaCommandLineState {
6362
@NotNull
6463
private final EmbeddedLinuxJVMRunConfiguration configuration;
6564
@NotNull
66-
private final ExecutionEnvironment environment;
67-
@NotNull
6865
private final RunnerSettings runnerSettings;
6966
@NotNull
7067
private final EmbeddedLinuxJVMOutputForwarder outputForwarder;
@@ -82,7 +79,6 @@ public class AppCommandLineState extends JavaCommandLineState {
8279
public AppCommandLineState(@NotNull ExecutionEnvironment environment, @NotNull EmbeddedLinuxJVMRunConfiguration configuration) {
8380
super(environment);
8481
this.configuration = configuration;
85-
this.environment = environment;
8682
this.runnerSettings = environment.getRunnerSettings();
8783
this.project = environment.getProject();
8884
this.isDebugMode = runnerSettings instanceof DebuggingRunnerData;
@@ -136,35 +132,40 @@ protected OSProcessHandler startProcess() throws ExecutionException {
136132
handler.addProcessListener(new ProcessAdapter() {
137133
private void closeSSHConnection() {
138134
try {
139-
closeSSHThreads();
140135
if (isDebugMode) {
141136
//todo fix tcp connection closing issue random error message showing up
142-
closeRemoteVM();
137+
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(project).getContext().getDebuggerSession();
138+
if (debuggerSession == null) {
139+
return;
140+
}
141+
142+
final DebugProcessImpl debugProcess = debuggerSession.getProcess();
143+
if (debugProcess.isDetached() || debugProcess.isDetaching()) {
144+
debugProcess.stop(true);
145+
debugProcess.dispose();
146+
debuggerSession.dispose();
147+
}
143148
}
144-
Session session = EmbeddedLinuxJVMConsoleView.getInstance(project).getSession();
145149
} catch (Exception e) {
146150
}
147151
}
148152

149-
private void closeSSHThreads() {
150-
// for (Thread thread : SSHHandlerTarget.threads) {
151-
// thread.interrupt();
153+
/**
154+
* closes debug session
155+
*/
156+
private void closeDescriptors() {
157+
//todo remove remote debugger console
158+
final Collection<RunContentDescriptor> descriptors =
159+
ExecutionHelper.findRunningConsoleByTitle(project, new NotNullFunction<String, Boolean>() {
160+
@NotNull
161+
@Override
162+
public Boolean fun(String title) {
163+
return AppCommandLineState.getRunConfigurationName(configuration.getRunnerParameters().getPort()).equals(title);
164+
}
165+
});
166+
// for (RunContentDescriptor descriptor : descriptors) {
167+
// final Content content = descriptor.getAttachedContent();
152168
// }
153-
// SSHHandlerTarget.threads.clear();
154-
}
155-
156-
private void closeRemoteVM() {
157-
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(project).getContext().getDebuggerSession();
158-
if (debuggerSession == null) {
159-
return;
160-
}
161-
162-
final DebugProcessImpl debugProcess = debuggerSession.getProcess();
163-
if (debugProcess.isDetached() || debugProcess.isDetaching()) {
164-
debugProcess.stop(true);
165-
debugProcess.dispose();
166-
debuggerSession.dispose();
167-
}
168169
}
169170

170171
/**
@@ -179,6 +180,9 @@ public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
179180
@Override
180181
public void run(@NotNull ProgressIndicator progressIndicator) {
181182
closeSSHConnection();
183+
if (isDebugMode) {
184+
closeDescriptors();
185+
}
182186
}
183187
});
184188
super.processWillTerminate(event, willBeDestroyed);

src/com/atsebak/embeddedlinuxjvm/localization/EmbeddedLinuxJVMBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ ssh.tryingtoconnect=Trying to contact remote target...
3030
app.vmoptions=VM Options
3131
app.programargs=Program Arguments
3232
debugport.placeholder=Any number not in use on the target device
33-
exit.code.message=Process finished with exit code {0}
33+
exit.code.message=\n\r\n\rProcess finished with exit code {0}\n\r

0 commit comments

Comments
 (0)