From 683816f14718b257666b29f792a8d330936cf5c1 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Thu, 13 Mar 2025 09:21:55 +0100 Subject: fix(python): don't highlight parameter name as builtin (#7732) --- tests/query/highlights/python/fields.py | 15 +++++++++++---- tests/query/highlights/python/functions.py | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'tests/query/highlights/python') diff --git a/tests/query/highlights/python/fields.py b/tests/query/highlights/python/fields.py index cea9eccb7..cbe80cdc2 100644 --- a/tests/query/highlights/python/fields.py +++ b/tests/query/highlights/python/fields.py @@ -2,12 +2,15 @@ class Fields: type: str # ^^^^ @variable.member - def __init__(self, fields: list[int]) -> None: -# ^^^ @type.builtin -# ^^^^ @constant.builtin + def __init__(self, type: str, fields: list[int]) -> None: +# ^^^^ @variable.builtin +# ^^^^ @variable.parameter +# ^^^^^^ @variable.parameter +# ^^^ @type.builtin +# ^^^^ @constant.builtin self.fields = fields # ^^^^^^ @variable.member - self.type = "foo" + self.type = type # this cannot be highlighted correctly by Treesitter # ^^^^ @variable.member self.__dunderfield__ = None # ^^^^^^^^^^^^^^^ @variable.member @@ -15,3 +18,7 @@ class Fields: # ^^^^^^^^^^^ @variable.member self.NOT_A_FIELD = "IM NOT A FIELD" # ^^^^^^^^^^^ @constant + +Fields(type="schema", fields=[0, 1]) +# ^^^^ @variable.parameter +# ^^^^^^ @variable.parameter diff --git a/tests/query/highlights/python/functions.py b/tests/query/highlights/python/functions.py index 6d3028433..7284d3fcc 100644 --- a/tests/query/highlights/python/functions.py +++ b/tests/query/highlights/python/functions.py @@ -8,6 +8,11 @@ _ = func() class Foo: def method(self) -> None: ... +# ^^^^ @variable.builtin + + @classmethod + def clsmethod(cls) -> None: ... +# ^^^ @variable.builtin Foo().method() # ^^^^^^ @function.method.call -- cgit v1.2.3-70-g09d2