Closed dabikuru closed 2 weeks ago
Aside of the first four items (from @tool
to docstring), reordering can change the code's behavior, so I doubt it's possible to do safely.
Calinou's right, this kind of thing is deceptively difficult to execute at an acceptable level of safety and reliability.
I also don't think top-level code organization is an appropriate target for auto-formatters. I'm familiar with clang-format, prettier, biomejs, black, ruff and others, and I'm not aware of one that will actually reorder sections of your files.
We appreciate the interest and your effort in describing a possible solution, but this feature doesn't really align with the extension's goals or available resources.
Thank you for the explanation, I see how auto-fix cannot easily be done safely.
Would it still make sense to at least provide a warning where the recommended ordering is not being followed? This could be an optional setting.
No, because merely detecting this situation requires almost as much work as generating the quick fix suggestions, eg correctly parsing all of GDScript and sorting every available language construct into the various categories from the "recommended ordering".
Understood, thank you!
Godot version
4.2.2.stable
VS Code version
1.90.1
Godot Tools VS Code extension version
2.0.0
System information
MacOS
Problem statement
The GDScript style guide suggests a recommended ordering of member signals, variables, and methods.
I thought it would be really helpful if godot-tools provided an optional warning if the recommended ordering is not being followed, and offer to auto-fix if possible.
Proposed solution
I am not familiar with code formatting tools yet, so please forgive the high-level description!
For the auto-fix, I could imagine the following:
Note: to avoid unexpected behavior, within each category, the original order should be preserved. E.g.: