From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Jostein Kjønigsen" <jostein@kjonigsen.net>
Cc: casouri@gmail.com, 59897@debbugs.gnu.org
Subject: bug#59897: 29.0.60; csharp-ts-mode: variable-name fontified as method when invoking method with generic type-argument.
Date: Thu, 08 Dec 2022 11:12:54 +0100 [thread overview]
Message-ID: <87zgby9pax.fsf@thornhill.no> (raw)
In-Reply-To: <76edd79f-6da1-4c28-b20e-5eb4d9a819b2@app.fastmail.com> ("Jostein Kjønigsen"'s message of "Thu, 08 Dec 2022 10:29:15 +0100")
[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]
Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:
> When I use the new csharp-ts-mode, method fontification is usually accurate with only 1 exception which I have
> encountered so far:
>
> When calling methods on objects, and that method accepts a generic type-argument. You typically see this in
> Startup.cs-like files in ASP.Net Core projects:
>
> services.AddSomeExtensionWithoutTypeArguments();
> services.AddSomeExtensionWithTypeArguments<MyType>();
>
> In the above cases we see that fontification of "services" differs.
>
> For the first line, services is fontified using font-lock-variable-name-face (correct), but in the latter case services
> is fontified using font-lock-function-name-face (incorrect).
>
> In both cases I expected services to be fontified using font-lock-variable-name-face.
>
Can you test this patch, Jostein, and if you're happy, please install,
Yuan :-)
BTW, I think the ruleset is getting pretty gnarly in csharp-mode, so
maybe we should consider slimming it down a little (without losing
granularity) for perf reasons down the line!
Theo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-expression-for-generic_name-in-csharp-ts-mode.patch --]
[-- Type: text/x-diff, Size: 1441 bytes --]
From 34fa2bc67ddffca65f219644f055f75a2b073aba Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Thu, 8 Dec 2022 11:08:28 +0100
Subject: [PATCH] Add expression for generic_name in csharp-ts-mode
Given the below example, we want 'services' to be font-locked in
'font-lock-variable-name-face' in all cases. Previously this only
worked in the first case, and the other was font-locked as
'font-lock-function-name-face'.
namespace Foo {
void Foo() {
services.Add();
services.Add<MyType>();
}
}
* lisp/progmodes/csharp-mode.el (csharp-ts-mode--font-lock-settings):
Add new query that makes the mentioned example work.
(bug#59897)
---
lisp/progmodes/csharp-mode.el | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 82e3bc0d54..bedf3f4342 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -784,6 +784,10 @@ csharp-ts-mode--font-lock-settings
(invocation_expression
(member_access_expression
(generic_name (identifier) @font-lock-function-name-face)))
+ (invocation_expression
+ (member_access_expression
+ expression: (identifier) @font-lock-variable-name-face
+ name: (generic_name (type_argument_list (identifier)))))
(invocation_expression
(member_access_expression
((identifier) @font-lock-variable-name-face
--
2.34.1
next prev parent reply other threads:[~2022-12-08 10:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 9:29 bug#59897: 29.0.60; csharp-ts-mode: variable-name fontified as method when invoking method with generic type-argument Jostein Kjønigsen
[not found] ` <handler.59897.B.167049179324261.ack@debbugs.gnu.org>
2022-12-08 10:09 ` bug#59897: Acknowledgement (29.0.60; csharp-ts-mode: variable-name fontified as method when invoking method with generic type-argument.) Jostein Kjønigsen
2022-12-08 10:12 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-08 10:52 ` bug#59897: 29.0.60; csharp-ts-mode: variable-name fontified as method when invoking method with generic type-argument Jostein Kjønigsen
2022-12-08 11:12 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 11:31 ` Jostein Kjønigsen
2022-12-09 20:57 ` Jostein Kjønigsen
2022-12-09 21:12 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-12 7:58 ` Jostein Kjønigsen
2022-12-12 22:19 ` Yuan Fu
2022-12-14 18:49 ` Jostein Kjønigsen
2022-12-14 19:43 ` Yuan Fu
2022-12-14 21:45 ` Jostein Kjønigsen
2022-12-14 22:34 ` Yuan Fu
2022-12-09 21:05 ` Yuan Fu
2022-12-09 21:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-09 21:07 ` Yuan Fu
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=87zgby9pax.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=59897@debbugs.gnu.org \
--cc=casouri@gmail.com \
--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.