Hello everyone,
I have started working on a tool that identifies unused imports. It uses dmd as a library.
The purpose is to have a working tool, but also to better understand what sort of information the frontend needs to output so that such tools are possible.
Up to this point, I managed to make it work with global imports (since dmdfe currently does not provide the scope hierarchy). The tool does output some false positives because semantic is destructive and some things like aliases or enums are substituted eagerly and you cannot trace their origin.
I have tested this tool with some dmd sources and have already identified unused imports·
So, if you have projects with lots of global imports you could use it to at least narrow down the list of potential unused imports.
The tool is a work in progress, so if you have any ideas for improvement feel free to ping me.
Note that the import paths used are from my machine, so you will need to update those accordingly to the files imported in your project.
RazvanN