Skip to content

Commit bc04d13

Browse files
committed
Clean up LaunchHelper class
1 parent 18bc8d7 commit bc04d13

File tree

1 file changed

+15
-20
lines changed
  • eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils

1 file changed

+15
-20
lines changed

eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/LaunchHelper.java

+15-20
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import java.util.concurrent.CompletableFuture;
55

66
import org.eclipse.core.runtime.CoreException;
7-
import org.eclipse.core.runtime.Status;
7+
import org.eclipse.core.runtime.IStatus;
88
import org.eclipse.core.runtime.jobs.Job;
99
import org.eclipse.debug.core.DebugPlugin;
1010
import org.eclipse.debug.core.ILaunch;
1111

1212
public class LaunchHelper {
1313

14-
1514
public static Job createJob(ILaunch launch, String command, String workingDirectory) {
1615
return createJob(launch, command, new File(workingDirectory));
1716
}
@@ -27,32 +26,28 @@ public static Job createJob(ILaunch launch, String command, File workingDirector
2726
}
2827
CompletableFuture<Process> future = process.onExit();
2928
// initialize a process completion future to log any non-zero process exit
30-
future.defaultExecutor().execute(new Runnable() {
31-
@Override
32-
public void run() {
33-
try {
34-
if (process.isAlive()) {
35-
process.waitFor();
36-
}
37-
} catch (InterruptedException e) {
38-
LogHelper.cancelled("Process monitor interrupted: " + command);
39-
return;
40-
}
41-
int exc = process.exitValue();
42-
if (exc != 0) {
43-
String msg = String.format("Process exited non-zero (%d): %s ", exc, command);
44-
LogHelper.error(msg);
29+
future.defaultExecutor().execute(() -> {
30+
try {
31+
if (process.isAlive()) {
32+
process.waitFor();
4533
}
34+
} catch (InterruptedException e) {
35+
LogHelper.cancelled("Process monitor interrupted: " + command);
36+
return;
37+
}
38+
int exc = process.exitValue();
39+
if (exc != 0) {
40+
String msg = String.format("Process exited non-zero (%d): %s ", exc, command);
41+
LogHelper.error(msg);
4642
}
47-
4843
});
4944
DebugPlugin.newProcess(launch, process, command);
5045
} catch (CoreException e) {
5146
// CoreException from exec
52-
LogHelper.log(Status.ERROR, "Exception when launching process: " + command, e);
47+
LogHelper.log(IStatus.ERROR, "Exception when launching process: " + command, e);
5348
return;
5449
}
5550
});
5651
}
5752

58-
};;
53+
}

0 commit comments

Comments
 (0)