-
Notifications
You must be signed in to change notification settings - Fork 620
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
GDScript based on #3194 #3199
GDScript based on #3194 #3199
Conversation
7b99cb1
to
1de2c5b
Compare
Codecov Report
@@ Coverage Diff @@
## master #3199 +/- ##
==========================================
+ Coverage 84.84% 84.91% +0.06%
==========================================
Files 205 206 +1
Lines 48369 48991 +622
==========================================
+ Hits 41040 41599 +559
- Misses 7329 7392 +63
Continue to review full report at Codecov.
|
1de2c5b
to
f50bce8
Compare
Alright, it seems like geany is pretty behind on pulling changes from here so I had to jury rig some things to get some functions used that aren't defined in geany's main/entry.c. It's true that files are all classes behind the scenes, but I kind of like doing what is normally done with other languages by just listing symbols at the "top level", like in the image below: Because while it's sort of true to say they're all attributes of the class defined by the file, it does nuke functionality a little bit by clumping things together when they were sorted into nice categories before, and prepending Although maybe this is just something that could be improved with the geany symbol display. The class we're inheriting from also shows on the symbol table, but that has some additional information in the tags that could probably be used to hide it. I found that a signal call with no parameters and no brackets breaks whatever is on the line immediately after it, in the screenshot above it's breaking the Local variables to functions aren't showing up on the symbol display, so it looks like I didn't need to be worried about too much on that front and mapping variables and consts to the variable display in Geany looks like it looks fine. Also I've never seen github CI fail because it couldn't reach its own URLs before. Must have happened right when github went down a few days ago. Some luck that it happened to exactly one CI run. Should I make changes against and send commits to this branch, or drag changes over to mine and commit on top? |
Because of the limitation of my English reading skill, it is hard from tracking the discussion. So, let me summarize your comments: A. integrating this parser to geany is a bit hard because the ctags code in geany is a bit old. B. tagging the name coming after in C. the code parsing signal is broken. D. local variables and parameters are not listed on geany's symbol table. E. how we should do next?A and B are understandable. However, let's forget to integrate this parser into Geany for a while. About C, I will fix it. Thank you for reporting in this branch. About D, I guess geany does something internally. Currently, the "local" and "parameter" kinds are enabled by default. About E, I'm thinking about the following process:
I will list up the critical issue in the first comment of this pull request. |
93959ca
to
d80370f
Compare
The ctags version used in geany just hasn't been updated in a while I think, I see on the geany pull request queue that they actually have some open for updating that already so that should be fine. My main quibble with how it looks in geany is more about how the symbols are sorted, in the first image top level symbols are in little categories for functions, classes, variables, etc, but in the second image class attributes don't get any sorting like that in geany, they're all just mixed togethor. This could be a feature to add to geany rather than a change to make with the tags here though, to extend the categorisation down into class declarations. I tested Java which also has giant classes and the nice sorting is nuked there as well so GDScript wouldn't be the only language to benefit from that little addition. I can take a shot at that. Local and parameter being invisible on the symbol tree is the desired result, we wouldn't want every variable declared in a function filling up the global symbol tree view. I thought local variables might not be hidden properly if we removed the local kind and changed it to an extra field but I didn't have to change anything explicitly and they were already hidden so it seems geany already has code for hiding local variables marked in this way. Signals work from what I can tell now. Can't find anything the parser's doing strictly wrong for now. I'll close my initial pull request if this'll be the canonical one. |
In your test input, |
Annotations are a coming feature in GDScript, currently in the development builds of Godot 4. A number of keywords are being cleaned out of the global namespace by changing them into annotations beginning with @. In their keyword form they didn't interfere with anything on the symbol display or folding or anything so I didn't need to change anything to do with them, I do have their pre-annotation forms listed on the keyword list in Geany so they'll highlight properly: I wanted to get a little future proofing in, so I remember I added a little bit with variables and removed a bit of code from classes because python has similar @ notation for an operation done on classes and functions and I just needed to shift references to that code around a little bit so that annotations would operate on variables and functions. |
Oh, I see. Thank you for the explanation. I understand why I cannot find any code using |
Can I define a function inside a function? If yes, could you show a short example? I wonder how the tag for In python, @Davidy22, could you recommend a good kind name for 'static func' ? |
Currently, nested function declarations are illegal. There's an upcoming feature in godot 4, lambda functions, that would enable something with a similar effect to nested functions:
There's some deviation from the python lambda that meant I couldn't do the same level of copying from python code that I did for the rest of the language. It uses func instead of lambda, so there's a keyword collision with regular function definitions, parameters are enclosed in brackets (), they can take up multiple lines, there's an optional name assignment that's mostly useless and the return value is explicit. For some performance reason, calling a lambda function uses a .call() instead of being able to call it directly like in Python because it's more like a sort of object assigned to the variable. Godot inner class methods actually aren't static by default, so if we do the following:
We will get the output:
Where the first call to f() nulls because class methods aren't static by default, and gdscript is magnanimous and gives us a null instead of crashing. Since static is explicit, I think we don't need to do anything with checking scope. For the kind, I feel like a |
Thank you. It seems that the "function" kind is never used; only "method" kind is used for valid GDScript input. In addition, "static", and RPC-related keywords like "remote" are treated as annotations. The last topic is "access:" field. I will write about how I think about it. |
Oh I forgot everything was being labelled as a method. If we're doing that then the static functions would be static methods too. Then the static methods would be using the same kind as other methods, and the added static annotation would be relevant helpful additional information. The last time I checked, the static keyword still had its keyword status although the current nightly build of godot 4 crashes for me so I can't check for myself in the latest version of godot. The RPC keywords I know for sure have all been demoted to using the @ notation There were three access levels in the python parser:
Public is the default open access level, protected is items preceded by one _underscore and in python, this is actually a functionally meaningless distinction and completely driven by convention, python will allow you to access the variable anyways. Private is preceded by two __underscores and it will modify the name of the attribute, but it also ultimately doesn't actually prevent access and is also driven by programmer convention. I neglected to touch this for GDScript, but GDScript has a convention for a single _underscore which in similar manner to python doesn't actually do anything and only protects the attribute if the programmer agrees to not touch it. Since the python parser has chosen to reflect honorary access levels, we can probably do something similar here. GDScript access levels are basically the same as python ones, except there's no double __underscore convention, and everything is technically a class attribute. We can probably just delete a lot of the |
Thank you. I reverted the change for extracting a "static func" object as a "function kind tag. Now it is extracted as a "method" kind tag with "annotations:static". As a result of the change, there is no place where the "function" kind is used. So I removed the "function" kind. I found one more bug in my code handling signal. I fixed it. |
Thank you for explaining the "access". I thought assigning a "private" to "local" and "parameter" kind tags is too redundant. So I will not touch this area:-P. About the parser design, including kinds, roles, fields, and extras, I could not find any more critical issues. Do you find a critical issue when using ctags as a stand-alone command-line tool? After I get "ack" from you I will squash the changes into one and make a new pull request for refreshing the discussion. Before merging I would like to do:
After merging let's think about integrating the parser to Geany. BTW, do you want to write parsers for tscn and project.godot files? |
a08a621
to
713a00e
Compare
I have a commit removing some of the python access logic that doesn't apply to gdscript in 3d7b3ac. Other than that I don't see anything strictly incorrect from a cursory pass through. I've been plugging this into geany along the way, in its current form it's a little weird because of the files are classes thing but I'm going to see what I can do about extending geany's nested symbol table display. The tscn and godot files look like just a config file format. I set them to use the iniconf parser in geany and the symbol tree looks pretty nice already. There's some definitions for what names mean in the tscn spec but I don't see how that would impact symbol tagging within them. There is the hairy inter-file thing to deal with, but I think that's the editor's job the more I think about it. I can whip up something quickly for the docs page as a pr |
3721843
to
3c1f75d
Compare
In 282463b, I tried to provide a solution for the issue, "too tall symbol tree in Geany". Thank you for the document. I can start from it. We use "method" kind for all ".* func" language objects. |
The GDScript documentation does make the traditional distinction between functions and methods even though if they're all methods. If we're going to classify them all as functions that belong to classes though, method is the just the proper name for it. If we renamed the kind to function for everything then the methods of inner classes would also be labelled as functions and that would be weird. The symbol tree looks like it's back to normal with the latest version, so I don't need to try do any feature additions on the geany side to extend the symbol display anymore which is nice. |
@Davidy22, thank you. All we must have are in this pull request. There are some "better to have" items. If you have an issue when integrating this new parser to Geany, please, open an issue on either u-ctags or geany side. |
282463b
to
0d5e19d
Compare
Tested in geany, heavily borrowed from python
0d5e19d
to
ebbfee1
Compare
Alright, one step closer to getting this into geany. Do you need me to write ctags-lang-gdscript? |
Thank you for the offering, but I would like to write an initial version by myself. |
This pull request is derived from #3194 submitted by @Davidy22.
Many changes are the result of my reviewing #3194 and @Davidy22's replies.
See https://docs.ctags.io/en/latest/contributions.html#testing-a-pr-locally-before-being-merged for testing this pull request.
The topic this pull request doesn't cover:The critical issues that must be fixed before emerging:
rename "method" kind to "function" kind ?→ "method" is better.The optional items:
extends "file.gd".class
@icon(...)
after class_nameremote
to annotations like@remote
, and attach them toannotations:
fieldThis pull request doesn't deal with the way to integrate the parser with geany like:
the symbol tree becomes too deep (class_name tagging)With "implicitClass" extra, the parser can ignore the unnamed implicitly existing class.