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

net.intelie.pipes.util.CallsCompilerContext Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes.util;

import net.intelie.pipes.CompilationResult;
import net.intelie.pipes.CompilerContext;
import net.intelie.pipes.PipeException;
import net.intelie.pipes.ast.AstNode;
import net.intelie.pipes.ast.CallNode;

import java.util.*;

public class CallsCompilerContext extends CompilerContext.Forwarding {
    private final Set calls;

    public CallsCompilerContext(CompilerContext context) {
        this(context, null, new LinkedHashSet<>());
    }

    private CallsCompilerContext(CompilerContext context, CompilerContext forward, Set calls) {
        super(context, forward);
        this.calls = calls;
    }

    public Set getCalls() {
        return calls;
    }

    @Override
    public Forwarding wrap(CompilerContext context, CompilerContext forward) {
        return new CallsCompilerContext(context, forward, calls);
    }

    @Override
    public CompilationResult compile(AstNode node) throws PipeException {
        if (node instanceof CallNode)
            calls.add(((CallNode) node).getName());
        return delegate().compile(node);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy