Fixed docs, thx to David Karr for the correction

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4361 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-04-25 02:35:33 +00:00
parent 82f8229a5a
commit b0035e2c5c
2 changed files with 12 additions and 2 deletions

View File

@ -48,6 +48,7 @@
</subsection>
<subsection name="Contributors">
<ul>
<li>David Karr - reported stale XPath documentation</li>
<li>Christopher Stach - several bug reports for rules that didn't handle JDK 1.5 enums</li>
<li>Jarkko Hietaniemin - rewrote most of cpd.sh, tweaked C/CPP grammar to allow $ in identifiers, several CPD documentation suggestions, noted missing CPD scripts in binary release</li>
<li>Dawid Weiss - Reported bug in UnusedPrivateMethod</li>

View File

@ -95,7 +95,11 @@ Writing PMD rules with XPath can be a bit easier than writing rules with Java co
<p>You'll quickly see that all three local variables are matched. A possible
solution for this is to request that the parent of the local variable
declaration is the MethodDeclaration node:</p>
<source><![CDATA[//LocalVariableDeclaration[name(../../..) = 'MethodDeclaration']]]></source>
<source>
<![CDATA[
//LocalVariableDeclaration[name(../../..) = 'MethodDeclaration']
]]>
</source>
<subsection name="Matching variables by name">
<p>Let's consider that we are writing rules for logger. Let's assume we
use the Java logging API and we want to find all classes that have more
@ -141,7 +145,12 @@ Writing PMD rules with XPath can be a bit easier than writing rules with Java co
}
]]></source>
<p>The following expression does the magic we need:</p>
<source><![CDATA[//VariableDeclarator[../Type/Name[@Image='Factory'] and ..[@Final='false'] ]]]></source>
<source><![CDATA[
//VariableDeclarator
[../Type/ReferenceType/ClassOrInterfaceType
[@Image = 'Factory'] and ..[@Final='false']]
]]>
</source>
<p>I must recommend at this point that you experiment with Designer putting
the final modifier to the Factory and verifying that the results produced
are those expected.</p>