lint for D

Ary Borenszweig ary at esperanto.org.ar
Wed Jul 9 18:44:07 PDT 2008


Bruce Adams a écrit :
> 
> Hi all,
>        Alas this is not an announcement. It should be relatively easy to 
> knock up a few noddy scripts that can detect some kinds
> of potential problem.

It should be relatively easy to write a plugin for Descent to do that. 
Something similar to FindBugs for Java ( 
http://findbugs.sourceforge.net/ ). Given a source file, you can ask 
Descent for it's AST with complete type resolution. You can apply the 
visitor pattern, which is supported by the AST nodes. You can store in a 
list which variables are declared, and then if they are used in a 
function or are written too, you eliminate them. The remaining entries 
in the list are the unused variables. It's a little harder for 
class/struct members, but it's still relatively easy.

It is both helpful for a developer and for Descent, because the code 
that support that is kind of finished, but it isn't tested much (it's 
only used in highlighting code, which seems to work fine). Of course I 
could do that, but atm I'm adding support for D2, plus it would be 
interesting if anyone else could join the project.



More information about the Digitalmars-d mailing list