Subject: bug#67684: 30.0.50; Font lock rule conflict in js-ts-mode at level 4

From: Dmitry Gutov <[email-masked]>
Date: Fri, 8 Dec 2023 03:33:16 +0200

Hi!

On 07/12/2023 12:07, Loïc Lemaître wrote:
> I have noticed a font coloration issue in js-ts-mode when setting the 
> treesit font lock level to 4: JSX attributes color is not the same than 
> at level 3.
> There should have a conflict between rules for "property_identifier" 
> treesit type. The feature that triggers the conflict is "property" (of 
> the level 4).
> 
> You can reproduce the issue by following these steps:
> - M-: (setq treesit-font-lock-level 4)
> - M-x js-ts-mode on a JSX buffer
> 
> Note that the bug already exists in Emacs 29.1.

The attached patch seems to fix that.

But it removes a function added by Yuan in e78e69b33189, while 
reshuffling the highlights to reorder priorities.

Yuan, do you remember why you did it that way back then? Perhaps I'm 
missing some other conflict.

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 5a669fdbd42..e2b748f6cb8 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3570,16 +3570,6 @@ js--treesit-font-lock-settings
      ;; full namespace import (* as alias)
      (import_clause (namespace_import (identifier) @font-lock-variable-name-face)))
 
-   :language 'javascript
-   :feature 'property
-   '(((property_identifier) @font-lock-property-use-face
-      (:pred js--treesit-property-not-function-p
-             @font-lock-property-use-face))
-
-     (pair value: (identifier) @font-lock-variable-use-face)
-
-     ((shorthand_property_identifier) @font-lock-property-use-face))
-
    :language 'javascript
    :feature 'assignment
    '((assignment_expression
@@ -3606,6 +3596,12 @@ js--treesit-font-lock-settings
      (jsx_self_closing_element name: (_) @font-lock-function-call-face)
      (jsx_attribute (property_identifier) @font-lock-constant-face))
 
+   :language 'javascript
+   :feature 'property
+   '(((property_identifier) @font-lock-property-use-face)
+     (pair value: (identifier) @font-lock-variable-use-face)
+     ((shorthand_property_identifier) @font-lock-property-use-face))
+
    :language 'javascript
    :feature 'number
    '((number) @font-lock-number-face
@@ -3657,14 +3653,6 @@ js--fontify-template-string
       (setq font-beg (treesit-node-end child)
             child (treesit-node-next-sibling child)))))
 
-(defun js--treesit-property-not-function-p (node)
-  "Check that NODE, a property_identifier, is not used as a function."
-  (not (equal (treesit-node-type
-               (treesit-node-parent ; Maybe call_expression.
-                (treesit-node-parent ; Maybe member_expression.
-                 node)))
-              "call_expression")))
-
 (defvar js--treesit-lhs-identifier-query
   (when (treesit-available-p)
     (treesit-query-compile 'javascript '((identifier) @id