01: /*
02: * Created on Jan 11, 2005
03: *
04: * $Id: AbstractOptimizationRule.java 5019 2007-01-31 02:14:16Z xlv $
05: */
06: package net.sourceforge.pmd.rules.optimization;
07:
08: import java.util.List;
09:
10: import net.sourceforge.pmd.AbstractRule;
11: import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
12: import net.sourceforge.pmd.symboltable.NameOccurrence;
13:
14: /**
15: * Base class with utility methods for optimization rules
16: *
17: * @author mgriffa
18: */
19: public class AbstractOptimizationRule extends AbstractRule {
20:
21: public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
22: if (node.isInterface()) {
23: return data;
24: }
25: return super .visit(node, data);
26: }
27:
28: protected boolean assigned(List<NameOccurrence> usages) {
29: for (NameOccurrence occ : usages) {
30: if (occ.isOnLeftHandSide() || occ.isSelfAssignment()) {
31: return true;
32: }
33: continue;
34: }
35: return false;
36: }
37:
38: }
|