GNU bug report logs -
#75764
30.0.50; [PATCH] java-ts-mode: Constant highlighting no longer captures Java annotations.
Previous Next
Reported by: Vincenzo Pupillo <v.pupillo <at> gmail.com>
Date: Wed, 22 Jan 2025 15:39:02 UTC
Severity: normal
Tags: patch
Found in version 30.0.50
Fixed in version 30.2
Done: Stefan Kangas <stefankangas <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 75764 in the body.
You can then email your comments to 75764 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Wed, 22 Jan 2025 15:39:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Vincenzo Pupillo <v.pupillo <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 22 Jan 2025 15:39:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Ciao,
the attached patch fixes a problem with highlighting constants in java-ts
mode. Annotations such as @GET were previously being captured by the regular
expression used for constants.
The patch can be safely applied to Emacs 31.
Thanks.
Vincenzo
[0001-Constant-highlighting-no-longer-captures-Java-annota.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Sat, 25 Jan 2025 10:46:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 75764 <at> debbugs.gnu.org (full text, mbox):
> From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
> Date: Wed, 22 Jan 2025 16:38:20 +0100
>
> Ciao,
> the attached patch fixes a problem with highlighting constants in java-ts
> mode. Annotations such as @GET were previously being captured by the regular
> expression used for constants.
> The patch can be safely applied to Emacs 31.
>
> Thanks.
>
> Vincenzo
Yuan and Theo, any comments?
> >From 82e2e6d1d8827f9ed811760e3b08fb637b33f958 Mon Sep 17 00:00:00 2001
> From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
> Date: Wed, 22 Jan 2025 16:14:41 +0100
> Subject: [PATCH] Constant highlighting no longer captures Java annotations.
>
> * lisp/progmodes/java-ts-mode.el
> (java-ts-mode--fontify-constant): New function.
> (java-ts-mode--font-lock-settings): Use it.
> ---
> lisp/progmodes/java-ts-mode.el | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el
> index 6823cb4f38a..849ab23ef3e 100644
> --- a/lisp/progmodes/java-ts-mode.el
> +++ b/lisp/progmodes/java-ts-mode.el
> @@ -164,6 +164,23 @@ java-ts-mode--string-highlight-helper
> (error
> `((string_literal) @font-lock-string-face))))
>
> +(defun java-ts-mode--fontify-constant (node override start end &rest _)
> + "Fontify a Java constant.
> +In Java the names of variables declared class constants and of ANSI
> +constants should be all uppercase with words separated by underscores.
> +This function also prevents annotations from being highlighted as if
> +they were constants.
> +For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'."
> + (let ((node-start (treesit-node-start node))
> + (case-fold-search nil))
> + (when (and
> + (not (equal (char-before node-start) ?@)) ;; skip annotations
> + (string-match "\\`[A-Z_][0-9A-Z_]*\\'" (treesit-node-text node)))
> + (treesit-fontify-with-override
> + node-start (treesit-node-end node)
> + 'font-lock-constant-face override
> + start end))))
> +
> (defvar java-ts-mode--font-lock-settings
> (treesit-font-lock-rules
> :language 'java
> @@ -174,8 +191,7 @@ java-ts-mode--font-lock-settings
> :language 'java
> :override t
> :feature 'constant
> - `(((identifier) @font-lock-constant-face
> - (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face))
> + `((identifier) @java-ts-mode--fontify-constant
> [(true) (false)] @font-lock-constant-face)
> :language 'java
> :override t
> --
> 2.48.1
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Tue, 28 Jan 2025 01:36:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 75764 <at> debbugs.gnu.org (full text, mbox):
> On Jan 25, 2025, at 2:45 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
>> Date: Wed, 22 Jan 2025 16:38:20 +0100
>>
>> Ciao,
>> the attached patch fixes a problem with highlighting constants in java-ts
>> mode. Annotations such as @GET were previously being captured by the regular
>> expression used for constants.
>> The patch can be safely applied to Emacs 31.
>>
>> Thanks.
>>
>> Vincenzo
>
> Yuan and Theo, any comments?
>
>>> From 82e2e6d1d8827f9ed811760e3b08fb637b33f958 Mon Sep 17 00:00:00 2001
>> From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
>> Date: Wed, 22 Jan 2025 16:14:41 +0100
>> Subject: [PATCH] Constant highlighting no longer captures Java annotations.
>>
>> * lisp/progmodes/java-ts-mode.el
>> (java-ts-mode--fontify-constant): New function.
>> (java-ts-mode--font-lock-settings): Use it.
>> ---
>> lisp/progmodes/java-ts-mode.el | 20 ++++++++++++++++++--
>> 1 file changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el
>> index 6823cb4f38a..849ab23ef3e 100644
>> --- a/lisp/progmodes/java-ts-mode.el
>> +++ b/lisp/progmodes/java-ts-mode.el
>> @@ -164,6 +164,23 @@ java-ts-mode--string-highlight-helper
>> (error
>> `((string_literal) @font-lock-string-face))))
>>
>> +(defun java-ts-mode--fontify-constant (node override start end &rest _)
>> + "Fontify a Java constant.
>> +In Java the names of variables declared class constants and of ANSI
>> +constants should be all uppercase with words separated by underscores.
>> +This function also prevents annotations from being highlighted as if
>> +they were constants.
>> +For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'."
>> + (let ((node-start (treesit-node-start node))
>> + (case-fold-search nil))
>> + (when (and
>> + (not (equal (char-before node-start) ?@)) ;; skip annotations
>> + (string-match "\\`[A-Z_][0-9A-Z_]*\\'" (treesit-node-text node)))
>> + (treesit-fontify-with-override
>> + node-start (treesit-node-end node)
>> + 'font-lock-constant-face override
>> + start end))))
>> +
>> (defvar java-ts-mode--font-lock-settings
>> (treesit-font-lock-rules
>> :language 'java
>> @@ -174,8 +191,7 @@ java-ts-mode--font-lock-settings
>> :language 'java
>> :override t
>> :feature 'constant
>> - `(((identifier) @font-lock-constant-face
>> - (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face))
>> + `((identifier) @java-ts-mode--fontify-constant
>> [(true) (false)] @font-lock-constant-face)
>> :language 'java
>> :override t
>> --
>> 2.48.1
>>
Seems reasonable to me. Tree-sitter’s query doesn’t support negation match, so we can’t match constants that are not annotations. But I don’t want these fixes to delay emacs 30 (they will keep coming), so perhaps we can apply this to emacs-30 after release, WDYT, Eli?
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Tue, 28 Jan 2025 12:44:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 75764 <at> debbugs.gnu.org (full text, mbox):
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Mon, 27 Jan 2025 17:35:30 -0800
> Cc: Vincenzo Pupillo <v.pupillo <at> gmail.com>,
> Theodor Thornhill <theo <at> thornhill.no>,
> 75764 <at> debbugs.gnu.org
>
> Seems reasonable to me. Tree-sitter’s query doesn’t support negation match, so we can’t match constants that are not annotations. But I don’t want these fixes to delay emacs 30 (they will keep coming), so perhaps we can apply this to emacs-30 after release, WDYT, Eli?
Fine by me, thanks.
Added tag(s) pending.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 11 Feb 2025 07:19:01 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefan Kangas <stefankangas <at> gmail.com>
:
You have taken responsibility.
(Sun, 23 Feb 2025 19:50:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Vincenzo Pupillo <v.pupillo <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 23 Feb 2025 19:50:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 75764-done <at> debbugs.gnu.org (full text, mbox):
Version: 30.2
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Mon, 27 Jan 2025 17:35:30 -0800
>> Cc: Vincenzo Pupillo <v.pupillo <at> gmail.com>,
>> Theodor Thornhill <theo <at> thornhill.no>,
>> 75764 <at> debbugs.gnu.org
>>
>> Seems reasonable to me. Tree-sitter’s query doesn’t support negation match, so
>> we can’t match constants that are not annotations. But I don’t want these
>> fixes to delay emacs 30 (they will keep coming), so perhaps we can apply this
>> to emacs-30 after release, WDYT, Eli?
>
> Fine by me, thanks.
Since Emacs 30.1 is now released, I have pushed this to emacs-30 as
commit 563b6f94511.
I'm therefore closing this bug report.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Mon, 24 Feb 2025 00:05:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 75764-done <at> debbugs.gnu.org (full text, mbox):
Thanks!
> 在 2025年2月23日,上午11:49,Stefan Kangas <stefankangas <at> gmail.com> 写道:
>
> Version: 30.2
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Yuan Fu <casouri <at> gmail.com>
>>> Date: Mon, 27 Jan 2025 17:35:30 -0800
>>> Cc: Vincenzo Pupillo <v.pupillo <at> gmail.com>,
>>> Theodor Thornhill <theo <at> thornhill.no>,
>>> 75764 <at> debbugs.gnu.org
>>>
>>> Seems reasonable to me. Tree-sitter’s query doesn’t support negation match, so
>>> we can’t match constants that are not annotations. But I don’t want these
>>> fixes to delay emacs 30 (they will keep coming), so perhaps we can apply this
>>> to emacs-30 after release, WDYT, Eli?
>>
>> Fine by me, thanks.
>
> Since Emacs 30.1 is now released, I have pushed this to emacs-30 as
> commit 563b6f94511.
>
> I'm therefore closing this bug report.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75764
; Package
emacs
.
(Mon, 24 Feb 2025 06:59:01 GMT)
Full text and
rfc822 format available.
Message #27 received at 75764-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thank you both!
Vincenzo
Il 24 febbraio 2025 01:03:57 CET, Fu Yuan <casouri <at> gmail.com> ha scritto:
>
>Thanks!
>
>> 在 2025年2月23日,上午11:49,Stefan Kangas <stefankangas <at> gmail.com> 写道:
>>
>> Version: 30.2
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>> Date: Mon, 27 Jan 2025 17:35:30 -0800
>>>> Cc: Vincenzo Pupillo <v.pupillo <at> gmail.com>,
>>>> Theodor Thornhill <theo <at> thornhill.no>,
>>>> 75764 <at> debbugs.gnu.org
>>>>
>>>> Seems reasonable to me. Tree-sitter’s query doesn’t support negation match, so
>>>> we can’t match constants that are not annotations. But I don’t want these
>>>> fixes to delay emacs 30 (they will keep coming), so perhaps we can apply this
>>>> to emacs-30 after release, WDYT, Eli?
>>>
>>> Fine by me, thanks.
>>
>> Since Emacs 30.1 is now released, I have pushed this to emacs-30 as
>> commit 563b6f94511.
>>
>> I'm therefore closing this bug report.
[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
.
(Mon, 24 Mar 2025 11:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 85 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.