From fbaf1103a1eff984faf111534f37d61f361d10e2 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Fri, 26 Jul 2002 16:28:55 +0000 Subject: [PATCH] tweak git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@526 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/xdocs/howtowritearule.xml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pmd/xdocs/howtowritearule.xml b/pmd/xdocs/howtowritearule.xml index 667a2c459c..b7490cdcea 100644 --- a/pmd/xdocs/howtowritearule.xml +++ b/pmd/xdocs/howtowritearule.xml @@ -99,7 +99,35 @@ CompilationUnit
  • If you get a FileNotFoundException, make sure that go.bat is pointing to the test-data directory where you put Example.java
  • - +

    + So you can see in the example above that the AST for a WhileStatement looks kind of like this (excluding that expression gibberish for clarity): +

    + + + +

    + If you were to add curly braces and run the go.bat file again, you'd see that the AST would change a bit. It'd look like this: +

    + + + +

    + Ah ha! We see that the curly braces add a couple more AST elements - a Block and a BlockStatement. So all we have + to do is write a rule to detect a WhileStatement that's not followed by a Block, and we've got it. +