This is an automated email from the ASF dual-hosted git repository.
jlahoda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new a9dc51215e Not registering the LSP's SingleFileOptionsQueryImpl in
java.lsp.server, but only in nbcode
new e92309ca46 Merge pull request #6854 from
lahodaj/fix-single-file-options-in-nb
a9dc51215e is described below
commit a9dc51215e2958e12488a9c39f5fbe1daddb4005
Author: Jan Lahoda <[email protected]>
AuthorDate: Fri Dec 15 18:44:20 2023 +0100
Not registering the LSP's SingleFileOptionsQueryImpl in java.lsp.server,
but only in nbcode
---
java/java.file.launcher/nbproject/project.xml | 1 +
.../nbcode/integration/nbproject/project.xml | 8 +++++
.../integration/LspSingleFileOptionsQueryImpl.java | 27 +++++++++++++++
.../server/protocol/TextDocumentServiceImpl.java | 38 ++++++++++++----------
.../SingleFileOptionsQueryImpl.java | 4 +--
5 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/java/java.file.launcher/nbproject/project.xml
b/java/java.file.launcher/nbproject/project.xml
index 1bc8cb541b..d5520075de 100644
--- a/java/java.file.launcher/nbproject/project.xml
+++ b/java/java.file.launcher/nbproject/project.xml
@@ -260,6 +260,7 @@
</test-dependencies>
<friend-packages>
<friend>org.netbeans.modules.java.lsp.server</friend>
+ <friend>org.netbeans.modules.nbcode.integration</friend>
<friend>org.netbeans.modules.refactoring.java</friend>
<package>org.netbeans.modules.java.file.launcher.api</package>
<package>org.netbeans.modules.java.file.launcher.spi</package>
diff --git a/java/java.lsp.server/nbcode/integration/nbproject/project.xml
b/java/java.lsp.server/nbcode/integration/nbproject/project.xml
index debf5ec044..fab44f77aa 100644
--- a/java/java.lsp.server/nbcode/integration/nbproject/project.xml
+++ b/java/java.lsp.server/nbcode/integration/nbproject/project.xml
@@ -101,6 +101,14 @@
<implementation-version/>
</run-dependency>
</dependency>
+ <dependency>
+
<code-name-base>org.netbeans.modules.java.file.launcher</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.lsp.server</code-name-base>
<build-prerequisite/>
diff --git
a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/LspSingleFileOptionsQueryImpl.java
b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/LspSingleFileOptionsQueryImpl.java
new file mode 100644
index 0000000000..a796f89ad6
--- /dev/null
+++
b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/LspSingleFileOptionsQueryImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.nbcode.integration;
+
+import
org.netbeans.modules.java.file.launcher.spi.SingleFileOptionsQueryImplementation;
+import
org.netbeans.modules.java.lsp.server.singlesourcefile.SingleFileOptionsQueryImpl;
+import org.openide.util.lookup.ServiceProvider;
+
+@ServiceProvider(service=SingleFileOptionsQueryImplementation.class,
position=100)
+public class LspSingleFileOptionsQueryImpl extends SingleFileOptionsQueryImpl {
+}
diff --git
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
index 4a101d81ce..0c3f2868c5 100644
---
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
+++
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
@@ -1128,28 +1128,30 @@ public class TextDocumentServiceImpl implements
TextDocumentService, LanguageCli
CompletableFuture<CodeAction> future = new CompletableFuture<>();
BACKGROUND_TASKS.post(() -> {
JsonObject data = (JsonObject) unresolved.getData();
- if (data.has(CodeActionsProvider.CODE_ACTIONS_PROVIDER_CLASS)) {
- String providerClass =
data.getAsJsonPrimitive(CodeActionsProvider.CODE_ACTIONS_PROVIDER_CLASS).getAsString();
- for (CodeActionsProvider codeGenerator :
Lookup.getDefault().lookupAll(CodeActionsProvider.class)) {
- if
(codeGenerator.getClass().getName().equals(providerClass)) {
+ if (data != null) {
+ if (data.has(CodeActionsProvider.CODE_ACTIONS_PROVIDER_CLASS))
{
+ String providerClass =
data.getAsJsonPrimitive(CodeActionsProvider.CODE_ACTIONS_PROVIDER_CLASS).getAsString();
+ for (CodeActionsProvider codeGenerator :
Lookup.getDefault().lookupAll(CodeActionsProvider.class)) {
+ if
(codeGenerator.getClass().getName().equals(providerClass)) {
+ try {
+ codeGenerator.resolve(client, unresolved,
data.get(CodeActionsProvider.DATA)).thenAccept(action -> {
+ future.complete(action);
+ });
+ } catch (Exception e) {
+ future.completeExceptionally(e);
+ }
+ return;
+ }
+ }
+ } else if (data.has(URL) && data.has(INDEX)) {
+ LazyCodeAction inputAction =
lastCodeActions.get(data.getAsJsonPrimitive(INDEX).getAsInt());
+ if (inputAction != null) {
try {
- codeGenerator.resolve(client, unresolved,
data.get(CodeActionsProvider.DATA)).thenAccept(action -> {
- future.complete(action);
- });
+
unresolved.setEdit(fromAPI(inputAction.getLazyEdit().get(),
data.getAsJsonPrimitive(URL).getAsString(), client));
} catch (Exception e) {
future.completeExceptionally(e);
+ return;
}
- return;
- }
- }
- } else if (data.has(URL) && data.has(INDEX)) {
- LazyCodeAction inputAction =
lastCodeActions.get(data.getAsJsonPrimitive(INDEX).getAsInt());
- if (inputAction != null) {
- try {
-
unresolved.setEdit(fromAPI(inputAction.getLazyEdit().get(),
data.getAsJsonPrimitive(URL).getAsString(), client));
- } catch (Exception e) {
- future.completeExceptionally(e);
- return;
}
}
}
diff --git
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/singlesourcefile/SingleFileOptionsQueryImpl.java
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/singlesourcefile/SingleFileOptionsQueryImpl.java
index 4ac93cf616..c2e70cc102 100644
---
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/singlesourcefile/SingleFileOptionsQueryImpl.java
+++
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/singlesourcefile/SingleFileOptionsQueryImpl.java
@@ -32,10 +32,8 @@ import
org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient;
import org.openide.filesystems.FileObject;
import org.openide.util.ChangeSupport;
import org.openide.util.Lookup;
-import org.openide.util.lookup.ServiceProvider;
-@ServiceProvider(service=SingleFileOptionsQueryImplementation.class,
position=100)
-public class SingleFileOptionsQueryImpl implements
SingleFileOptionsQueryImplementation {
+public abstract class SingleFileOptionsQueryImpl implements
SingleFileOptionsQueryImplementation {
private final Map<NbCodeLanguageClient, ResultImpl> client2Options = new
WeakHashMap<>();
private final GlobalResultImpl globalOptions = new GlobalResultImpl();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists