dfmt
dfmt copied to clipboard
Sorting import statements
This is something I love since I am kind of a maniac sometimes. In Intellij Idea for example, formatting Java code can also sort import statements alphabetically. Would it be difficult to implement in dfmt ? Maybe I'll try to get into the code and try to do something myself, but as I have never touched anything related to code parsing/formatting, for now I have no idea of how hard it could be.
Thumbs up
There is a WIP here: https://github.com/dlang-community/dfmt/pull/302
Due to dfmt's architecture it is actually pretty hard to move statements around. I do it by basically ignoring imports in the tree and putting them out as text not as tokens at the beginning of the enclosing scope.
Much like this issue's author (I'm accustomed to the Organize Imports action in VS Code for JavaScript sources), I like to alphabetize my Selective Imports.
I might try to pickup that closed PR.
just like for the reason the original PR was closed, I think this does not belong in dfmt. It's rather a dfix thing or something like that, that users would want to trigger manually. It's also already has an implementation in serve-d, you could just rip that out of there if you want it as standalone tool.