forked from phoedos/pmd
refactored, new isQualifiedName(SimpleNode) method
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4609 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -242,4 +242,8 @@ public abstract class AbstractRule extends JavaParserVisitorAdapter implements R
|
||||
return c.getImage();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isQualifiedName(SimpleNode node) {
|
||||
return node.getImage().indexOf('.') != -1;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class CompareObjectsWithEquals extends AbstractRule {
|
||||
private boolean hasName(Node n) {
|
||||
return n.jjtGetNumChildren() > 0 && n.jjtGetChild(0) instanceof ASTName;
|
||||
}
|
||||
|
||||
|
||||
public Object visit(ASTEqualityExpression node, Object data) {
|
||||
// skip if either child is not a simple name
|
||||
if (!hasName(((SimpleNode) node.jjtGetChild(0)).jjtGetChild(0)) || !hasName(((SimpleNode) node.jjtGetChild(1)).jjtGetChild(0))) {
|
||||
@ -21,8 +21,8 @@ public class CompareObjectsWithEquals extends AbstractRule {
|
||||
}
|
||||
|
||||
// skip if either is a qualified name
|
||||
if (((SimpleNode) node.jjtGetChild(0).jjtGetChild(0).jjtGetChild(0)).getImage().indexOf('.') != -1
|
||||
|| ((SimpleNode) node.jjtGetChild(1).jjtGetChild(0).jjtGetChild(0)).getImage().indexOf('.') != -1) {
|
||||
if (isQualifiedName((SimpleNode) node.jjtGetChild(0).jjtGetChild(0).jjtGetChild(0))
|
||||
|| isQualifiedName((SimpleNode) node.jjtGetChild(1).jjtGetChild(0).jjtGetChild(0))) {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class PositionalIteratorRule extends AbstractRule {
|
||||
if (child.jjtGetNumChildren() > 0) {
|
||||
collectNames(target, names, child);
|
||||
} else {
|
||||
if (child instanceof ASTName && child.getImage().indexOf('.') != -1 && target.equals(getVariableName(child.getImage()))) {
|
||||
if (child instanceof ASTName && isQualifiedName(child) && target.equals(getVariableName(child.getImage()))) {
|
||||
names.add(child.getImage());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user