From: Vincenzo Pupillo <v.pupillo@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Theodor Thornhill <theo@thornhill.no>
Cc: 64647@debbugs.gnu.org, Jostein Kjonigsen <jostein@kjonigsen.net>
Subject: bug#64647: treesit-query-error due to a recent change to tree-sitter-javascript grammar definition
Date: Sat, 15 Jul 2023 21:17:54 +0200 [thread overview]
Message-ID: <2289696.ElGaqSPkdT@fedora> (raw)
In-Reply-To: <874jm5rrgk.fsf@thornhill.no>
[-- Attachment #1: Type: text/plain, Size: 2604 bytes --]
Hi Theo,
In data sabato 15 luglio 2023 19:54:03 CEST, Theodor Thornhill ha scritto:
> Eli Zaretskii <eliz@gnu.org> writes:
> >> From: Vincenzo Pupillo <v.pupillo@gmail.com>
> >> Date: Sat, 15 Jul 2023 14:34:29 +0200
> >>
> >> this commit (bb1f97b643b77fc1f082d621bf533b4b14cf0c30) changed the
> >> definition of the JSX grammar to tree-sitter-javascript. This causes a
> >> node type error: "
> >> Error while displaying: (jit-lock-function 1) reported
> >> (treesit-query-error
> >> "Node type error at" 24 "(jsx_opening_element [(nested_identifier
> >> (identifier)) (identifier)] @font-lock-function-call-face)
> >> (jsx_closing_element
> >> [(nested_identifier (identifier)) (identifier)] @font-
> >> lock-function-call-face) (jsx_self_closing_element [(nested_identifier
> >> (identifier)) (identifier)] @font- lock-function-call-face)
> >> (jsx_attribute (property_identifier) @font-lock- constant-face)" "Debug
> >> the query with `treesit-query-validate'")
> >> "
> >> Indentation also has problems due to the deletion of "jsx_fragment"
> >> definition.
> >>
> >> The patch in attachment fixes both problems.
> >
> > Will the patch work with the grammar libraries before the recent
> > change?
>
> It will introduce regressions, but the patch itself is a change for the
> better, both in emacs land and in the grammar itself.
>
> >> p.s. nvim-treesitter tries to limit these problems by indicating which
> >> commit to install. Does it make sense to try a similar approach with
> >> emacs as well?>
> > I think it is better if we make the code work with as many versions as
> > possible, by checking whether a feature exists before using it.
> >
> > Theo, Jostein: any comments or ideas?
> >
> > Thanks.
>
> I don't disagree, but I think this is a difficult problem to solve, but
> with an easy cop-out solution that most other implementors use - just
> refer to the last supported commit. We've had some discussions on this,
> but IIRC we never settled on anything. Personally, I think a
>
> ;;; Tree-sitter-version: bb1f97b643b77fc1f082d621bf533b4b14cf0c30
>
> header may be the simplest way to at least signal some awareness
> here. That way the auto install mechanism can pull that hash directly
> and we can ensure some sort of compatibility checking.
>
> What do you think?
>
> @Vicenzo, seeing as this change only targets the JSX variant in
> js-ts-mode, could you possibly also make the according changes to
> tsx-ts-mode as well?
Yes, and I also attached the previous one with a corrected commit message ((I
had written js-ts-mode.el instead of js.el)
Thanks,
Vincenzo
[-- Attachment #2: 0001-Updated-JSX-support-due-to-changes-in-tree-sitter-ja.patch --]
[-- Type: text/x-patch, Size: 2053 bytes --]
From fab9765fdaa7d4712d0bf3b4b8068d02f4dd73c2 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Sat, 15 Jul 2023 13:47:41 +0200
Subject: [PATCH] Updated JSX support due to changes in tree-sitter-javascript
A recent change in tree-sitter-javascript grammar support for
JSX (commit bb1f97b), changed two things:
1. renamed nested_identifier to member_expression
2. removed jsx_fragment, jsx_text is used instead
* lisp/progmodes/js.el: (js--treesit-font-lock-settings):
replace nested_identifier with member_expression
* lisp/progmodes/js.el: (js--treesit-indent-rules): replace
jsx_fragment with jsx_text
---
lisp/progmodes/js.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index de1a820ba11..7ee72a22daa 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3462,8 +3462,8 @@ js--treesit-indent-rules
((parent-is "statement_block") parent-bol js-indent-level)
;; JSX
- ((match "<" "jsx_fragment") parent 0)
- ((parent-is "jsx_fragment") parent js-indent-level)
+ ((match "<" "jsx_text") parent 0)
+ ((parent-is "jsx_text") parent js-indent-level)
((node-is "jsx_closing_element") parent 0)
((match "jsx_element" "statement") parent js-indent-level)
((parent-is "jsx_element") parent js-indent-level)
@@ -3600,15 +3600,15 @@ js--treesit-font-lock-settings
:language 'javascript
:feature 'jsx
'((jsx_opening_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@font-lock-function-call-face)
(jsx_closing_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@font-lock-function-call-face)
(jsx_self_closing_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@font-lock-function-call-face)
(jsx_attribute
--
2.41.0
[-- Attachment #3: 0002-Updated-JSX-support-due-to-changes-in-tree-sitter-ty.patch --]
[-- Type: text/x-patch, Size: 2381 bytes --]
From 5748f07f1465f30cbd31321d3f6806f8f8cb2b0c Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Sat, 15 Jul 2023 20:37:24 +0200
Subject: [PATCH] Updated JSX support due to changes in tree-sitter-typescript
A recent change in tree-sitter-typescript grammar support for
JSX (commit b893426), changed two things:
1. renamed nested_identifier to member_expression
2. removed jsx_fragment, jsx_text is used instead
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--font-lock-settings):
replace nested_identifier with member_expression
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--indent-rules):
replace jsx_fragment with jsx_text
---
lisp/progmodes/typescript-ts-mode.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index ccf0026d7ba..ea04c6f24a3 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -110,8 +110,8 @@ typescript-ts-mode--indent-rules
((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
,@(when (eq language 'tsx)
- `(((match "<" "jsx_fragment") parent 0)
- ((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
+ `(((match "<" "jsx_text") parent 0)
+ ((parent-is "jsx_text") parent typescript-ts-mode-indent-offset)
((node-is "jsx_closing_element") parent 0)
((match "jsx_element" "statement") parent typescript-ts-mode-indent-offset)
((parent-is "jsx_element") parent typescript-ts-mode-indent-offset)
@@ -294,15 +294,15 @@ typescript-ts-mode--font-lock-settings
:language language
:feature 'jsx
`((jsx_opening_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@typescript-ts-jsx-tag-face)
(jsx_closing_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@typescript-ts-jsx-tag-face)
(jsx_self_closing_element
- [(nested_identifier (identifier)) (identifier)]
+ [(member_expression (identifier)) (identifier)]
@typescript-ts-jsx-tag-face)
(jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face))
--
2.41.0
next prev parent reply other threads:[~2023-07-15 19:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-15 12:34 bug#64647: treesit-query-error due to a recent change to tree-sitter-javascript grammar definition Vincenzo Pupillo
2023-07-15 12:57 ` Eli Zaretskii
2023-07-15 13:23 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-15 17:54 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-15 19:16 ` Eli Zaretskii
2023-07-15 19:39 ` Vincenzo Pupillo
2023-07-15 20:45 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-16 5:13 ` Eli Zaretskii
2023-07-16 8:38 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-16 18:00 ` Vincenzo Pupillo
2023-07-16 18:19 ` bug#64647: " Eli Zaretskii
2023-07-16 18:56 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-17 21:24 ` Vincenzo Pupillo
2023-07-19 5:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-20 10:14 ` Vincenzo Pupillo
2023-07-22 6:41 ` bug#64647: " Eli Zaretskii
2023-07-22 7:29 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-22 8:52 ` Eli Zaretskii
2023-07-22 11:56 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-22 14:10 ` Vincenzo Pupillo
2023-07-22 21:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-22 22:59 ` Yuan Fu
2023-07-23 5:17 ` Eli Zaretskii
2023-07-16 4:48 ` bug#64647: " Eli Zaretskii
2023-07-15 19:17 ` Vincenzo Pupillo [this message]
2023-07-15 20:51 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2289696.ElGaqSPkdT@fedora \
--to=v.pupillo@gmail.com \
--cc=64647@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=jostein@kjonigsen.net \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.