Class AbstractVilTracer

    • Field Detail

      • INDENTATION_STEP

        private static final java.lang.String INDENTATION_STEP
        See Also:
        Constant Field Values
      • indentation

        private java.lang.String indentation
      • emitTraceText

        private boolean emitTraceText
      • enable

        private boolean enable
      • templateDefVisited

        private boolean templateDefVisited
    • Constructor Detail

      • AbstractVilTracer

        protected AbstractVilTracer()
        Creates a tracer instance without emitting trace texts.
      • AbstractVilTracer

        protected AbstractVilTracer​(boolean emitTraceText)
        Creates a tracer instance.
        Parameters:
        emitTraceText - whether text passed to trace(String) shall be emitted
    • 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
      • increaseIndentation

        private void increaseIndentation()
        Increases the indentation by one INDENTATION_STEP.
      • decreaseIndentation

        private void decreaseIndentation()
        Decreases the indentation by one INDENTATION_STEP if possible.
      • write

        protected void write​(java.lang.String msg)
        Writes a message and indents it.
        Parameters:
        msg - the message to be written
      • writeImpl

        protected abstract void writeImpl​(java.lang.String msg)
        Writes a message.
        Parameters:
        msg - the message to be written
      • trace

        public void trace​(java.lang.String text)
        Description copied from interface: ITracer
        Emits a trace string.
        Specified by:
        trace in interface ITracer
        Parameters:
        text - the text to be emitted
      • valueDefined

        public void valueDefined​(VariableDeclaration var,
                                 FieldDescriptor field,
                                 java.lang.Object value)
        Description copied from interface: ITracer
        Is called when a value of a variable is defined.
        Specified by:
        valueDefined in interface ITracer
        Parameters:
        var - the modified variable
        field - the field in var, may be null
        value - the actual value
      • traceExecutionException

        public void traceExecutionException​(VilException exception)
        Description copied from interface: ITracer
        Traces a top-level execution exception, i.e., execution a VIL script or template failed.
        Specified by:
        traceExecutionException in interface ITracer
        Parameters:
        exception - the exception
      • cleanImplicitFromOptionalArgument

        private static java.util.Map<?,​?> cleanImplicitFromOptionalArgument​(java.util.Map<?,​?> argument)
        Cleans implicit arguments from the optional arguments.
        Parameters:
        argument - the arguments to be cleaned
        Returns:
        a copy of argument
      • visitedCallExpression

        public void visitedCallExpression​(OperationDescriptor descriptor,
                                          CallExpression.CallType callType,
                                          java.lang.Object[] args,
                                          java.lang.Object result)
        Description copied from interface: ITracer
        Is called after a resolved call expression is actually executed. Do not modify the parameters!
        Specified by:
        visitedCallExpression in interface ITracer
        Parameters:
        descriptor - the descriptor to be called
        callType - the type of the call
        args - the actual arguments
        result - the result of the call
      • visitingCallExpression

        public void visitingCallExpression​(OperationDescriptor descriptor,
                                           CallExpression.CallType callType,
                                           java.lang.Object[] args)
        Description copied from interface: ITracer
        Is called before a resolved call expression is actually executed. Do not modify the parameters!
        Specified by:
        visitingCallExpression in interface ITracer
        Parameters:
        descriptor - the descriptor to be called
        callType - the type of the call
        args - the actual arguments
      • 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 map,
                              RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Is called when visiting a map starts.
        Specified by:
        visitLoop in interface ITracer
        Parameters:
        map - 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​(Expression expression)
        Description copied from interface: ITracer
        Is called when the evaluation of an expression caused an execution failure.
        Specified by:
        failedAt in interface ITracer
        Parameters:
        expression - the failing expression
      • 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
      • 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
      • visitDef

        public void visitDef​(Def def,
                             RuntimeEnvironment<?,​?> environment)
        Description copied from interface: ITracer
        Starts visiting a sub-template.
        Specified by:
        visitDef in interface ITracer
        Parameters:
        def - the sub-template
        environment - the runtime environment
      • visitedDef

        public void visitedDef​(Def def,
                               RuntimeEnvironment<?,​?> environment,
                               java.lang.Object result)
        Description copied from interface: ITracer
        Ends visiting a sub-template.
        Specified by:
        visitedDef in interface ITracer
        Parameters:
        def - the sub-template
        environment - the runtime environment
        result - the execution result
      • visitedSwitch

        public void visitedSwitch​(java.lang.Object select,
                                  int alternative,
                                  java.lang.Object value)
        Description copied from interface: ITracer
        A switch statement was visited.
        Specified by:
        visitedSwitch in interface ITracer
        Parameters:
        select - the select value
        alternative - the successive alternative (0-based index including default)
        value - the actual value of the switch statement
      • visitLoop

        public void visitLoop​(VariableDeclaration var)
        Description copied from interface: ITracer
        Visiting a loop started.
        Specified by:
        visitLoop in interface ITracer
        Parameters:
        var - the loop/iterator variable
      • visitedLoop

        public void visitedLoop​(VariableDeclaration var)
        Description copied from interface: ITracer
        Visiting a loop ended.
        Specified by:
        visitedLoop in interface ITracer
        Parameters:
        var - the loop/iterator variable
      • visitAlternative

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

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

        public void visitTemplate​(Template template)
        Description copied from interface: ITracer
        Starts visiting a template.
        Specified by:
        visitTemplate in interface ITracer
        Parameters:
        template - the template being visited
      • visitedTemplate

        public void visitedTemplate​(Template template)
        Description copied from interface: ITracer
        Ends visiting a template.
        Specified by:
        visitedTemplate in interface ITracer
        Parameters:
        template - the template
      • reset

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

        public void traceMessage​(java.lang.String message)
        Trace a message (usually going to System.out in an instantiator).
        Specified by:
        traceMessage in interface IInstantiatorTracer
        Parameters:
        message - the message to be traced
      • traceError

        public void traceError​(java.lang.String message)
        Description copied from interface: ITracer
        Emits an error trace string.
        Specified by:
        traceError in interface IInstantiatorTracer
        Specified by:
        traceError in interface ITracer
        Parameters:
        message - the text to be emitted
      • traceWarning

        public void traceWarning​(java.lang.String message)
        Description copied from interface: ITracer
        Emits a warning trace string.
        Specified by:
        traceWarning in interface ITracer
        Parameters:
        message - the text to be emitted
      • isEnabled

        protected boolean isEnabled()
        Returns whether the tracer is enabled.
        Returns:
        true enabled, false else
      • enable

        public void enable​(boolean enable)
        Description copied from interface: ITracer
        Enables or disables the tracer. By default, a tracer is enabled.
        Specified by:
        enable in interface ITracer
        Parameters:
        enable - enable or disable
      • visitFlush

        public void visitFlush()
        Description copied from interface: ITracer
        Is called before a content flush.
        Specified by:
        visitFlush in interface ITracer
      • visitedFlush

        public void visitedFlush()
        Description copied from interface: ITracer
        Is called after a content flush.
        Specified by:
        visitedFlush in interface ITracer