Class StreamTracer

  • All Implemented Interfaces:
    ITracer, ITracer, ITracer

    public class StreamTracer
    extends StreamTracer
    implements ITracer
    Implements a simple stream-based execution tracer. Produces normalized sequences of collections in order to facilitate easy comparison. As this may affect followup computations, don't use this tracer for real execution! Does not support filtering.
    Author:
    Holger Eichelberger
    • Field Detail

      • emitFailed

        private boolean emitFailed
    • Constructor Detail

      • StreamTracer

        public StreamTracer​(java.io.Writer out,
                            java.lang.String... baseFolder)
        Creates a new file tracer.
        Parameters:
        out - the output writer
        baseFolder - optional base folders used to make matching (string) values relative
      • StreamTracer

        public StreamTracer​(java.io.Writer out,
                            boolean emitFailed,
                            java.lang.String... baseFolder)
        Creates a new stream tracer.
        Parameters:
        out - the output writer
        emitFailed - whether failure causes shall be emitted
        baseFolder - optional base folders used to make matching (string) values relative
    • Method Detail

      • setTraceFilter

        public void setTraceFilter​(ITraceFilter filter)
        Description copied from interface: ITracer
        Sets a trace filter on this tracer.
        Specified by:
        setTraceFilter in interface ITracer
        Parameters:
        filter - the new trace filter, ignored if null
      • getTraceFilter

        public ITraceFilter getTraceFilter()
        Description copied from interface: ITracer
        Returns the active trace filter.
        Specified by:
        getTraceFilter in interface ITracer
        Returns:
        the filter, may be null if the tracer does not support filters
      • visitRule

        public void visitRule​(Rule rule,
                              RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when visiting a rule starts.
        Specified by:
        visitRule in interface ITracer
        Parameters:
        rule - the rule being visited
        environment - the runtime environment
      • visitedRule

        public void visitedRule​(Rule rule,
                                RuntimeEnvironment<?,​?> environment,
                                java.lang.Object result)
        Description copied from interface: ITracer
        Is called when visiting a rule ends.
        Specified by:
        visitedRule in interface ITracer
        Parameters:
        rule - the rule being visited
        environment - the runtime environment
        result - the result produced by the rule
      • visitLoop

        public void visitLoop​(IEnumeratingLoop loop,
                              RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when visiting a map starts.
        Specified by:
        visitLoop in interface ITracer
        Parameters:
        loop - the loop being visited
        environment - the runtime environment
      • visitIteratorAssignment

        public void visitIteratorAssignment​(IEnumeratingLoop loop,
                                            VariableDeclaration var,
                                            java.lang.Object value)
        Description copied from interface: ITracer
        Is called when a loop iterator variable is assigned.
        Specified by:
        visitIteratorAssignment in interface ITracer
        Parameters:
        loop - the loop
        var - the iterator variable
        value - the actual value
      • visitedLoop

        public void visitedLoop​(IEnumeratingLoop loop,
                                RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when visiting a map ends.
        Specified by:
        visitedLoop in interface ITracer
        Parameters:
        loop - the loop being visited
        environment - the runtime environment
      • adjustSequenceForMap

        public Collection<?> adjustSequenceForMap​(Collection<?> collection)
        Description copied from interface: ITracer
        Allows a tracer to change the sequence of processing a map collection. This is intended for testing and debugging only as it normalizes and, thus, interfers with the actual execution sequence.
        Specified by:
        adjustSequenceForMap in interface ITracer
        Parameters:
        collection - the collection to be considered
        Returns:
        the new sequence (just the elements may be reordered)
      • adjustSequenceForJoin

        public Collection<java.lang.Object> adjustSequenceForJoin​(Collection<java.lang.Object> collection)
        Description copied from interface: ITracer
        Allows a tracer to change the sequence of processing a map collection. This is intended for testing and debugging only as it normalizes and, thus, interfers with the actual execution sequence.
        Specified by:
        adjustSequenceForJoin in interface ITracer
        Parameters:
        collection - the collection to be considered
        Returns:
        the new sequence (just the elements may be reordered)
      • visitSystemCall

        public void visitSystemCall​(java.lang.String[] args)
        Description copied from interface: ITracer
        Is called before executing a system call.
        Specified by:
        visitSystemCall in interface ITracer
        Parameters:
        args - the arguments for the system call
      • visitingInstantiator

        public void visitingInstantiator​(java.lang.String name)
        Description copied from interface: ITracer
        Is called when an instantiator is being visited / executed.
        Specified by:
        visitingInstantiator in interface ITracer
        Parameters:
        name - the name of the instantiator
      • visitedInstantiator

        public void visitedInstantiator​(java.lang.String name,
                                        java.lang.Object result)
        Description copied from interface: ITracer
        Is called when an instantiator was visited / executed.
        Specified by:
        visitedInstantiator in interface ITracer
        Parameters:
        name - the name of the instantiator
        result - the result of the execution
      • failedAt

        public void failedAt​(IBuildlangElement element)
        Description copied from interface: ITracer
        Is called when the execution of a build language element failed.
        Specified by:
        failedAt in interface ITracer
        Parameters:
        element - the failed element
      • getWriter

        protected ExpressionWriter getWriter​(java.io.Writer out)
        Description copied from class: StreamTracer
        Returns the writer for emitting expressions.
        Specified by:
        getWriter in class StreamTracer
        Parameters:
        out - the output target
        Returns:
        the writer
      • visitScript

        public void visitScript​(Script script,
                                RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when a script (header) is being visited.
        Specified by:
        visitScript in interface ITracer
        Parameters:
        script - the script
        environment - the runtime environment
      • visitScriptBody

        public void visitScriptBody​(Script script,
                                    RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when a script (body) is being visited.
        Specified by:
        visitScriptBody in interface ITracer
        Parameters:
        script - the script
        environment - the runtime environment
      • visitedScript

        public void visitedScript​(Script script)
        Description copied from interface: ITracer
        Is called when visiting a script ends.
        Specified by:
        visitedScript in interface ITracer
        Parameters:
        script - the script
      • reset

        public void reset()
        Description copied from interface: ITracer
        Resets this tracer for reuse.
        Specified by:
        reset in interface ITracer
      • visitAlternative

        public void visitAlternative​(boolean takeIf)
        Description copied from interface: ITracer
        An alternative was visited.
        Specified by:
        visitAlternative in interface ITracer
        Parameters:
        takeIf - if true the if-branch is used, false else the else-branch
      • visitWhileBody

        public void visitWhileBody()
        Description copied from interface: ITracer
        Is called when visiting a while body starts.
        Specified by:
        visitWhileBody in interface ITracer
      • visitedWhileBody

        public void visitedWhileBody()
        Description copied from interface: ITracer
        Is called when visiting a while body ends.
        Specified by:
        visitedWhileBody in interface ITracer