1 23 package org.hammurapi.inspectors; 24 25 import org.hammurapi.InspectorBase; 26 27 import com.pavelvlasov.jsel.VariableDefinition; 28 import com.pavelvlasov.jsel.impl.AST; 29 30 31 37 public class ArrayDeclarationRule extends InspectorBase { 38 39 42 public void visit(VariableDefinition element) { 43 AST arrayNode=null; 44 AST identNode=null; 45 46 for (AST node=(AST) element.getAst().getFirstChild(); node!=null; node=(AST) node.getNextSibling()) { 47 String typeName=node.getTypeName(); 48 if ("TYPE".equals(typeName)) { 49 AST node2=(AST) node.getFirstChild(); 50 if (node2!=null && "ARRAY_DECLARATOR".equals(node2.getTypeName())) { 51 arrayNode=node2; 52 } 53 } else if ("IDENT".equals(typeName)) { 54 identNode=node; 55 break; 56 } 57 } 58 59 if (arrayNode!=null && identNode!=null && identNode.getColumn()<arrayNode.getColumn()) { 60 context.reportViolation(element); 61 } 62 } 63 } 64 | Popular Tags |