godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Add public/private access modifiers to GDScript and autocompletion improvements

Open 2plus2makes5 opened this issue 5 years ago • 206 comments

Describe the project you are working on: 2.5d beat'em up

Describe the problem or limitation you are having in your project: Inside a GDScript class i often use "private" variables and functions that shouldn't be visible ouside but that instead are "public", hence visible and usable by everyone. More or less related is the fact that autocompletion is cluttered, yes alphabetic order is good but the list always starts with lots of constants and the function or variable we want is usually buried in lots of other things that aren't useful in that moment.

Describe the feature / enhancement and how it helps to overcome the problem or limitation: Let us specify if a variable or function is private or protected(or whatever keywords you want to use), a private variable can only be used by the functions of the same class, protected means that it's also accessible by the classes that inherit from the class the variable is in.

About autocompletion in my opinion it would be even more useful if suggestions were grouped by class, ordered from the leaf of the class tree back to the root class, or maybe add to the editor's options the possibility to order and filter what is shown.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: var v(no access modifier means public) protected var v(accessible only in the class it's in and the ones that inherit it) private var v(accessible only in the class it's in)

Autocompletion suggestions would be grouped by class, ordered from the leaf to the root of the class tree, maybe with their class written somewhere. It would be also helpful if the suggestions were colored the same way as in the editor, this way it would be even faster and easier to find what we want.

If this enhancement will not be used often, can it be worked around with a few lines of script?: Access modifiers and autocompletion are essential features so they would be used very often and probably they can't be made with few lines of script.

Is there a reason why this should be core and not an add-on in the asset library?: It seems to me that a GDScript feature like these ones should be core.

2plus2makes5 avatar Mar 27 '20 09:03 2plus2makes5