/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ /* Generated By:JJTree: Do not edit this line. ASTVariableOrConstantDeclaratorId.java Version 4.1 */ /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */ package net.sourceforge.pmd.lang.plsql.ast; import java.util.List; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.symboltable.NameDeclaration; import net.sourceforge.pmd.lang.symboltable.NameOccurrence; public class ASTVariableOrConstantDeclaratorId extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode { public ASTVariableOrConstantDeclaratorId(int id) { super(id); } public ASTVariableOrConstantDeclaratorId(PLSQLParser p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(PLSQLParserVisitor visitor, Object data) { return visitor.visit(this, data); } private int arrayDepth; private NameDeclaration nameDeclaration; public NameDeclaration getNameDeclaration() { return nameDeclaration; } public void setNameDeclaration(NameDeclaration decl) { nameDeclaration = decl; } public List<NameOccurrence> getUsages() { return getScope().getDeclarations().get(nameDeclaration); } public void bumpArrayDepth() { arrayDepth++; } public int getArrayDepth() { return arrayDepth; } public boolean isArray() { return arrayDepth > 0; } public Node getTypeNameNode() { if (jjtGetParent() instanceof ASTFormalParameter) { return findTypeNameNode(jjtGetParent()); } else if (jjtGetParent().jjtGetParent() instanceof ASTVariableOrConstantDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) { return findTypeNameNode(jjtGetParent().jjtGetParent()); } throw new RuntimeException( "Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration"); } public ASTDatatype getTypeNode() { if (jjtGetParent() instanceof ASTFormalParameter) { return ((ASTFormalParameter) jjtGetParent()).getTypeNode(); } else { Node n = jjtGetParent().jjtGetParent(); if (n instanceof ASTVariableOrConstantDeclaration || n instanceof ASTFieldDeclaration) { return n.getFirstChildOfType(ASTDatatype.class); } } throw new RuntimeException( "Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration"); } private Node findTypeNameNode(Node node) { ASTDatatype typeNode = (ASTDatatype) node.jjtGetChild(0); return typeNode.jjtGetChild(0); } } /* * JavaCC - OriginalChecksum=935037739d9116b8c87f25deb4faa2d0 (do not edit this * line) */