You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "jtulach (via GitHub)" <gi...@apache.org> on 2024/07/15 12:24:14 UTC
[PR] Using LSP's ErrorProvider [netbeans]
jtulach opened a new pull request, #7579:
URL: https://github.com/apache/netbeans/pull/7579
Continuation of
- #7505
- #7483
Let's use [ErrorProvider](https://bits.netbeans.org/22/javadoc/org-netbeans-api-lsp/org/netbeans/spi/lsp/ErrorProvider.html) when available and display its hints in NetBeans.

The above picture shows errors provided by [Enso IGV Plugin rev. 1.40.554](https://github.com/enso-org/enso/actions/runs/9937051398) in NetBeans as proposed by https://github.com/enso-org/enso/pull/10553
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2248154974
> > I can register `MicronautSymbolErrorProvider` in VSCode only just like I did for `JavaErrorProvider`. Or we can remove `org.netbeans.modules.csl.api.HintsProvider` implementation in `micronaut` module and let the bridge handle the error presentation. I let @dbalek decide.
>
> In an ideal case, `MicronautSymbolErrorProvider` should provide the errors for both NetBeans IDE and VSCode.
Looks like there are no doubled Micronaut warnings. Things look OK:

In such case I rather leave Micronaut support untouched.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2228742269
the slightly concerning aspect of the last revert was that it caused multiple issues in seemingly unrelated areas - and was only noticed during manual testing. It broke auto completion in the debug expression eval window, in a maven properties editor and @matthiasblaesing found also something in typescript (don't know the details). This indicates that there is a hole in the unit test coverage.
You can find the traces under the original PR https://github.com/apache/netbeans/pull/7505#issuecomment-2192369332.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1683288421
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ if (p.getClass().getName().equals("org.netbeans.modules.editor.hints.lsp.HintsDiagnosticsProvider")) {
+ continue;
+ }
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
+ }
+ }
+
+ private void computeHints(final ErrorProvider.Kind type, ErrorProvider p, final String prefix) {
+ List<ErrorDescription> arr = new ArrayList<>();
+ ErrorProvider.Context errorCtx = new ErrorProvider.Context(file, type);
+ List<? extends Diagnostic> errors = p.computeErrors(errorCtx);
+ if (errors != null) {
+ for (Diagnostic e : errors) {
+ final Severity s = Severity.ERROR;
+ ErrorDescription descr = ErrorDescriptionFactory.createErrorDescription(s,
+ e.getDescription(),
+ file,
+ e.getStartPosition().getOffset(),
+ e.getEndPosition().getOffset()
+ );
+ arr.add(descr);
+ }
+ applyHints(prefix, p, arr);
+ }
+ }
+
+ protected void applyHints(final String prefix, ErrorProvider p, List<ErrorDescription> arr) {
+ HintsController.setErrors(file, prefix + ":" + p.getClass().getSimpleName(), arr);
Review Comment:
```suggestion
HintsController.setErrors(file, prefix + ":" + p.getClass().getName(), arr);
```
To limit ambiguities.
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -94,7 +95,9 @@ public class JavaErrorProvider implements ErrorProvider {
@Override
public List<? extends Diagnostic> computeErrors(Context context) {
List<Diagnostic> result = new ArrayList<>();
-
+ if (!GraphicsEnvironment.isHeadless()) {
Review Comment:
I think I would rather suggest to drop the `@MimeRegistration` on this class, and register the class in `nbcode`. A similar pattern is already used for numerous services. Although in this case, it may be necessary/better to create the registration manually in `layer.xml`, for other services we do it by having a subclass in `nbcode` with an appropriate registration annotation.
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ if (p.getClass().getName().equals("org.netbeans.modules.editor.hints.lsp.HintsDiagnosticsProvider")) {
Review Comment:
Is it possible to use the same trick as for `JavaErrorProvider` for this one as well? Regardless of which way is used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2238071459
> @jtulach I noticed while helping to merge PRs for NB23 that this PR has no milestone set, Please set the intended milestone, thanks!
I would love to see (some of these fixes - e.g. #7505 as reapplied by 8356885712afdd792c1b5e32a445230b9cec9c77 in this PR, #7483 and the _rest of this PR_) in NetBeans release as soon as possible. Thus adding NB23 label. If this PR isn't in integrateable state as a whole in time, I can split this PR to smaller PRs that are integratable - but it is essential for Enso to have
- navigator content
- code completion
- errors
displayed in NetBeans. As debugging VSCode extension is really a pain. It is way easier to debug in NetBeans and only when everything works generate the final `.vsix`... That's why I am trying so hard to get these `lsp.api` bridges in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1687064835
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
+ }
+ }
+
+ private void computeHints(final ErrorProvider.Kind type, ErrorProvider p, final String prefix) {
+ List<ErrorDescription> arr = new ArrayList<>();
+ ErrorProvider.Context errorCtx = new ErrorProvider.Context(file, type);
+ List<? extends Diagnostic> errors = p.computeErrors(errorCtx);
+ if (errors != null) {
+ for (Diagnostic e : errors) {
+ final Severity s = Severity.ERROR;
Review Comment:
Looking at `LanguageClientImpl` I think this is better:
```suggestion
final Severity s;
switch(e.getSeverity()) {
case Error:
s = Severity.ERROR; break;
case Warning:
s = Severity.WARNING; break;
case Information:
case Hint:
default:
s = Severity.HINT; break;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach merged PR #7579:
URL: https://github.com/apache/netbeans/pull/7579
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2230739035
> I see failure in [Check PR labels](https://github.com/apache/netbeans/actions/runs/9941781478/job/27462251248?pr=7579#step:2:17), but I am not sure why? There are **LSP** and **VSCode Extension** labels on this PR.

The CI checks are all green now, but I'd rather wait for Matthias to confirm the behavior is better when he edits TypeScript. On the other hand, I'd like these `lsp.client` changes to get into next version of NetBeans. My colleagues are eagerly waiting for Enso support in NetBeans/IGV and they don't build NetBeans from source.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "dbalek (via GitHub)" <gi...@apache.org>.
dbalek commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2247116970
> > I also see `MicronautSymbolErrorProvider` in the java lookup and while currently there does not seem to be a provider that reports the same problems in NetBeans IDE, it might quickly turn up and cause similar problems as the JavaErrorManager.
>
> I can register `MicronautSymbolErrorProvider` in VSCode only just like I did for `JavaErrorProvider`. Or we can remove `org.netbeans.modules.csl.api.HintsProvider` implementation in `micronaut` module and let the bridge handle the error presentation. I let @dbalek decide.
In an ideal case, `MicronautSymbolErrorProvider` should provide the errors for both NetBeans IDE and VSCode.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2229963506
I see failure in [Check PR labels](https://github.com/apache/netbeans/actions/runs/9941781478/job/27462251248?pr=7579#step:2:17), but I am not sure why? There are **LSP** and **VSCode Extension** labels on this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2240946735
> freeze for NB23 was moved from 15th to the 26th (next Friday) so there is time to review/test this properly without rushing anything in https://lists.apache.org/thread/pr3dnjdkot8kny9g2htqlpcg1s9f9t45
Thanks for letting me know. I believe both NetBeans as well as VSCode are working fine with the current state of this PR:
- Matthias's [debugging scenario](https://github.com/apache/netbeans/pull/7579#issuecomment-2236516957) works and there are no duplications
- VSCode shows hints in `Dummy.java` file, can debug, offers code completion
I am confident things are OK this time. Unless I hear objections, I plan to integrate early next week.
> I think the main discovery here remains that none of the existing tests picked any of the problems up. Would be good to check why that happened (is the module not loaded or something similar?). E.g regression tests for double occurrence of hint annotations might be something we could add (but I would be surprised if they weren't there yet).
Hints are certainly tested, but I think they are tested via "unit tests". Such kind of tests can detect missing functionality of own module, but cannot detect extra functionality of completely different module. Such an integration test would need `NbModuleSuite` with all enabled modules - I don't think NetBeans has such a test these days.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2236516957
> You are hitting the codepath in `LspCompletionProviderImpl.java` line 55.
Thanks for the hint. With such a error identification, it is easy to fix it: 87523ab. Now the debugging experience looks as expected (I'd say):

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1683326766
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -94,7 +95,9 @@ public class JavaErrorProvider implements ErrorProvider {
@Override
public List<? extends Diagnostic> computeErrors(Context context) {
List<Diagnostic> result = new ArrayList<>();
-
+ if (!GraphicsEnvironment.isHeadless()) {
Review Comment:
This gives me bad vibes and is only a partial solution. I placed a breakpoint in `ErrorProviderBridge#run` and I see three `ErrorProvider` there:
1. `org.netbeans.modules.java.hints.infrastructure.JavaErrorProvider`
2. `org.netbeans.modules.editor.hints.lsp.HintsDiagnosticsProvider`
3. `org.netbeans.modules.micronaut.symbol.MicronautSymbolErrorProvider`
(1) is now handled by checking `GraphicsEnvironment#isHeadless`, (2) ist explicitly filtered out by its name, (3) is retained.
This will become whac-a-mole because the interaction are not obvious. Would a different approach make sense where an autoloaded helper module, that depends on the modules, that provides the LSP implementation, provides the bridge only for that module? That way the interaction is easier to see and if necessary easy to drop.
I don't know the enso module name but assuming it is `enso-lsp`, a module `enso-lsp.nb` could be used to provide the integration limited to the enso type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2239738030
freeze for NB23 was moved from 15th to the 26th (next Friday) so there is time to review/test this properly without rushing anything in https://lists.apache.org/thread/pr3dnjdkot8kny9g2htqlpcg1s9f9t45
I think the main discovery here remains that none of the existing tests picked any of the problems up. Would be good to check why that happened (is the module not loaded or something similar?). E.g regression tests for double occurrence of hint annotations might be something we could add (but I would be surprised if they weren't there yet).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2228409938
What does continuation of #7505 mean? That was reverted in #7528
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1689383219
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
Review Comment:
The [Enso error provider](https://github.com/enso-org/enso/blob/develop/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/enso/EnsoErrorProvider.java#L28) is only computing `ERRORS` and returns empty array for `HINTS` request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jlahoda (via GitHub)" <gi...@apache.org>.
jlahoda commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1690852374
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
Review Comment:
I would expect disjoint sets to be provided, which are then automatically merged, and the joint result is presented to the used. If a provider returns the same diagnostics from both queries, it will be duplicated for the user, I think.
The main purpose of this split is to show errors to the user quickly, and then take the time needed to compute the warnings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2228722114
> What does continuation of #7505 mean? That was reverted in #7528
Interesting. But I want the change in - new attempt 8356885 with additional fix in ea184f7afc76d0e9c9747c22479ab388a92cd551. I tested the TypeScript editing on `explorer.ts` from `java/java.lsp.server/vscode` project. I am getting no `NullPointerException` (as reported by #7528).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1677745661
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java:
##########
@@ -1032,7 +1032,10 @@ public CompletableFuture<List<Either<Command, CodeAction>>> codeAction(CodeActio
continue;
}
}
- Optional<Diagnostic> diag = diagnostics.stream().filter(d -> entry.getKey().equals(d.getCode().getLeft())).findFirst();
+ Optional<Diagnostic> diag = diagnostics.stream().filter(d -> {
+ String code = d.getCode() != null ? d.getCode().getLeft() : null;
Review Comment:
Unrelated to the core of this PR, but discovered at the same time. According to the [LSP Spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic) `code` field is **optional**. Need to check for `null`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2248161738
Unless there are objections, I will merge tomorrow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2236478654
Thank you for the QA, Matthias.
> Same file shows a new regression introduced by this. Before your change the unused variable "list" (line 5) is marked, but only slightly
> now it is reported as a warning:
> And I think the popup also shows, that the error is reported twice.
This one is particularly tricky. Unlike #7505 and #7483 - there is no declarative registration for _"hints"_ (am I right @jlahoda). As such it is hard to find out whether there is a better alternative to `JavaErrorManager` or not. I can imagine various tricks to do such check (annotating `ErrorProvider` with some annotation, for example), but to keep the scope as small as possible I suggest just ab7bdc9
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1682827605
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -94,7 +95,9 @@ public class JavaErrorProvider implements ErrorProvider {
@Override
public List<? extends Diagnostic> computeErrors(Context context) {
List<Diagnostic> result = new ArrayList<>();
-
+ if (!GraphicsEnvironment.isHeadless()) {
Review Comment:
The `java.lsp.server` project is using `isHeadless()` to detect whether the code is running in VSCode or in NetBeans IDE. Using it here to solve https://github.com/apache/netbeans/pull/7579#issuecomment-2236478654 inquiry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2251038358
@jtulach thanks for cleaning up and explaining one real example
@jlahoda thanks for chiming in and giving the overall perspective!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2231063752
> I see failure in [Check PR labels](https://github.com/apache/netbeans/actions/runs/9941781478/job/27462251248?pr=7579#step:2:17), but I am not sure why? There are **LSP** and **VSCode Extension** labels on this PR.
workflow runs are like container images. If you start one, the state doesn't change (restarts) until you build a new image. New ones are built when they are freshly triggered (e.g PR sync). This is also mentioned on the short reviewer guide we have on the wiki which is linked in the log when the label validation fails. So my guess is that this is what happened but I wasn't there to observe it. Neil forced a fresh workflow run and everything is green.
> On the other hand, I'd like these lsp.client changes to get into next version of NetBeans.
you probably saw that I added the https://github.com/apache/netbeans/labels/ci%3Adev-build label. This makes it easier to manually test this PR. As previously mentioned, the last time this caused problems and had to be reverted, it broke completion in seemingly unrelated areas + possibly more things without causing test failures. So I don't even know what features this can influence or what to look out for.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2237491834
@jtulach I noticed while helping to merge PRs for NB23 that this PR has no milestone set, Please set the intended milestone, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1683753389
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ if (p.getClass().getName().equals("org.netbeans.modules.editor.hints.lsp.HintsDiagnosticsProvider")) {
Review Comment:
I don't think that's possible. But I'll think about it and give it a try.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2242482398
The best way to break things is to test everything and then make additional commit...
> This is still broken. The layer registration of `JavaErrorProvider` in `java.lsp.server` (added in [275ade6](https://github.com/apache/netbeans/commit/275ade6a0dd52681c3b8996e004496dfa099ada6)) restores the broken behavior, that should have been fixed by `512ee110f7865130c16a85d930a2217fcc4545a2`. I.e. the invalid error markers are back again.
Fixed by registering the provider only for tests, as was my intention to begin with. Please accept my apology for useless round of review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2242486600
> I also see `MicronautSymbolErrorProvider` in the java lookup and while currently there does not seem to be a provider that reports the same problems in NetBeans IDE, it might quickly turn up and cause similar problems as the JavaErrorManager.
I can register `MicronautSymbolErrorProvider` in VSCode as `JavaErrorProvider`. Or we can remove `org.netbeans.modules.csl.api.HintsProvider` implementation in `micronaut` moduel and let the bridge handle the error presentation. I let @dbalek decide.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1687066207
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
Review Comment:
Do the runs with `ErrorProvider.Kind.ERRORS` and and `ErrorProvider.Kind.HINTS` yield disjunct sets of error sets? If not, what is the result for the user?
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ computeHints(ErrorProvider.Kind.ERRORS, p, "lsp:errors");
+ computeHints(ErrorProvider.Kind.HINTS, p, "lsp:hints");
+ }
+ }
+
+ private void computeHints(final ErrorProvider.Kind type, ErrorProvider p, final String prefix) {
+ List<ErrorDescription> arr = new ArrayList<>();
+ ErrorProvider.Context errorCtx = new ErrorProvider.Context(file, type);
+ List<? extends Diagnostic> errors = p.computeErrors(errorCtx);
+ if (errors != null) {
+ for (Diagnostic e : errors) {
+ final Severity s = Severity.ERROR;
Review Comment:
Looking at `LanguageClientImpl` I think this is better:
```suggestion
final Severity s;
switch(e.getSeverity()) {
case Error:
s = Severity.ERROR; break;
case Warning:
s = Severity.WARNING; break;
case Information:
s = Severity.HINT; break;
case Hint:
s = Severity.HINT; break;
default:
s = Severity.HINT; break;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1685271084
##########
ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/ErrorProviderBridge.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.lsp.client.bindings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.Diagnostic;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.editor.hints.HintsController;
+import org.netbeans.spi.editor.hints.Severity;
+import org.netbeans.spi.lsp.ErrorProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.RequestProcessor;
+import org.openide.util.WeakListeners;
+
+class ErrorProviderBridge implements Runnable, DocumentListener {
+
+ private final FileObject file;
+ private final RequestProcessor.Task task;
+ private final Collection<? extends ErrorProvider> errorProviders;
+ private final DocumentListener listener;
+
+ ErrorProviderBridge(Document doc, FileObject file, Collection<? extends ErrorProvider> errorProviders, RequestProcessor rp) {
+ this.file = file;
+ this.errorProviders = errorProviders;
+ this.task = rp.create(this);
+ this.listener = WeakListeners.create(DocumentListener.class, this, doc);
+ doc.addDocumentListener(listener);
+ }
+
+ final void start() {
+ task.schedule(0);
+ }
+
+ final void waitFinished() {
+ task.waitFinished();
+ }
+
+ @Override
+ public final void run() {
+ for (ErrorProvider p : errorProviders) {
+ if (p.getClass().getName().equals("org.netbeans.modules.editor.hints.lsp.HintsDiagnosticsProvider")) {
Review Comment:
Looks like it works. Done in f1678df. Thanks for the idea. Registering in VSCode's `nbcode` suite is a neat way to avoid cycles in the delegation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#discussion_r1685266927
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -81,20 +82,18 @@
import org.openide.util.Exceptions;
import org.openide.util.Union2;
-/**
+/** Provides errors and hints for VSCode. This class is abstract to
+ * be subclasses and registered by VSCode extension XML layer.
*
* @author lahvac
*/
-@MimeRegistration(mimeType="text/x-java", service=ErrorProvider.class)
Review Comment:
> ... drop the @MimeRegistration on this class, and register the class in nbcode.
Thanks @jlahoda. Done in 512ee11
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2249341446
Squashed into two commits:
- [Re-apply #7505 that was reverted by #7528 with additional resolved.getDocumentation() can be null](https://github.com/apache/netbeans/pull/7579/commits/c7eda4fa3fdb670a012181f92a6e79df11811322)
- [ErrorProviderBridge exposes content of ErrorProviders to NetBeans IDE](https://github.com/apache/netbeans/pull/7579/commits/557c823ba5244c6d67262eca3ce27d22bc07fc78)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider [netbeans]
Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2228891283
> the slightly concerning aspect of the last revert was that it caused multiple issues in seemingly unrelated areas - and was only noticed during manual testing. It broke auto completion in the debug expression eval window, in a maven properties editor and @matthiasblaesing found also something in typescript (don't know the details). This indicates that there is a hole in the unit test coverage.
Let's do more QA this time.
> You can find the traces under the original PR [#7505 (comment)](https://github.com/apache/netbeans/pull/7505#issuecomment-2192369332).
I believe ea184f7afc76d0e9c9747c22479ab388a92cd551 eliminates the NPE. I never saw the `AssertionError`. If anyone sees it during QA, please give me steps to reproduce.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Using LSP's ErrorProvider & another attempt at CompletionCollector [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #7579:
URL: https://github.com/apache/netbeans/pull/7579#issuecomment-2276404213
@jtulach a new regression was found introduced by this. See #7647
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists