GNU bug report logs - #59824
flymake-show-project-diagnotics not updating (eglot for Java with jdtls)

Previous Next

Package: emacs;

Reported by: João Távora <joaotavora <at> gmail.com>

Date: Sun, 4 Dec 2022 20:48:02 UTC

Severity: normal

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59824 in the body.
You can then email your comments to 59824 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59824; Package emacs. (Sun, 04 Dec 2022 20:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to João Távora <joaotavora <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 04 Dec 2022 20:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: David Ventimiglia <davidaventimiglia <at> neptunestation.com>
Cc: "simon254--- via Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java with
 jdtls)
Date: Sun, 4 Dec 2022 20:46:56 +0000
[Message part 1 (text/plain, inline)]
Thanks David. Please also repost here the transcripts of the events buffer
that you collected and shared in the original discussion, for convenience.

On Sun, Dec 4, 2022, 20:39 David Ventimiglia <
davidaventimiglia <at> neptunestation.com> wrote:

> Hello,
>
> When I run flymake-show-project-diagnostics some warnings are listed for
> my Java project. As I jump to those locations and fix the warnings, the
> diagnostics buffer doesn't update. One problem I have is that I don't even
> know where to begin to look in order to troubleshoot this. It could be a
> problem with eglot, jdtls, flymake, or some combination thereof. I started
> a GitHub discussion for the eglot project here:
>
> https://github.com/joaotavora/eglot/discussions/1131#discussion-4626934
>
> In summary, for Java if I add say an unused import to a file, jdtls
> publishes a diagnostic event for this and the flymake buffer shows a
> warning for the unused import.  If I correct the issue by deleting the
> unused import, jdtls again publishes a correct diagnostic report for the
> file, but the flymake diagnostics buffer doesn't update.
>
> After some correspondence with its maintainer, I believe we ruled out the
> jdtls server, since the events buffer seems to show an accurate diagnostics
> report being delivered from the server to Emacs/eglot/flymake.  We're
> wondering if perhaps the problem lies therefore in eglot and/or flymake.  I
> should also say that I'm using the "stock" eglot and flymake built into
> Emacs, as I'm using emacs-snapshot.  Here's my Emacs version info:
>
> GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33,
> cairo version 1.16.0) of 2022-12-03
>
> I grant that this may not be a bug and could be a mis-configuration, but I
> am trying to track that down.  Thanks!
>
> Best,
> David Ventimiglia
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59824; Package emacs. (Sun, 04 Dec 2022 21:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 59824 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: David Ventimiglia <davidaventimiglia <at> neptunestation.com>
Cc: 59824 <at> debbugs.gnu.org
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java
 with jdtls)
Date: Sun, 04 Dec 2022 21:03:12 +0000
David Ventimiglia <davidaventimiglia <at> neptunestation.com> writes:

> I grant that this may not be a bug and could be a mis-configuration,
> but I am trying to track that down.  Thanks!

I may have found the possibly culprit in Eglot.  I wish you could try
the patch after my sig, untested by me.  Also, if you find that the
project listing still doesn't update automatically, please go to its
buffer and type 'g' (and report back here that you needed this extra
step).

João

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e057b12e0ee..3d0e97bba8c 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2048,9 +2048,11 @@ eglot-handle-notification
                     (t          'eglot-note)))
             (mess (source code message)
               (concat source (and code (format " [%s]" code)) ": " message)))
-    (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
+    (if-let* ((path (expand-file-name (eglot--uri-to-path uri)))
+              (buffer (find-buffer-visiting path)))
         (with-current-buffer buffer
           (cl-loop
+           initially (assoc-delete-all path flymake-list-only-diagnostics #'string=)
            for diag-spec across diagnostics
            collect (eglot--dbind ((Diagnostic) range code message severity source tags)
                        diag-spec
@@ -2093,7 +2095,6 @@ eglot-handle-notification
                          (t
                           (setq eglot--diagnostics diags)))))
       (cl-loop
-       with path = (expand-file-name (eglot--uri-to-path uri))
        for diag-spec across diagnostics
        collect (eglot--dbind ((Diagnostic) code range message severity source) diag-spec
                  (setq message (mess source code message))






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59824; Package emacs. (Sun, 04 Dec 2022 23:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 59824 <at> debbugs.gnu.org (full text, mbox):

From: David Ventimiglia <davidaventimiglia <at> neptunestation.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: 59824 <at> debbugs.gnu.org
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java with
 jdtls)
Date: Sun, 4 Dec 2022 15:22:57 -0800
[Message part 1 (text/plain, inline)]
That seems to have fixed it.  Can you explain what's going on here?  To my
untutored eye, it looks we're doing the following:

   1. In addition to defining the "buffer" variable from the "uri", we're
   now also defining "path" from the "uri".
   2. Using the value of "path" to purge all entries from
   "flymake-list-only-diagnostics" whose key is string= to the "path".
   3. Further down in the function, no longer setting "path" while using
   cl-loop to loop over "diagnostics", presumably because that's redundant now
   that "path" has been defined above.

Broadly, it looks like diagnostics were sorta *cached* and if the eglot
backed publishes an empty set of diagnostics for a file (i.e., the file has
been corrected) then we make sure to purge the stale cache.  Or something
like that.  Am I close?

Thanks!
David

On Sun, Dec 4, 2022 at 1:01 PM João Távora <joaotavora <at> gmail.com> wrote:

> David Ventimiglia <davidaventimiglia <at> neptunestation.com> writes:
>
> > I grant that this may not be a bug and could be a mis-configuration,
> > but I am trying to track that down.  Thanks!
>
> I may have found the possibly culprit in Eglot.  I wish you could try
> the patch after my sig, untested by me.  Also, if you find that the
> project listing still doesn't update automatically, please go to its
> buffer and type 'g' (and report back here that you needed this extra
> step).
>
> João
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index e057b12e0ee..3d0e97bba8c 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -2048,9 +2048,11 @@ eglot-handle-notification
>                      (t          'eglot-note)))
>              (mess (source code message)
>                (concat source (and code (format " [%s]" code)) ": "
> message)))
> -    (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
> +    (if-let* ((path (expand-file-name (eglot--uri-to-path uri)))
> +              (buffer (find-buffer-visiting path)))
>          (with-current-buffer buffer
>            (cl-loop
> +           initially (assoc-delete-all path flymake-list-only-diagnostics
> #'string=)
>             for diag-spec across diagnostics
>             collect (eglot--dbind ((Diagnostic) range code message
> severity source tags)
>                         diag-spec
> @@ -2093,7 +2095,6 @@ eglot-handle-notification
>                           (t
>                            (setq eglot--diagnostics diags)))))
>        (cl-loop
> -       with path = (expand-file-name (eglot--uri-to-path uri))
>         for diag-spec across diagnostics
>         collect (eglot--dbind ((Diagnostic) code range message severity
> source) diag-spec
>                   (setq message (mess source code message))
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59824; Package emacs. (Mon, 05 Dec 2022 11:32:01 GMT) Full text and rfc822 format available.

Message #14 received at 59824 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: David Ventimiglia <davidaventimiglia <at> neptunestation.com>
Cc: 59824 <at> debbugs.gnu.org
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java with
 jdtls)
Date: Mon, 5 Dec 2022 11:30:54 +0000
[Message part 1 (text/plain, inline)]
On Sun, Dec 4, 2022 at 11:23 PM David Ventimiglia <
davidaventimiglia <at> neptunestation.com> wrote:
>
> That seems to have fixed it.  Can you explain what's going on here?

What's going on is "a lot" or "not much" depending on the level of detail
you're after.

There are two main types of project-wide diagnostic, as described in the
manual,
depending on whether the file that the diagnostic refers to is or isn't
visited by emacs
with Flymake enabled.

As [1] explains, the unvisited type can be handled by "foreign" or
"list-only" diagnostics.
Eglot uses the latter.  When Eglot is activated in a buffer visiting one of
the files that
were in 'flymake-list-only-diagnostics' it needs to remember to remove that
file from
that list, as it is no longer needed there.  This wasn't happening and my
patch fixes it.
The project listing is then refreshed automatically (at least it seems it
is, according to
your report).

Hope this helps.

> To my untutored  eye, it looks we're doing the following. [...] Am I
close?

To be honest, I don't think so. At least I don't recognize in your
description the design
I put forth some time ago (and which I had since forgotten until this bug).

João

[1]:
https://www.gnu.org/software/emacs/manual/html_node/flymake/Foreign-and-list_002donly-diagnostics.html
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59824; Package emacs. (Mon, 05 Dec 2022 22:29:01 GMT) Full text and rfc822 format available.

Message #17 received at 59824 <at> debbugs.gnu.org (full text, mbox):

From: David Ventimiglia <davidaventimiglia <at> neptunestation.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: 59824 <at> debbugs.gnu.org
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java with
 jdtls)
Date: Mon, 5 Dec 2022 14:28:01 -0800
[Message part 1 (text/plain, inline)]
No worries.  I just updated the bug with the additional info.  I trust you
can take it from here.  Thanks!

On Mon, Dec 5, 2022 at 3:31 AM João Távora <joaotavora <at> gmail.com> wrote:

> On Sun, Dec 4, 2022 at 11:23 PM David Ventimiglia <
> davidaventimiglia <at> neptunestation.com> wrote:
> >
> > That seems to have fixed it.  Can you explain what's going on here?
>
> What's going on is "a lot" or "not much" depending on the level of detail
> you're after.
>
> There are two main types of project-wide diagnostic, as described in the
> manual,
> depending on whether the file that the diagnostic refers to is or isn't
> visited by emacs
> with Flymake enabled.
>
> As [1] explains, the unvisited type can be handled by "foreign" or
> "list-only" diagnostics.
> Eglot uses the latter.  When Eglot is activated in a buffer visiting one
> of the files that
> were in 'flymake-list-only-diagnostics' it needs to remember to remove
> that file from
> that list, as it is no longer needed there.  This wasn't happening and my
> patch fixes it.
> The project listing is then refreshed automatically (at least it seems it
> is, according to
> your report).
>
> Hope this helps.
>
> > To my untutored  eye, it looks we're doing the following. [...] Am I
> close?
>
> To be honest, I don't think so. At least I don't recognize in your
> description the design
> I put forth some time ago (and which I had since forgotten until this bug).
>
> João
>
> [1]:
> https://www.gnu.org/software/emacs/manual/html_node/flymake/Foreign-and-list_002donly-diagnostics.html
>
>
[Message part 2 (text/html, inline)]

Reply sent to João Távora <joaotavora <at> gmail.com>:
You have taken responsibility. (Wed, 07 Dec 2022 11:34:02 GMT) Full text and rfc822 format available.

Notification sent to João Távora <joaotavora <at> gmail.com>:
bug acknowledged by developer. (Wed, 07 Dec 2022 11:34:02 GMT) Full text and rfc822 format available.

Message #22 received at 59824-done <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: David Ventimiglia <davidaventimiglia <at> neptunestation.com>,
 59824-done <at> debbugs.gnu.org
Subject: Re: flymake-show-project-diagnotics not updating (eglot for Java with
 jdtls)
Date: Wed, 7 Dec 2022 11:34:11 +0000
[Message part 1 (text/plain, inline)]
I've now pushed a fix for this in the emacs-29 branch.

Marking this bug done.

Thanks,
João
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Jan 2023 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 84 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.