Skip to content
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

Renaming anything in Godot should rename their references #3163

Closed
RebelliousX opened this issue Dec 29, 2015 · 21 comments
Closed

Renaming anything in Godot should rename their references #3163

RebelliousX opened this issue Dec 29, 2015 · 21 comments

Comments

@RebelliousX
Copy link
Contributor

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.

@reduz
Copy link
Member

reduz commented Dec 29, 2015

This is a good idea, it could be a checkbox in the rename dialog

On Tue, Dec 29, 2015 at 10:44 AM, RebelliousX [email protected]
wrote:

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 to to renaming variables, it would be great if when
renaming a variable in script
it changes all occurrences in the script file.


Reply to this email directly or view it on GitHub
#3163.

@magpie514
Copy link

This would be real nice. While doing it manually is possible, accidents or forgetfulness happen, this would completely negate the possibility of human error in that regard.

@akien-mga
Copy link
Member

There should be a kind of dialog that shows you everything that would get renamed though, and let you confirm or not if you want the rename to happen in all scripts and scenes. We don't want to brutally run sed -i 's/oldname/newname/g' on all files in case the oldname is not unique enough :)

@vnen
Copy link
Member

vnen commented Dec 29, 2015

This should be treated as "refactoring tools" and should be designed as such. Certainly individual refactoring tools can be added in steps, but I guess a proper design of those tools would be better to avoid being reworked later on.

@kubecz3k
Copy link
Contributor

Just some small notice: This might be somehow related to new static typed language that is planned for 2.1, since with static typing there actually is a way for editor to know what exactly he is renaming, so it would be possible to avoid renaming 2 variables with the same name in different scopes.

@Zylann
Copy link
Contributor

Zylann commented Mar 15, 2016

Given the importance of names and paths in Godot, this feature would be awesome. Would it be possible to do that too when a node or resource is moved to a different hierarchy level?

@RebelliousX
Copy link
Contributor Author

RebelliousX commented Nov 5, 2016

Ping.

It has been almost a year, I was wondering if this will make it in v3 which I doubt, but it would be great if it did!!

I have seen long time ago (about 5 months ago) an attempt to similar behavior, please have a look at this youtube video, it has great concept that implement some of what this issue is about.

IMAGE ALT TEXT HERE

@supercom32
Copy link

It's been an while since the last post, but I thought I would +1 this issue since good refactoring tools are sorely missing. When you use any modern IDE like Eclipse (Java), you can right click and rename any object, variable, or method, and all instances referencing it will get updated over your entire project. Likewise in IDEs like Eclipse, you can also do things like change the method signature (parameter order), and then have all callers change their parameter orders too.

Currently if I have to rename a global/shared variable, or a method in a class library, I'm always really worried that I broke something because I forgot to change all instances calling it. Coupled with the fact that debugging isn't multi-threaded (threads don't report errors, stop at breakpoints, etc), you could rename something and just suddenly have your whole project die, because you forgot to change one instance in something that is threaded (which causes an error to be thrown, but not to the user since debugging isn't multi-threaded). A real pain in deed! (^_^);

@reduz
Copy link
Member

reduz commented May 29, 2017 via email

@midopa
Copy link

midopa commented Jun 5, 2017

PyCharm manages to provide this functionality, despite Python being a dynamically/duck-typed language. So it's not impossible. I think it boils down to properly indexing the code?

@Anudin

This comment has been minimized.

@mhilbrunner
Copy link
Member

@kubecz3k Close this? Impossible until (optional) typing is added to GDScript.

@kubecz3k
Copy link
Contributor

kubecz3k commented Nov 8, 2017

@mhilbrunner I think we will close when the issue will be resolved (optional typing is very high on our priority list) :)

@GeminiSquishGames
Copy link

I just started using Godot, and I would just be happy if it worked on exported Script Variables that I've set in the inspector when I change a node's name that is that value. More practically, I think the value of the exported script variable should be linked to the nodes ID rather than it's string name and path but I'm uncertain if nodes even have a static ID that stays the same in all cases.

@Zylann
Copy link
Contributor

Zylann commented May 26, 2018

@gff1979 that would work only if you export a NodePath. Then Godot would parse the entire scene and all scripts in it to find references to the node you are renaming.

@athal24

This comment has been minimized.

@jaykyburz
Copy link

jaykyburz commented Sep 20, 2019

I'm fairly new to Godot and came to suggest we need this as well. I don't see any reason why the rename function should not do a find and replace on the full path string of the asset as well.

TurretAttackEffect

Rename

@Zylann
Copy link
Contributor

Zylann commented Sep 20, 2019

preload should be renamable since the path must be constant so no need to parse the whole script I think, but need to care about commented code, string sections and any form of concatenation. Scripts embedded in scenes may also need special treatment.

@akien-mga
Copy link
Member

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

@Zireael07
Copy link
Contributor

I'm not sure if this is an enhancement, more of a bugfix (at least for the script variables use case)

@akien-mga
Copy link
Member

No, the currently implemented features are not buggy. What this asks for is a new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests