|
35 | 35 | import java.util.concurrent.ExecutorService;
|
36 | 36 | import java.util.concurrent.Executors;
|
37 | 37 | import java.util.concurrent.Future;
|
| 38 | +import java.util.concurrent.ThreadFactory; |
38 | 39 | import java.util.concurrent.TimeUnit;
|
39 | 40 | import java.util.concurrent.TimeoutException;
|
40 | 41 | import java.util.concurrent.atomic.AtomicBoolean;
|
| 42 | +import java.util.concurrent.atomic.AtomicLong; |
41 | 43 | import java.util.concurrent.atomic.AtomicReference;
|
42 | 44 | import java.util.function.Consumer;
|
43 | 45 | import java.util.function.Function;
|
|
109 | 111 | import org.eclipse.osgi.util.NLS;
|
110 | 112 | import org.eclipse.swt.widgets.Display;
|
111 | 113 |
|
112 |
| -import com.google.common.base.Functions; |
113 |
| -import com.google.common.util.concurrent.ThreadFactoryBuilder; |
114 | 114 | import com.google.gson.Gson;
|
115 | 115 | import com.google.gson.JsonObject;
|
116 | 116 |
|
@@ -194,17 +194,31 @@ private LanguageServerWrapper(@Nullable IProject project, @NonNull LanguageServe
|
194 | 194 | this.initialPath = initialPath;
|
195 | 195 | this.serverDefinition = serverDefinition;
|
196 | 196 | this.connectedDocuments = new HashMap<>();
|
197 |
| - String projectName = (project != null && project.getName() != null && !serverDefinition.isSingleton) ? ("@" + project.getName()) : ""; //$NON-NLS-1$//$NON-NLS-2$ |
198 |
| - String dispatcherThreadNameFormat = "LS-" + serverDefinition.id + projectName + "#dispatcher"; //$NON-NLS-1$ //$NON-NLS-2$ |
199 |
| - this.dispatcher = Executors |
200 |
| - .newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat(dispatcherThreadNameFormat).build()); |
| 197 | + final String projectName = (project != null && project.getName() != null && !serverDefinition.isSingleton) ? ("@" + project.getName()) : ""; //$NON-NLS-1$//$NON-NLS-2$ |
| 198 | + final String dispatcherThreadNameFormat = "LS-" + serverDefinition.id + projectName + "#dispatcher"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 199 | + this.dispatcher = Executors.newSingleThreadExecutor(new ThreadFactory() { |
| 200 | + @Override |
| 201 | + public Thread newThread(final Runnable r) { |
| 202 | + final Thread thread = Executors.defaultThreadFactory().newThread(r); |
| 203 | + thread.setName(dispatcherThreadNameFormat); |
| 204 | + return thread; |
| 205 | + } |
| 206 | + }); |
201 | 207 |
|
202 | 208 | // Executor service passed through to the LSP4j layer when we attempt to start the LS. It will be used
|
203 | 209 | // to create a listener that sits on the input stream and processes inbound messages (responses, or server-initiated
|
204 | 210 | // requests).
|
205 |
| - String listenerThreadNameFormat = "LS-" + serverDefinition.id + projectName + "#listener-%d"; //$NON-NLS-1$ //$NON-NLS-2$ |
206 |
| - this.listener = Executors |
207 |
| - .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(listenerThreadNameFormat).build()); |
| 211 | + final String listenerThreadNamePrefix = "LS-" + serverDefinition.id + projectName + "#listener-"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 212 | + this.listener = Executors.newSingleThreadExecutor(new ThreadFactory() { |
| 213 | + final ThreadFactory threadFactory = Executors.defaultThreadFactory(); |
| 214 | + final AtomicLong threadCount = new AtomicLong(); |
| 215 | + @Override |
| 216 | + public Thread newThread(final Runnable r) { |
| 217 | + final Thread thread = threadFactory.newThread(r); |
| 218 | + thread.setName(listenerThreadNamePrefix + threadCount.incrementAndGet()); |
| 219 | + return thread; |
| 220 | + } |
| 221 | + }); |
208 | 222 | }
|
209 | 223 |
|
210 | 224 | void stopDispatcher() {
|
@@ -707,7 +721,7 @@ private boolean supportsWorkspaceFolderCapability() {
|
707 | 721 | return;
|
708 | 722 | }
|
709 | 723 | TextDocumentSyncKind syncKind = initializeFuture == null ? null
|
710 |
| - : serverCapabilities.getTextDocumentSync().map(Functions.identity(), TextDocumentSyncOptions::getChange); |
| 724 | + : serverCapabilities.getTextDocumentSync().map(left -> left, TextDocumentSyncOptions::getChange); |
711 | 725 | final var listener = new DocumentContentSynchronizer(this, languageServer, theDocument, syncKind);
|
712 | 726 | theDocument.addPrenotifiedDocumentListener(listener);
|
713 | 727 | LanguageServerWrapper.this.connectedDocuments.put(uri, listener);
|
|
0 commit comments