Skip to content

Commit cd817ef

Browse files
committed
feat: move LanguageClientImpl to a package which is exported without
restrictions and rename it
1 parent 0480a5b commit cd817ef

6 files changed

Lines changed: 31 additions & 15 deletions

File tree

org.eclipse.lsp4e/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Bundle-Localization: plugin
4747
Bundle-ActivationPolicy: lazy
4848
Bundle-Activator: org.eclipse.lsp4e.LanguageServerPlugin
4949
Export-Package: org.eclipse.lsp4e;x-friends:="org.eclipse.lsp4e.debug,org.eclipse.lsp4e.jdt",
50+
org.eclipse.lsp4e.client,
5051
org.eclipse.lsp4e.command;x-internal:=true,
5152
org.eclipse.lsp4e.format;x-internal:=true,
5253
org.eclipse.lsp4e.internal;x-friends:="org.eclipse.lsp4e.debug,org.eclipse.lsp4e.jdt",

org.eclipse.lsp4e/schema/languageServer.exsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
<attribute name="clientImpl" type="string">
8080
<annotation>
8181
<documentation>
82-
An optional language client implementation to use as local endpoint. If undefined, the default implementation &lt;code&gt;org.eclipse.lsp4e.LanguageClientImpl&lt;/code&gt; is used. See the &lt;a href=&quot;https://github.com/eclipse-lsp4j/lsp4j/tree/main/documentation&quot;&gt;LSP4J documentation&lt;/a&gt; for more information on how to extend the Language Server Protocol.
82+
An optional language client implementation to use as local endpoint. If undefined, the default implementation &lt;code&gt;org.eclipse.lsp4e.client.DefaultLanguageClient&lt;/code&gt; is used. See the &lt;a href=&quot;https://github.com/eclipse-lsp4j/lsp4j/tree/main/documentation&quot;&gt;LSP4J documentation&lt;/a&gt; for more information on how to extend the Language Server Protocol.
8383
</documentation>
8484
<appinfo>
85-
<meta.attribute kind="java" basedOn="org.eclipse.lsp4e.LanguageClientImpl:"/>
85+
<meta.attribute kind="java" basedOn="org.eclipse.lsp4e.client.DefaultLanguageClient:"/>
8686
</appinfo>
8787
</annotation>
8888
</attribute>

