]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/progmodes/csharp-mode.el: Fix fontification of typeof (bug#75406).
authorJostein Kjønigsen <jostein@kjonigsen.net>
Mon, 6 Jan 2025 14:08:36 +0000 (15:08 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 3 Feb 2025 11:13:38 +0000 (12:13 +0100)
(cherry picked from commit 0ef78b131b4e232f064e370699a7ae2413715a44)

lisp/progmodes/csharp-mode.el

index 3e07da40cdd0406457af754a2d678e431e20d5bc..9d19456179bd5d64e099b0d485a055ef5ada073c 100644 (file)
@@ -748,6 +748,12 @@ compilation and evaluation time conflicts."
     (treesit-query-compile 'c-sharp "(type_of_expression)" t)
     t))
 
+(defun csharp-ts-mode--test-typeof-expression ()
+  "Return non-nil if (type_of_expression) is in the grammar."
+  (ignore-errors
+    (treesit-query-compile 'c-sharp "(typeof_expression)" t)
+    t))
+
 (defun csharp-ts-mode--test-name-equals ()
   "Return non-nil if (name_equals) is in the grammar."
   (ignore-errors
@@ -871,7 +877,9 @@ compilation and evaluation time conflicts."
            (type_parameter_constraint (type type: (generic_name (identifier) @font-lock-type-face)))))
 
      ,@(when (csharp-ts-mode--test-type-of-expression)
-         '((type_of_expression (identifier) @font-lock-type-face))
+         '((type_of_expression (identifier) @font-lock-type-face)))
+
+     ,@(when (csharp-ts-mode--test-typeof-expression)
          '((typeof_expression (identifier) @font-lock-type-face)))
 
      (object_creation_expression