tusharsadhwani / zigimports

Automatically remove unused imports and globals from Zig files.
MIT License
34 stars 2 forks source link

Return unused imports ordered by source location #6

Open furpu opened 2 months ago

furpu commented 2 months ago

Description

This PR implements ordering the results of find_unused_imports by source location.

Just a suggestion that I thought would be a nice addition to the tool. Also, I'm not sure if this is the best place to order the results.

Feel free to correct or edit it in anyway. Thanks for the awesome tool.

Sample output:

src/der.zig:4:0: big is unused
src/der.zig:5:0: builtin is unused
src/der.zig:11:0: Allocator is unused
src/der.zig:12:0: ArenaAllocator is unused
tusharsadhwani commented 2 months ago

We already have a sort function that sorts by start_index, which should have the same exact effect:

https://github.com/tusharsadhwani/zigimports/blob/3a1bf3ea98ab25cbd1444e15d5dc024e3f679f83/src/zigimports.zig#L186-L196

Although this one is for BlockSpan, not ImportSpan, Can you see if it's possible to de-duplicate the code somehow?