Change file name when change class name
See original GitHub issueEvery time that I want to refactor a name of a class in my code I need to change the class name and also change the file name. I think this is a waste of time to change the name of the same thing twice, this is an another step to make refactor harder. For example, I have a class that have the name of NodeKey
and I want to change the class name to FileKey
I need to change the class name and the file name from node_key.dart
to file_key.dart
.
I thing that this process need to be automated and it will same time for many users and make refactoring easier. On Change Symble
that change class name the extension will check if the file name have the same name as the changed class name (taking into consideration the name conventions of UpperCamelCase for class names and lowercase_with_underscores for file names) and if they have the same name change also the file name to the new name (with the name conventions).
Alternative solutions are: use existing extensions that does it, if you know any, or this is already possible in this extension and I don’t know about it or make a new extension that does it.
I will be happy to implement this if it is possible 😃 If possible you know any file/files you think that I need to change to make this feature?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
This works is complete but requires two things to use it:
It’s off by default but can be turned on with the
dart.renameFilesWithClasses
setting (which can be"never"
,"prompt"
or"always"
).If you want to try it before them, you can manually add the setting to your VS Code settings (ignore that VS Code says it doesn’t exist):
And use a bleeding edge SDK build (not recommended for general dev, stick to stable!):
https://dart.dev/tools/sdk/archive#main-channel-url-scheme
Thanks!