From 0e2c4eb0f3acfd90b1c9650676c4495b0de7047b Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Tue, 7 Jul 2026 14:29:03 +0200 Subject: [PATCH] Improve highlighting around self/super --- data/parsing_test.gd | 10 +++++++++- languages/gdscript/highlights.scm | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/data/parsing_test.gd b/data/parsing_test.gd index 568ce25..ce75008 100644 --- a/data/parsing_test.gd +++ b/data/parsing_test.gd @@ -15,13 +15,21 @@ var setget_property: float = 3.2: func _init() -> void: - pass + super() + super.other() + self.property.x = 20 + method_call(self) + func _process(delta: float) -> void: position += velocity * delta rotation = velocity.angle() +func _not_implemented() -> void: + pass + + class InnerClass extends RefCounted: func _init(arg: int) -> void: pass diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index 90b3803..685373a 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -3,6 +3,9 @@ ; but a = 10 has 'a matching nothing. ; This is to keep consistency, and is like 'text_editor/theme/highlighting/text_color' in Godot Editor Settings (identifier) @variable +; Self reference in class. +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) ; Class @@ -12,8 +15,16 @@ ; Function calls (attribute_call (identifier) @function.method) -(base_call (identifier) @function.builtin) +(base_call (identifier) @function.method) (call (identifier) @function) +; Super calls have two forms: +; - super() to call this method's parent implementation, +; - super.other() to call another method's parent implementation. +((identifier) @function.builtin + (#eq? @function.builtin "super")) +(call (identifier) @function.builtin + (#eq? @function.builtin "super")) + ; Setget (setget @@ -221,9 +232,6 @@ "extends" ] @keyword -((identifier) @variable.language - (#match? @variable.language "^(self|super)$")) - ; Identifier naming conventions ; This needs to be at the very end in order to override earlier queries