From 2e94f9726704260f3ba8b51b3a47c927a025a85f Mon Sep 17 00:00:00 2001 From: David Craine Date: Mon, 29 Jul 2002 18:40:47 +0000 Subject: [PATCH] Fixed problem with detecting object useage of param as well as problem with native methods. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@551 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/rules/UnusedFormalParameterRule.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java b/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java index 291bb7ce9e..f2d0431f97 100644 --- a/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java @@ -10,6 +10,7 @@ import net.sourceforge.pmd.ast.ASTBlock; import net.sourceforge.pmd.RuleContext; import java.text.MessageFormat; import net.sourceforge.pmd.ast.ASTVariableDeclaratorId; +import net.sourceforge.pmd.ast.ASTPrimaryPrefix; public class UnusedFormalParameterRule extends AbstractRule { @@ -30,12 +31,18 @@ public class UnusedFormalParameterRule extends AbstractRule { int index = 0; if (startNode instanceof ASTName) { String nodeImage = ((ASTName)startNode).getImage(); + //check to see if there is a "." in the image which indicates a method call on this variable name + int index2 = nodeImage.indexOf('.'); + if (index2 != -1) { + nodeImage = nodeImage.substring(0, index2); //set the node Image to the prefix + } if (paramNames.contains(nodeImage)) { paramNames.remove(nodeImage); //the name is used so let's remove it from the list } } else if (startNode.jjtGetNumChildren() > 0) { - for (int i=0; i