Open jmatsu opened 6 years ago
Thanks for your report and sorry for late response! I know what you mean. Let me consider how to solve this issue 🤔
One easy option is to run several time. But it takes too much time to finish task. I guess other option would make logic complex. So I'm thinking how this should be fixed...
Thank you for providing a wonderful plugin! :)
BTW, should I run
removeUnusedResources
task twice or more to assure Completed?In our case, it's not enough to remove resources by running
removeUnusedResources
only once due to a reference graph.(These examples are just based on my quick look so that other cases might exist.)
Simple reference case in value-grained Remover
For example, you should assume that
referenced_color
is referenced from only one code, i.e. referencer_color, andreferencer_color
is not referenced from anywhere. Then,referencer_color
must be removed and this plugin does behave like so. :) After removing that,referenced_color
's reference count would be changed from 1 to 0 so that this plugin should removereferenced_color
too. So kinda reference count concept should be considered during removing.More complex reference case across file-grained and value-grained Removers
Let's say:
drawable/jpg_drawable.jpg
is availabledrawable/jpg_drawable.jpg
is referenced from onlyxml_drawable
xml_drawable
is referenced from only StyleSampleRun a task once, then StyleSample should be removed (of course, your plugin works fine! ). After that, run a task again, then
xml_drawable
would be removed. Again,drawable/jpg_drawable.jpg
would be removed. Files, which would be marked asunused
after removing values, cannot be removed by running a task once. Because file removers are run before value removers.