package accrue.analysis.ast;

import polyglot.ast.Block;
import polyglot.ast.Catch;
import polyglot.ast.Catch_c;
import polyglot.ast.Formal;
import polyglot.util.Position;
import polyglot.util.SerialVersionUID;
import accrue.analysis.ext.AccrueExt_c;
import accrue.analysis.ext.ExtFormal;

public class AccrueCatch_c extends Catch_c {
    private static final long serialVersionUID = SerialVersionUID.generate();

    public AccrueCatch_c(Position pos, Formal formal, Block body) {
        super(pos, formal, body);
        // set the extension to know that it is in a catch clause
        ExtFormal ef = (ExtFormal) AccrueExt_c.ext(formal);
        ef.setIsCatchFormal();
    }

    @Override
    public Catch formal(Formal formal) {
        // set the delegate to know that it is in a catch clause
        ExtFormal ef = (ExtFormal) AccrueExt_c.ext(formal);
        ef.setIsCatchFormal();

        return super.formal(formal);
    }

    @Override
    protected <N extends Catch_c> N reconstruct(N n, Formal formal, Block body) {
        // set the delegate to know that it is in a catch clause
        // set the delegate to know that it is in a catch clause
        ExtFormal ef = (ExtFormal) AccrueExt_c.ext(formal);
        ef.setIsCatchFormal();

        return super.reconstruct(n, formal, body);
    }
}
