You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not really project specific. In every project you will eventually have the need to navigate and refactor your code and see which parts of your code are used by other code.
Describe the problem or limitation you are having in your project
There is currently no good way to refactor visual script functions. The only thing that is supported is renaming a function. If I add or remove parameters, this will break all usages of it. I cannot reorder parameters without deleting them. In addition I have no way of finding usages of my function. In the text editor I could do some search and replace, and while that still is a far cry from modern refactoring tools, it is at least an approach that would work.
Once I realize I have to change a function which is used in a dozen places, it is basically game over, because If i add or remove a parameter, all usage places of the function are broken and I will only find out at runtime if something is not working because the compiler will not tell me. Since I have no usage search I cannot even find these places easily.
Lastly, navigation is quite limited. I cannot easily jump from usage of a function to its declaration (like i can in the text editor).
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Enhancement: Proper function signature change refactoring
Add proper refactoring support for changing function signatures. This could be done either with the inspector (as it is done right now) or through a dedicated refactoring dialog. The refactoring must fix all usages of the to conform to the new signature where possible. It should be possible to change parameter names, types and order easily without losing information when I reorder parameters.
This would enormously improve the experience as in many cases the code remains in working condition and even in cases where manual rework is required, the editor can still help out by at least automatically fixing everything that is in its power.
Enhancement: Usage search for functions
In addition there needs to be a way to search for usages of a function, so I can fix all usages quickly should I have made a change that cannot be automatically fixed (e.g. like adding a new parameter or changing the type to something incompatible).
Without this, I need to manually go through all the graphs to find any use of my function and there is a good chance I miss one.
Enhancement: Improved code navigation
It would be tremendously helpful if i could jump from a function invocation to its declaration, so I can fix stuff quickly without having to manually open the respective graph and then have to search for the function if it contains more than one.
This would make working with visual scripts less cumbersome.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Refactoring
For refactoring, the user could right-click the function definition or any usage and have a "refactor" entry in the context menu:
Then the user should have a way of easily reordering renaming and changing parameter types:
All changes should be reflected in all usages of the function, e.g. if parameters are reordered, they should be reordered in the usages as well and the connections should be fixed to connect to the new port position. If a parameter is introduced between two others, the connections are also moved appropriately.
If a connection cannot be fixed and becomes invalid, it should be removed (e.g. when a parameter type is changing to something incompatible). If a new parameter is introduced the new port stays disconnected.
Usage search
Right-clicking on the function definition or any usage of a function should offer a context menu item allowing to search for usages of the function:
Clicking on this would open a list of all places where the function is used. In this list an entry can be double-clicked to go to the respective usage site. The usage site will be centered in the editor and briefly highlighted:
Quick navigation
Right-clicking on any usage of a function should offer a context menu to quickly jump to the definition of the function:
Selecting this entry will open the editor with the function definition and scroll to the function entry point, also briefly highlighting it:
If this enhancement will not be used often, can it be worked around with a few lines of script?
I think the changes are too complex to be implemented with a simple script. The whole visual scripting editor is done in C++ and its internal model is only known to the developers.
Is there a reason why this should be core and not an add-on in the asset library?
Since the editor itself is core and this requires certain data structures to keep track of nodes and connections and fixing up these I think it will have to be part of the core editor.
The text was updated successfully, but these errors were encountered:
Offtopic: I think it's not just VisualScript needs a refactor, but I think GDScript also needs refactor, like it doesn't have "Find usages", "Refactor", "Generate Method", etc.
Offtopic: I think it's not just VisualScript needs a refactor, but I think GDScript also needs refactor, like it doesn't have "Find usages", "Refactor", "Generate Method", etc.
Yes that would be nice, however with GDScript this is almost impossible to reliably implement, simply because GDScript is not strongly typed and the editor would have to guess what to refactor then. With VisualScript it is a lot easier because you actually have the data structures and typing that would allow you to do these refactorings in the first place.
Offtopic: I think it's not just VisualScript needs a refactor, but I think GDScript also needs refactor, like it doesn't have "Find usages", "Refactor", "Generate Method", etc.
Describe the project you are working on
This is not really project specific. In every project you will eventually have the need to navigate and refactor your code and see which parts of your code are used by other code.
Describe the problem or limitation you are having in your project
There is currently no good way to refactor visual script functions. The only thing that is supported is renaming a function. If I add or remove parameters, this will break all usages of it. I cannot reorder parameters without deleting them. In addition I have no way of finding usages of my function. In the text editor I could do some search and replace, and while that still is a far cry from modern refactoring tools, it is at least an approach that would work.
Once I realize I have to change a function which is used in a dozen places, it is basically game over, because If i add or remove a parameter, all usage places of the function are broken and I will only find out at runtime if something is not working because the compiler will not tell me. Since I have no usage search I cannot even find these places easily.
Lastly, navigation is quite limited. I cannot easily jump from usage of a function to its declaration (like i can in the text editor).
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Enhancement: Proper function signature change refactoring
Add proper refactoring support for changing function signatures. This could be done either with the inspector (as it is done right now) or through a dedicated refactoring dialog. The refactoring must fix all usages of the to conform to the new signature where possible. It should be possible to change parameter names, types and order easily without losing information when I reorder parameters.
This would enormously improve the experience as in many cases the code remains in working condition and even in cases where manual rework is required, the editor can still help out by at least automatically fixing everything that is in its power.
Enhancement: Usage search for functions
In addition there needs to be a way to search for usages of a function, so I can fix all usages quickly should I have made a change that cannot be automatically fixed (e.g. like adding a new parameter or changing the type to something incompatible).
Without this, I need to manually go through all the graphs to find any use of my function and there is a good chance I miss one.
Enhancement: Improved code navigation
It would be tremendously helpful if i could jump from a function invocation to its declaration, so I can fix stuff quickly without having to manually open the respective graph and then have to search for the function if it contains more than one.
This would make working with visual scripts less cumbersome.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Refactoring
For refactoring, the user could right-click the function definition or any usage and have a "refactor" entry in the context menu:
Then the user should have a way of easily reordering renaming and changing parameter types:
All changes should be reflected in all usages of the function, e.g. if parameters are reordered, they should be reordered in the usages as well and the connections should be fixed to connect to the new port position. If a parameter is introduced between two others, the connections are also moved appropriately.
If a connection cannot be fixed and becomes invalid, it should be removed (e.g. when a parameter type is changing to something incompatible). If a new parameter is introduced the new port stays disconnected.
Usage search
Right-clicking on the function definition or any usage of a function should offer a context menu item allowing to search for usages of the function:
Clicking on this would open a list of all places where the function is used. In this list an entry can be double-clicked to go to the respective usage site. The usage site will be centered in the editor and briefly highlighted:
Quick navigation
Right-clicking on any usage of a function should offer a context menu to quickly jump to the definition of the function:
Selecting this entry will open the editor with the function definition and scroll to the function entry point, also briefly highlighting it:
If this enhancement will not be used often, can it be worked around with a few lines of script?
I think the changes are too complex to be implemented with a simple script. The whole visual scripting editor is done in C++ and its internal model is only known to the developers.
Is there a reason why this should be core and not an add-on in the asset library?
Since the editor itself is core and this requires certain data structures to keep track of nodes and connections and fixing up these I think it will have to be part of the core editor.
The text was updated successfully, but these errors were encountered: