Skip to content

Commit

Permalink
Style and consistency fixes (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs committed Jun 7, 2023
1 parent 98f5de9 commit 67923f0
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand Down Expand Up @@ -110,6 +111,8 @@

public class LanguageServerWrapper {

private static final ILog LOG = Platform.getLog(LanguageServerWrapper.class);

private final IFileBufferListener fileBufferListener = new FileBufferListenerAdapter() {
@Override
public void bufferDisposed(IFileBuffer buffer) {
Expand Down Expand Up @@ -157,7 +160,7 @@ public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
private ServerCapabilities serverCapabilities;
private final Timer timer = new Timer("Stop Language Server Task Processor"); //$NON-NLS-1$
private TimerTask stopTimerTask;
private AtomicReference<CompletableFuture<Void>> stopping = new AtomicReference<CompletableFuture<Void>>(null);
private final AtomicReference<CompletableFuture<Void>> stopping = new AtomicReference<CompletableFuture<Void>>(null);

private final ExecutorService dispatcher;

Expand Down Expand Up @@ -207,9 +210,9 @@ void stopDispatcher() {
stop().get(6, TimeUnit.SECONDS);
} catch (InterruptedException e ) {
Thread.currentThread().interrupt();
LanguageServerPlugin.logError(e);
LOG.error(e.getLocalizedMessage(), e);
} catch (ExecutionException | TimeoutException e) {
Platform.getLog(LanguageServerWrapper.class).error(String.format("Failed to stop %s in 6 second", this), e); //$NON-NLS-1$
LOG.error(String.format("Failed to stop %s in 6 second", this), e); //$NON-NLS-1$
} finally {
this.dispatcher.shutdownNow();

Expand Down Expand Up @@ -474,7 +477,7 @@ public synchronized CompletableFuture<Void> stop() {
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
} catch (Exception ex) {
LanguageServerPlugin.logError(ex);
LOG.error(ex.getLocalizedMessage(), ex);
}
}

Expand All @@ -498,7 +501,7 @@ public synchronized CompletableFuture<Void> stop() {
result.complete(ignored);
}
if (!this.stopping.compareAndSet(result, null)) {
LanguageServerPlugin.logError(new IllegalStateException("Unexpected concurrent stop")); //$NON-NLS-1$
LOG.error("Unexpected concurrent stop", new IllegalStateException()); //$NON-NLS-1$
}
});

Expand Down Expand Up @@ -644,7 +647,7 @@ public CompletableFuture<Void> disconnect(URI uri) {
if (this.serverDefinition.lastDocumentDisconnectedTimeout != 0) {
startStopTimerTask();
} else {
CompletableFuture.allOf(documentClosedFuture, stop());
documentClosedFuture = documentClosedFuture.thenCompose(ignored -> this.stop());
}
}
return documentClosedFuture;
Expand Down

0 comments on commit 67923f0

Please sign in to comment.