net.intelie.pipes.util.CallsCompilerContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
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);
}
}