Godot-proposals: Auto rename references - provide 'refactor' tooling

Created on 26 May 2020  路  3Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
N/A (generic issue)
Describe the problem or limitation you are having in your project:
Renaming a variable in a script causes references to it in other script to be broken.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
When renaming a variable, it should refactor/rename references too.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Quoted from original issue:
When renaming any kind of object in Godot, it should find all occurrences in scripts/editor
and change that as well. This can be achieved by parsing script files, any matching names for the changed scene/node, like "load(), preload(), set_script() get_node()..etc!) functions.

This should apply too to renaming variables, it would be great if when renaming a variable in script
it changes all occurrences in the script file.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Nope. (Also I assume it will be used more often the bigger and more complex projects are)

Is there a reason why this should be core and not an add-on in the asset library?:
Has to be done in script editor for variables use case, and in the editor itself (possibly Fix Dependencies dialog) for other use case.

Original issue: https://github.com/godotengine/godot/issues/3163

editor

Most helpful comment

This is a feature the GDScript language server could cover, it's part of the specification iirc. Implementing it there would make it available in all editors like VSCode, Atom, Emacs...

All 3 comments

Note that this will probably require a dedicated "refactor" tool to be added, similar to the one in JetBrains IDEs or Visual Studio Code. Search and replace should generally not attempt to be too smart on its own as to not break users' expectations.

Yep, I don't think it's a task for search-and-replace. (Also, in most cases, I change variable names manually and not via search)

This is a feature the GDScript language server could cover, it's part of the specification iirc. Implementing it there would make it available in all editors like VSCode, Atom, Emacs...

Was this page helpful?
0 / 5 - 0 ratings