1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| package net.sourceforge.pmd.rules.optimization; |
7 |
| |
8 |
| import java.util.Iterator; |
9 |
| import java.util.List; |
10 |
| |
11 |
| import net.sourceforge.pmd.AbstractRule; |
12 |
| import net.sourceforge.pmd.Rule; |
13 |
| import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration; |
14 |
| import net.sourceforge.pmd.symboltable.NameOccurrence; |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| public class AbstractOptimizationRule extends AbstractRule implements Rule { |
22 |
| |
23 |
27
| public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
24 |
27
| if (node.isInterface()) {
|
25 |
0
| return data;
|
26 |
| } |
27 |
27
| return super.visit(node, data);
|
28 |
| } |
29 |
| |
30 |
21
| protected boolean assigned(List usages) {
|
31 |
21
| for (Iterator j = usages.iterator(); j.hasNext();) {
|
32 |
17
| NameOccurrence occ = (NameOccurrence) j.next();
|
33 |
17
| if (occ.isOnLeftHandSide() || occ.isSelfAssignment()) {
|
34 |
10
| return true;
|
35 |
| } |
36 |
7
| continue;
|
37 |
| } |
38 |
11
| return false;
|
39 |
| } |
40 |
| |
41 |
| } |