Subject: bug#60376: 29.0.60; Standardize csharp-ts-mode's font-lock features

From: Jostein Kjønigsen <[email-masked]>
Date: Sun, 1 Jan 2023 18:24:32 +0100

On 01.01.2023 17:29, Jostein Kjønigsen wrote:
> On 31.12.2022 23:21, Yuan Fu wrote:
>> I applied it, thanks!
>>
>> Yuan
>
> Following up this case, attached is a patch which from what I can tell 
> movies function invocation fontification to level 4, without any other 
> regressions.
>
> Theo: Care to take it for a spin? Does it look OK by you?
>
> -- 
> Jostein

Disregard previous patch.

Consider instead please the patch attached to this email.

It does 3 things all in one:

* moves function-call fontification to level 4 only (in its own feature)

* cleans up long-standing issues with "messy" rules for 
function-invocations. Removes the needs for "overrides".

* also fixes issue with fonctification of self/this-method invocations.

Theo: Can you try this patch and see what you think?

--

Jostein
From eb3df7b77357a56da9e05163ef0bf0ca9efa97db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <[email-masked]>
Date: Sun, 1 Jan 2023 17:27:06 +0100
Subject: [PATCH] lisp/progmodes/csharp-mode.el: adjust function-call
 fontification

---
 lisp/progmodes/csharp-mode.el | 43 ++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index da64daf9848..02da705b445 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -764,8 +764,12 @@ csharp-ts-mode--font-lock-settings
       (identifier) @font-lock-type-face)
      (type_argument_list
       (identifier) @font-lock-type-face)
-     (generic_name
-      (identifier) @font-lock-type-face)
+     (type_argument_list
+      (generic_name
+       (identifier) @font-lock-type-face))
+     (base_list
+      (generic_name
+       (identifier) @font-lock-type-face))
      (array_type
       (identifier) @font-lock-type-face)
      (cast_expression (identifier) @font-lock-type-face)
@@ -810,26 +814,6 @@ csharp-ts-mode--font-lock-settings
      (method_declaration type: (_) @font-lock-type-face)
      (method_declaration name: (_) @font-lock-function-name-face)
 
-     (invocation_expression
-      (member_access_expression
-       (generic_name (identifier) @font-lock-function-name-face)))
-     (invocation_expression
-      (member_access_expression
-       ((identifier) @font-lock-variable-name-face
-        (identifier) @font-lock-function-name-face)))
-     (invocation_expression
-      (identifier) @font-lock-function-name-face)
-     (invocation_expression
-      (member_access_expression
-       expression: (identifier) @font-lock-variable-name-face))
-     (invocation_expression
-      function: [(generic_name (identifier)) @font-lock-function-name-face
-                 (generic_name (type_argument_list
-                                ["<"] @font-lock-bracket-face
-                                (identifier) @font-lock-type-face
-                                [">"] @font-lock-bracket-face)
-                               )])
-
      (catch_declaration
       ((identifier) @font-lock-type-face))
      (catch_declaration
@@ -845,6 +829,19 @@ csharp-ts-mode--font-lock-settings
      (binary_expression (identifier) @font-lock-variable-name-face)
      (argument (identifier) @font-lock-variable-name-face))
 
+   :language 'c-sharp
+   :feature 'function
+   '((invocation_expression
+      function: (member_access_expression
+                 name: (identifier) @font-lock-function-name-face))
+     (invocation_expression
+      function: (identifier) @font-lock-function-name-face)
+     (invocation_expression
+      function: (member_access_expression
+                 name: (generic_name (identifier) @font-lock-function-name-face)))
+     (invocation_expression
+      function: (generic_name (identifier) @font-lock-function-name-face)))
+
    :language 'c-sharp
    :feature 'escape-sequence
    :override t
@@ -916,7 +913,7 @@ csharp-ts-mode
               '(( comment definition)
                 ( keyword string type)
                 ( constant escape-sequence expression literal property)
-                ( bracket delimiter error)))
+                ( function bracket delimiter error)))
 
   ;; Imenu.
   (setq-local treesit-simple-imenu-settings
-- 
2.37.2