org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.eclipse.jdt.annotation.Nullable;
7272
import org.eclipse.jface.text.IDocument;
7373
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
74+
import org.eclipse.lsp4e.client.DefaultLanguageClient;
7475
import org.eclipse.lsp4e.internal.ArrayUtil;
7576
import org.eclipse.lsp4e.internal.CancellationUtil;
7677
import org.eclipse.lsp4e.internal.FileBufferListenerAdapter;
@@ -196,7 +197,7 @@ synchronized void close() {
196197
private @Nullable CompletableFuture<@Nullable Void> initializeFuture;
197198
private final AtomicReference<@Nullable IProgressMonitor> initializeFutureMonitorRef = new AtomicReference<>();
198199
private final int initializeFutureNumberOfStages = 7;
199-
private @Nullable LanguageClientImpl languageClient;
200+
private @Nullable DefaultLanguageClient languageClient;
200201
private volatile @Nullable ServerCapabilities serverCapabilities;
201202
private final Timer timer = new Timer("Stop Language Server Task Processor"); //$NON-NLS-1$
202203
private @Nullable TimerTask stopTimerTask;
@@ -962,7 +963,7 @@ public CompletableFuture<ServerCapabilities> getServerCapabilitiesAsync() {
962963
return null;
963964
}
964965

965-
void registerCapability(RegistrationParams params) {
966+
public void registerCapability(RegistrationParams params) {
966967
final var serverCapabilities = this.serverCapabilities;
967968
Assert.isNotNull(serverCapabilities,
968969
"Dynamic capability registration failed! Server not yet initialized?"); //$NON-NLS-1$
@@ -1102,7 +1103,7 @@ synchronized void registerCommands(List<String> newCommands) {
11021103
}
11031104
}
11041105

1105-
void unregisterCapability(UnregistrationParams params) {
1106+
public void unregisterCapability(UnregistrationParams params) {
11061107
params.getUnregisterations().forEach(reg -> {
11071108
String id = reg.getId();
11081109
Runnable unregistrator;

org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServersRegistry.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.eclipse.jface.preference.IPersistentPreferenceStore;
4242
import org.eclipse.jface.preference.IPreferenceStore;
4343
import org.eclipse.jface.text.IDocument;
44+
import org.eclipse.lsp4e.client.DefaultLanguageClient;
4445
import org.eclipse.lsp4e.enablement.EnablementTester;
4546
import org.eclipse.lsp4e.operations.diagnostics.LSPDiagnosticsToMarkers;
4647
import org.eclipse.lsp4e.server.StreamConnectionProvider;
@@ -109,8 +110,8 @@ public void registerAssociation(IContentType contentType, String languageId) {
109110

110111
public abstract StreamConnectionProvider createConnectionProvider();
111112

112-
public LanguageClientImpl createLanguageClient() {
113-
return new LanguageClientImpl();
113+
public DefaultLanguageClient createLanguageClient() {
114+
return new DefaultLanguageClient();
114115
}
115116

116117
public Class<? extends LanguageServer> getServerInterface() {
@@ -173,12 +174,12 @@ public StreamConnectionProvider createConnectionProvider() {
173174
}
174175

175176
@Override
176-
public LanguageClientImpl createLanguageClient() {
177-
LanguageClientImpl languageClient = null;
177+
public DefaultLanguageClient createLanguageClient() {
178+
DefaultLanguageClient languageClient = null;
178179
String clientImpl = extension.getAttribute(CLIENT_IMPL_ATTRIBUTE);
179180
if (clientImpl != null && !clientImpl.isEmpty()) {
180181
try {
181-
languageClient = (LanguageClientImpl) extension.createExecutableExtension(CLIENT_IMPL_ATTRIBUTE);
182+
languageClient = (DefaultLanguageClient) extension.createExecutableExtension(CLIENT_IMPL_ATTRIBUTE);
182183
} catch (CoreException e) {
183184
StatusManager.getManager().handle(e, LanguageServerPlugin.PLUGIN_ID);
184185
}
@@ -241,8 +242,8 @@ public StreamConnectionProvider createConnectionProvider() {
241242
}
242243

243244
@Override
244-
public LanguageClientImpl createLanguageClient() {
245-
LanguageClientImpl client = super.createLanguageClient();
245+
public DefaultLanguageClient createLanguageClient() {
246+
DefaultLanguageClient client = super.createLanguageClient();
246247
client.setDiagnosticsConsumer(new LSPDiagnosticsToMarkers(id, null, null));
247248
return client;
248249
}

org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageClientImpl.java renamed to org.eclipse.lsp4e/src/org/eclipse/lsp4e/client/DefaultLanguageClient.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Miro Spoenemann (TypeFox) - extracted to separate file
1212
* Rubén Porras Campo (Avaloq Evolution AG) - progress creation/notification implementation
1313
*******************************************************************************/
14-
package org.eclipse.lsp4e;
14+
package org.eclipse.lsp4e.client;
1515

1616
import static org.eclipse.lsp4e.internal.NullSafetyHelper.lateNonNull;
1717

@@ -28,6 +28,10 @@
2828
import org.eclipse.jdt.annotation.Nullable;
2929
import org.eclipse.jface.text.ITextViewer;
3030
import org.eclipse.jface.text.source.SourceViewer;
31+
import org.eclipse.lsp4e.LSPEclipseUtils;
32+
import org.eclipse.lsp4e.LanguageServerPlugin;
33+
import org.eclipse.lsp4e.LanguageServerWrapper;
34+
import org.eclipse.lsp4e.ServerMessageHandler;
3135
import org.eclipse.lsp4e.progress.LSPProgressManager;
3236
import org.eclipse.lsp4e.ui.Messages;
3337
import org.eclipse.lsp4e.ui.UI;
@@ -51,7 +55,10 @@
5155
import org.eclipse.ui.IEditorReference;
5256
import org.eclipse.ui.IWorkbenchPage;
5357

54-
public class LanguageClientImpl implements LanguageClient {
58+
/**
59+
* A default LanguageClient implementation which can be extended.
60+
*/
61+
public class DefaultLanguageClient implements LanguageClient {
5562

5663
private Consumer<PublishDiagnosticsParams> diagnosticConsumer = lateNonNull();
5764
private final LSPProgressManager progressManager = new LSPProgressManager();
@@ -65,7 +72,7 @@ public final void connect(LanguageServer server, LanguageServerWrapper wrapper)
6572
progressManager.connect(server, wrapper.serverDefinition);
6673
}
6774

68-
protected void setDiagnosticsConsumer(Consumer<PublishDiagnosticsParams> diagnosticConsumer) {
75+
public void setDiagnosticsConsumer(Consumer<PublishDiagnosticsParams> diagnosticConsumer) {
6976
this.diagnosticConsumer = diagnosticConsumer;
7077
}
7178

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2+
package org.eclipse.lsp4e.client;
3+
4+
import static org.eclipse.jdt.annotation.DefaultLocation.*;
5+
6+
import org.eclipse.jdt.annotation.NonNullByDefault;

0 commit comments

Comments
 (0)