Search in sources :

Example 1 with ASTClassOrInterfaceBody

use of net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody in project pmd by pmd.

the class ScopeAndDeclarationFinder method createClassScope.

/**
 * Creates a new class scope for an AST node. The scope on top of the stack
 * is set as the parent of the new scope, which is then also stored on the
 * scope stack.
 *
 * @param node
 *            the AST node for which the scope has to be created.
 * @throws java.util.EmptyStackException
 *             if the scope stack is empty.
 */
private void createClassScope(JavaNode node) {
    Scope s = ((JavaNode) node.jjtGetParent()).getScope();
    ClassNameDeclaration classNameDeclaration = new ClassNameDeclaration(node);
    s.addDeclaration(classNameDeclaration);
    if (node instanceof ASTClassOrInterfaceBody) {
        addScope(new ClassScope(classNameDeclaration), node);
    } else {
        addScope(new ClassScope(node.getImage(), classNameDeclaration), node);
    }
}
Also used : Scope(net.sourceforge.pmd.lang.symboltable.Scope) ASTClassOrInterfaceBody(net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody) JavaNode(net.sourceforge.pmd.lang.java.ast.JavaNode) AbstractJavaNode(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode)

Aggregations

ASTClassOrInterfaceBody (net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody)1 AbstractJavaNode (net.sourceforge.pmd.lang.java.ast.AbstractJavaNode)1 JavaNode (net.sourceforge.pmd.lang.java.ast.JavaNode)1 Scope (net.sourceforge.pmd.lang.symboltable.Scope)1