Clover coverage report - PMD - 3.3
Coverage timestamp: Thu Sep 15 2005 17:59:57 EDT
file stats: LOC: 48   Methods: 2
NCLOC: 31   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SymbolTableTestRule.java 0% 0% 0% 0%
coverage
 1    /**
 2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 3    */
 4    package net.sourceforge.pmd.rules;
 5   
 6    import net.sourceforge.pmd.AbstractRule;
 7    import net.sourceforge.pmd.Rule;
 8    import net.sourceforge.pmd.ast.ASTStatement;
 9    import net.sourceforge.pmd.symboltable.NameOccurrence;
 10    import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
 11   
 12    import java.util.Iterator;
 13    import java.util.List;
 14    import java.util.Map;
 15   
 16    public class SymbolTableTestRule extends AbstractRule implements Rule {
 17   
 18  0 public Object visit(ASTStatement node, Object data) {
 19  0 Map decls = node.getScope().getVariableDeclarations();
 20  0 for (Iterator i = decls.keySet().iterator(); i.hasNext();) {
 21  0 VariableNameDeclaration decl = (VariableNameDeclaration) i.next();
 22   
 23  0 List usages = (List) decls.get(decl);
 24  0 if (!isStaticMethodBeingInvoked(usages)) {
 25  0 System.out.println("Error");
 26    }
 27    }
 28  0 return data;
 29    }
 30   
 31  0 private boolean isStaticMethodBeingInvoked(List usages) {
 32  0 for (Iterator j = usages.iterator(); j.hasNext();) {
 33  0 NameOccurrence nameOccurrence = (NameOccurrence) j.next();
 34  0 if (nameOccurrence.isPartOfQualifiedName()) {
 35  0 System.out.println(nameOccurrence.getNameForWhichThisIsAQualifier().getImage());
 36   
 37    // how do i get the method access node here?
 38   
 39    /*
 40    if(method is static) {
 41    return true;
 42    }
 43    */
 44    }
 45    }
 46  0 return false;
 47    }
 48    }