Skip to content

Commit

Permalink
Fix build on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Apr 12, 2019
1 parent 5f4346f commit cfc8bf8
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
Expand Down Expand Up @@ -304,27 +305,35 @@ private CodeActionOptions getCodeActionOptions() {
@Override
public CompletableFuture<Object> shutdown() {
logInfo(">> shutdown");
disconnectFromWorkspace();
return computeAsync((monitor) -> {
try {
JavaRuntime.removeVMInstallChangedListener(jvmConfigurator);
if (workspaceDiagnosticsHandler != null) {
workspaceDiagnosticsHandler.removeResourceChangeListener();
workspaceDiagnosticsHandler = null;
}
ResourcesPlugin.getWorkspace().save(true, monitor);
} catch (CoreException e) {
logException(e.getMessage(), e);
}
return new Object();
});
}

private void disconnectFromWorkspace() {
try {
JavaRuntime.removeVMInstallChangedListener(jvmConfigurator);
if (workspaceDiagnosticsHandler != null) {
workspaceDiagnosticsHandler.removeResourceChangeListener();
workspaceDiagnosticsHandler = null;
}
JavaLanguageServerPlugin.logInfo("Saving workspace");
long start = System.currentTimeMillis();
ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor());
JavaLanguageServerPlugin.logInfo("Workspace saved. Took " + (System.currentTimeMillis() - start) + " ms");
} catch (CoreException e) {
logException(e.getMessage(), e);
}
}

/* (non-Javadoc)
* @see org.eclipse.lsp4j.services.LanguageServer#exit()
*/
@Override
public void exit() {
logInfo(">> exit");
disconnectFromWorkspace();
JavaLanguageServerPlugin.getLanguageServer().exit();
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
logInfo("Forcing exit after 1 min.");
Expand Down

0 comments on commit cfc8bf8

Please sign in to comment.