From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs 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 Message-ID: <2289696.ElGaqSPkdT@fedora> References: <2171209.irdbgypaU6@fedora> <83y1jhbad1.fsf@gnu.org> <874jm5rrgk.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart4816812.GXAFRqVoOG" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10847"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64647@debbugs.gnu.org, Jostein Kjonigsen To: Eli Zaretskii , Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 15 21:19:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qKknS-0002ZJ-Cq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Jul 2023 21:19:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKknH-00063U-He; Sat, 15 Jul 2023 15:19:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKknG-00062y-CR for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 15:19:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKknG-0002LY-4p for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 15:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qKknG-0001BF-0b for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 15:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Jul 2023 19:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64647 X-GNU-PR-Package: emacs Original-Received: via spool by 64647-submit@debbugs.gnu.org id=B64647.16894486854452 (code B ref 64647); Sat, 15 Jul 2023 19:19:01 +0000 Original-Received: (at 64647) by debbugs.gnu.org; 15 Jul 2023 19:18:05 +0000 Original-Received: from localhost ([127.0.0.1]:46101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKkmK-00019j-Nm for submit@debbugs.gnu.org; Sat, 15 Jul 2023 15:18:05 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:60869) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKkmI-00019E-Fd for 64647@debbugs.gnu.org; Sat, 15 Jul 2023 15:18:03 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso30865325e9.1 for <64647@debbugs.gnu.org>; Sat, 15 Jul 2023 12:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689448677; x=1692040677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SEyrmM7u8NItHQ/wcux0mAQzwGcxockonR0LUn2YteI=; b=lykn7wVBKQyrbwuqkXvzlZfERz4ryryONFDOHkLIoF7ZcbfSZo4j6Ka7dIRYrBVd63 8MhZgcLY+O3O8oeoVRQ9ZkJfPbwcCBhqltH2hI/WRTT+AL8YKli2ZNHOqv/Nbsn6dPbC K8rKkYoOrm5/9RSVJiviOp1sqrphO1lFac7aUa6n4lTLQ8kaaI/xUPNV27071zQ3YZN+ kFxbBTRJjE6bHmFnFRF2qLJFFp98k7UpeAoaMonoUIPfSlwStQpaj5aoPxiWx868Qnr8 W8V4g8VXGPzZyi3JDSp2V4H6Z0HZx1c+EAFs1j7wQnhBhXKNL4+Dk49HmT12knSuHRK8 0zVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689448677; x=1692040677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SEyrmM7u8NItHQ/wcux0mAQzwGcxockonR0LUn2YteI=; b=OFbBkeJjgTczxrHJeNJTnvSn0rIxIK4ZPVtpwL94Shw9ZlsN8sFFqf8gIA8v1TCBou OmYQ9vkYTukKP2nIaVy0liB8ZtM57X6aUywL9PZg00hsECKxskBBkPsrvyWAGzHq15Tl X96AZKoqxbPyQbNS47lLDX7ckAPBRaxv2rEVo2ZAI6nk8nPCXkq+qjp8NJPQQnftw07H Y2UDq35NnylSZIh8pf7MS/PmiDRodGigo7DBmZ0Ls3CBKPRwghKTpvrXJyLzzwQun6nL 9JGt0JBf9sg7PWZ7kL5bRXiMOU2KUAL2NzEbk0hml2CDtYjDlEBsCaV7zJxpLtQx5sj1 AvYQ== X-Gm-Message-State: ABy/qLbTGNr54T4Dg/aa5epQubmSRMCh8xTWT3Oxv/H3A6FRdMUt3Bk4 A4J94IAHKH2CUxhBeMjddiw= X-Google-Smtp-Source: APBJJlF0ji/cbC2KW8JdDnUxnRWZmSZrwfZX7yp1SyDkesdkaXF6FEW7cYfIBk3kdi+aiZPk1WET0g== X-Received: by 2002:a7b:cbcb:0:b0:3fb:e254:b81e with SMTP id n11-20020a7bcbcb000000b003fbe254b81emr8421549wmi.12.1689448676318; Sat, 15 Jul 2023 12:17:56 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id k2-20020a7bc402000000b003fc02e8ea68sm4294237wmi.13.2023.07.15.12.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 12:17:55 -0700 (PDT) In-Reply-To: <874jm5rrgk.fsf@thornhill.no> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265240 Archived-At: This is a multi-part message in MIME format. --nextPart4816812.GXAFRqVoOG Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi Theo, In data sabato 15 luglio 2023 19:54:03 CEST, Theodor Thornhill ha scritto: > Eli Zaretskii writes: > >> From: Vincenzo Pupillo > >> 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 --nextPart4816812.GXAFRqVoOG Content-Disposition: attachment; filename="0001-Updated-JSX-support-due-to-changes-in-tree-sitter-ja.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Updated-JSX-support-due-to-changes-in-tree-sitter-ja.patch" >From fab9765fdaa7d4712d0bf3b4b8068d02f4dd73c2 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo 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 --nextPart4816812.GXAFRqVoOG Content-Disposition: attachment; filename="0002-Updated-JSX-support-due-to-changes-in-tree-sitter-ty.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0002-Updated-JSX-support-due-to-changes-in-tree-sitter-ty.patch" >From 5748f07f1465f30cbd31321d3f6806f8f8cb2b0c Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo 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 --nextPart4816812.GXAFRqVoOG--