Fixed problem on AbstractRule. UPIVR should have been checked in already.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@130 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
David Dixon-Peugh
2002-06-28 17:44:58 +00:00
parent 8c264ca01f
commit 9fddbd5c8e
2 changed files with 14 additions and 5 deletions

View File

@ -6,6 +6,7 @@
package net.sourceforge.pmd;
import net.sourceforge.pmd.ast.JavaParserVisitorAdapter;
import net.sourceforge.pmd.ast.ASTCompilationUnit;
import net.sourceforge.pmd.ast.SimpleNode;
import java.util.List;
@ -31,8 +32,8 @@ public abstract class AbstractRule
protected void visitAll( List acus, RuleContext ctx ) {
for (Iterator i = acus.iterator(); i.hasNext();) {
SimpleNode node = (SimpleNode)i.next();
node.childrenAccept( this, ctx );
ASTCompilationUnit node = (ASTCompilationUnit)i.next();
visit( node, ctx );
}
}

View File

@ -19,6 +19,7 @@ public class UseSingletonRule
}
public Object visit( ASTMethodDeclaration decl, Object data ) {
System.err.println("Visiting Method Declaration.");
if (isOK) return data;
if (!decl.isStatic()) {
@ -29,11 +30,18 @@ public class UseSingletonRule
}
public Object visit( ASTCompilationUnit cu, Object data ) {
Object RC = super.visit( cu, data );
System.err.println("Visiting Compilation Unit.");
if (!isOK)
Object RC = cu.childrenAccept( this, data );
System.err.println("Finished visiting CU.");
if (!isOK) {
System.err.println("All methods are static.");
(((RuleContext) data).getReport()).
addRuleViolation( new RuleViolation( this, cu.getBeginLine() ));
return data;
}
return RC;
}
}