Does Godot support Refactoring

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wyattb

If not, how do you find all instances of a rename of a variable or object.

:bust_in_silhouette: Reply From: MysteryGM

Groups will work for this. That is just add every object when it is spawned to a group then call the group.

Godot’s groups also work kinda like C# interfaces, you can call a function that every object in the group will try to run.

I was asking how to change all occurrences of a variable similar to what is done in other IDEs (usually called refactoring). Are you saying groups is a work around?

wyattb | 2018-09-28 01:24

Yes and no.
Godot’s GDscript has no support for changing variables across all code.
However Godot is designed to work from the main scene down. So using groups you could have one main variable in a parent object, that you only have to change once.

GDscript is a infant coding language with only the bare basics, doesn’t even support cases yet.
It is never going to be as useful as C# or any well developed scripting language, it can’t be because making a language is as much work as making a whole engine.

I believe that GDscript will eventually fade into a visual scripting language and C# will replace it in the long run.

Sorry for taking this long to reply, I was never informed of your comment.

MysteryGM | 2018-10-02 12:22

From the looks of it GDScript is pretty solid and is specifically designed for the Godot gaming engine. I feel C# is oversold because it is overly complex for most things one wants to do in a gaming. (I coded in Unity and know C#.) GDScript now has type hinting, which means JIT will be forthcoming and the Editor is a big help. Also a Refactoring app can easily figure out what needs to be changed.

It is a matter of priorities I and someone to implement it but certainly doable.

wyattb | 2018-10-02 16:07

I also believe it is doable but I don’t see it happening. As you say it is a matter of priorities, the Godot devs do not believe that GDScript is a priority right now.

It has been over 3 years since refactoring has been brought up, the Godot developers simply have too much problems to deal with to focus on implementing it.
C# was integrated this year.

Engines normally follow the pattern of 1 primary language and 1 easy to use language. Maintaining more is just a drain on limited resources.

Although, personally I would like if GDScript remained instead of the visual scripting.

MysteryGM | 2018-10-02 19:40

:bust_in_silhouette: Reply From: paulhocker

There is nothing currently that will do that, but you can try using an external editor like Visual Studio Code, and try to do a Global Search/Replace. It is not perfect, but it can help.

– Paul

:bust_in_silhouette: Reply From: k3nzngtn

You can select the variable and then use CTRL + SHIFT + F and Replace.... It opens a search window at the bottom, allowing you to replace every occurrence of that variables name.

I hope OP’s glad he finally was told how to do this after 2 years of wondering! (jk)

Bernard Cloutier | 2020-10-18 14:32