All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.pmd.lang.apex.ast.ASTTryCatchFinallyBlockStatement Maven / Gradle / Ivy

There is a newer version: 7.5.0
Show newest version
/*
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.lang.apex.ast;

import java.util.List;

import com.google.summit.ast.statement.TryStatement;

public final class ASTTryCatchFinallyBlockStatement extends AbstractApexNode.Single {

    ASTTryCatchFinallyBlockStatement(TryStatement tryStatement) {
        super(tryStatement);
    }


    @Override
    protected  R acceptApexVisitor(ApexVisitor visitor, P data) {
        return visitor.visit(this, data);
    }

    public ASTBlockStatement getTryBlock() {
        return (ASTBlockStatement) getChild(0);
    }

    public List getCatchClauses() {
        return children(ASTCatchBlockStatement.class).toList();
    }

    public ASTBlockStatement getFinallyBlock() {
        ApexNode lastChild = null;
        if (getNumChildren() >= 2) {
            lastChild = getChild(getNumChildren() - 1);
        }
        if (lastChild instanceof ASTBlockStatement) {
            return (ASTBlockStatement) lastChild;
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy