Replies: 1 comment
-
an exception could easily be made to remove the "get_" part when searching for a method/attribute, to make the search results work better in this way. im surprised they dont already show up. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In C++, Godot uses getter and setter methods instead of properties.
In GDScript, you are encouraged to use the properties syntax only, but the getter/setter methods are also valid (even though they don't show auto completion anymore, see godotengine/godot#56268).
This can leave a user (e.g. myself) confused, since some methods like
get_tree()
orget_parent()
are only available as methods, while other properties have very similar sounding getters likeget_owner()
orget_root()
and they do not show up in the auto completion of GDScript.I understand and agree with removing the auto completion items for getter/setter methods, but this has tripped me up multiple times and I almost filed a bug report for it before realizing it's "intentional". Also confusing is that property getters/setters are still included in the documentation pages.
I have two potential solutions to help make this make more sense, but feel free to come up with others:
1) Remove the getter/setter table from the documentation
I mean this one:
C++ users will find the corresponding methods by searching the auto completion for the property name, and GDScript users (the main target audience of these documentation pages) simply get confused by seeing these in here, since they don't seem to be valid.
Unless there's use cases for these method names (maybe using reflection to call the methods?), I don't think they belong in the docs anymore.
2) Make Godot's auto completion smarter
This idea would make it so that when typing the name of a getter/setter method, the auto completion for the corresponding property shows up. (Right now, no auto completion popup appears in this situation...)
Something like this:
No idea how this solution would work with LSP integration.
P.S. I don't know the situation in C#, but would be interested to hear if this is a problem there as well, or if all properties exist only as properties in C#.
Beta Was this translation helpful? Give feedback.
All reactions