Is there any way to find unreferenced code in Flex Builder?
We've got several Flex projects, one of which has just been refactored. I'm wondering if there's an easy way t开发者_Python百科o tell which classes and functions (if any) aren't being used any more?
I've discovered that we've definitely got some unused code, because running ASDoc on the entire project reports some compilation errors which don't get reported by Flex Builder (implying that those classes aren't being used any more). I'm hoping to find a more robust and complete method, and preferably one which can work at function level too.
My ugly hack:
Using the swfdump
tool from SWFtools, dump the disassembly from (all of) your swf(s):
swfdump -a my.swf > dump
Get a list of all your classes:
find . -name "*.as" -exec basename {} .as \; > classes
find . -name "*.mxml" -exec basename {} .mxml \; >> classes
Apply one list to the other:
for class in $(<classes) ; do grep -q \\\<$class\\\> dump || echo $class ; done
I am doing this on Windows, using Cygwin.
Check out the Flex PMD tool. It was recently released in beta, but we've been using it at work for a few weeks, and it seems to work pretty nicely.
Note, the swfdump tool included with the Flex SDK will work in place of the SWFTools version in the bash script listed above.
This doesn't really answer your question but you can find the references to a single class, variable or function by selecting it (in code editor) and pushing: Ctrl+Shift+G . I think that's what you can get out of Flex / Flash Builder at the moment.
精彩评论