From e11923a5e85959a92ef28ec0de283b416ae4d20e Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Tue, 1 Jul 2003 13:32:57 +0000 Subject: [PATCH] Added note about which class to use for XPath rules git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2058 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/xdocs/howtowritearule.xml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pmd/xdocs/howtowritearule.xml b/pmd/xdocs/howtowritearule.xml index 2d7a180c6f..247a744a3b 100644 --- a/pmd/xdocs/howtowritearule.xml +++ b/pmd/xdocs/howtowritearule.xml @@ -270,13 +270,26 @@ public class WhileLoopsMustUseBracesRule extends AbstractRule {

-

Recently Dan Sheppard integrated an XPath engine into PMD, so now you can write rules as +

Recently Daniel Sheppard integrated an XPath engine into PMD, so now you can write rules as XPath expressions. For example, the XPath expression for our WhileLoopsMustUseBracesRule looks like this:

//WhileStatement[not(Statement/Block)]

Concise, eh? Here's an article with a lot more detail.

-

>Note that access modifiers are held as attributes, so, for example, +

Note that for XPath rules you'll need to set the + class attribute in the rule definition to net.sourceforge.pmd.rules.XPathRule. Like this: + + + + etc., etc. + ]]> + + +

+

Note that access modifiers are held as attributes, so, for example, //FieldDeclaration[@Private='true'] finds all private fields. You can see the code that determines all the attributes here