KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > ast > ASTAnnotation


1 /* Generated By:JJTree: Do not edit this line. ASTAnnotation.java */
2
3 package net.sourceforge.pmd.ast;
4
5 import net.sourceforge.pmd.Rule;
6
7 import java.util.Iterator JavaDoc;
8 import java.util.List JavaDoc;
9
10 public class ASTAnnotation extends SimpleJavaNode {
11     public ASTAnnotation(int id) {
12         super(id);
13     }
14
15     public ASTAnnotation(JavaParser p, int id) {
16         super(p, id);
17     }
18
19     public boolean suppresses(Rule rule) {
20         final String JavaDoc ruleAnno = "\"PMD." + rule.getName() + "\"";
21
22         if (jjtGetChild(0) instanceof ASTSingleMemberAnnotation) {
23             ASTSingleMemberAnnotation n = (ASTSingleMemberAnnotation) jjtGetChild(0);
24
25             if (n.jjtGetChild(0) instanceof ASTName) {
26                 ASTName annName = ((ASTName) n.jjtGetChild(0));
27
28                 if (annName.getImage().equals("SuppressWarnings")) {
29                     List JavaDoc nodes = n.findChildrenOfType(ASTLiteral.class);
30                     for (Iterator JavaDoc iter = nodes.iterator(); iter.hasNext();) {
31                         ASTLiteral element = (ASTLiteral) iter.next();
32                         if (element.hasImageEqualTo("\"PMD\"")
33                                 || element.hasImageEqualTo(ruleAnno)) {
34                             return true;
35                         }
36                     }
37                 }
38             }
39         }
40         return false;
41     }
42
43     /**
44      * Accept the visitor.
45      */

46     public Object JavaDoc jjtAccept(JavaParserVisitor visitor, Object JavaDoc data) {
47         return visitor.visit(this, data);
48     }
49 }
50
Popular Tags