-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing keywords in GDScript grammar #379
Comments
Strangely, signal changed(new_value)
var warns_when_changed = "some value":
get:
return warns_when_changed
set(value):
changed.emit(value)
warns_when_changed = value The editor in Godot 4 is not colorizing them as well, and they don't appear in the keyword list in the tokenizer. |
Hold on, that works??? I thought it only accept function names. |
These are reserved keywords but aren't currently implemented. |
Ah, I see. So they should indeed be highlighted to indicate that they're already reserved, even before implementation. |
This is great feedback, especially with the Godot 4 beta on the horizon. If you see any other Godot 4-related problems, please add them here (or on the PR when I post it) and I'll try to address them before the beta release. |
I believe this is mostly done, right? Except ... it's not a good choice to color Keyword makes much more sense, otherwise something like
Coloring it like a method would make it weird on the first use case, and coloring it like a language variable would make it weird on the 2nd use case (unlike |
Also, a minor unrelated thing. |
Yeah, that PR was already merged.
Python colors
I have literally never seen either of these used, and honestly I forget they exist so thanks for the reminder. These should be straightforward to add; I'll get to it eventually. |
That's because
That's why the syntax for calling the base constructor is different: # python: call __init__ method on proxy object returned by super()
def __init__(self):
super().__init__(constructorArgs) # gdscript: call parent _init method, using the super keyword
func _init():
super(constructorArgs) In GDScript, however, I would say GDScript's class Child : Parent {
Child(string name) : base(name) {} // base(...) call calls parent constructor
void DoStuff() { base.DoStuff(); } // base object is like `this` cast to parent class
} |
Btw I just found another issue: it seems keywords are being matched as ignore-case. At least in Godot 4, the script editor isn't ignoring case for keywords, so I believe it might have been some sort of copy-paste mistake (since ignoring case seems correct on the lines below the mistake). Lines 310-321 should remove the "control_flow": {
"match": "\\b(?:if|elif|else|for|while|break|continue|pass|return|match|yield|await)\\b",
"name": "keyword.control.gdscript"
},
"keywords": {
"match": "\\b(?:class|class_name|extends|is|onready|tool|static|export|as|void|enum|preload|assert|breakpoint|rpc|sync|remote|master|puppet|slave|remotesync|mastersync|puppetsync|trait|namespace)\\b",
"name": "keyword.language.gdscript"
},
"letter": {
"match": "\\b(?:true|false|null)\\b",
"name": "constant.language.gdscript"
}, Judging by the script editor in Godot 4, ignoring case on lines 329, 333, 337 (float literals) is correct. Line 325 (hexadecimal notation) requires clarification, though. Godot seems to ignore case only on A-F a-f part. It seems to require the x in "match": "\\b0x\\h*\\b", |
@AlfishSoftware how has it been a year? Yeah, case-insensitive is definitely a mistake from the original author. I've fixed all the numeric literals to properly handle _'s, added binary integers, and removed the I also added g3 nodepath/stringname, and g4 nodepath, stringname, and raw strings, and fixed my previously incorrect handling of %Unique shorthands. |
With the merge of #506, I think this issue is addressed. |
Thanks! Will
|
Godot version
v4.0.alpha8.official [cc3ed63af]
VS Code version
1.67.2
Godot Tools VS Code extension version
1.3.0
System information
Kubuntu 22.04 x64
Issue description
Some keywords are not being tokenized properly by GDScript grammar.
await
- should be recognized as (control?) keywordsuper
- should be a keyword, sincesuper.etc
andsuper(...)
have different semantics and it appears in tokenizertrait
,namespace
- not mentioned in the docs, but they appear in the tokenizer in master (reserved words?)in
- it's always being marked askeyword.control.gdscript
; but when it's not part of afor
construct, thein
operator should bekeyword.operator.wordlike.gdscript
Steps to reproduce
Test syntax coloring in a file like this:
To test
in
keyword on themes that don't distinguish control keywords, you can use the VSCode command "Developer: Inspect Editor Tokens and Scopes".The text was updated successfully, but these errors were encountered: