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

net.sourceforge.pmd.lang.apex.ast.ASTBlockStatement 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 net.sourceforge.pmd.lang.document.TextDocument;

import com.google.summit.ast.Node;

public final class ASTBlockStatement extends AbstractApexNode.Single {
    private boolean curlyBrace;

    ASTBlockStatement(Node blockStatement) {
        super(blockStatement);
    }


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

    public boolean hasCurlyBrace() {
        return curlyBrace;
    }

    @Override
    protected void calculateTextRegion(TextDocument sourceCode) {
        super.calculateTextRegion(sourceCode);
        if (!hasRealLoc()) {
            return;
        }

        // check, whether this block statement really begins with a curly brace
        // unfortunately, for-loop and if-statements always contain a block statement,
        // regardless whether curly braces where present or not.
        this.curlyBrace = sourceCode.getText().slice(getTextRegion()).charAt(0) == '{';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy