Class AbstractVilTracer
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.AbstractTracerBase
-
- net.ssehub.easy.instantiation.core.model.tracing.AbstractVilTracer
-
- All Implemented Interfaces:
ITracer,ITracer,IInstantiatorTracer,ITracer,ITracer
- Direct Known Subclasses:
StreamVilTracer,VilTracer
public abstract class AbstractVilTracer extends AbstractTracerBase implements ITracer, ITracer, IInstantiatorTracer
Implements a combined tracer for VIL and VTL with common indentation.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanemitTraceTextprivate booleanenableprivate java.lang.Stringindentationprivate static java.lang.StringINDENTATION_STEP
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractVilTracer()Creates a tracer instance without emitting trace texts.protectedAbstractVilTracer(boolean emitTraceText)Creates a tracer instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Collection<java.lang.Object>adjustSequenceForJoin(Collection<java.lang.Object> collection)Allows a tracer to change the sequence of processing a map collection.Collection<?>adjustSequenceForMap(Collection<?> collection)Allows a tracer to change the sequence of processing a map collection.private static java.util.Map<?,?>cleanImplicitFromOptionalArgument(java.util.Map<?,?> argument)Cleans implicit arguments from the optional arguments.private voiddecreaseIndentation()Decreases the indentation by oneINDENTATION_STEPif possible.voidenable(boolean enable)Enables or disables the tracer.voidfailedAt(IBuildlangElement element)Is called when the execution of a build language element failed.voidfailedAt(Expression expression)Is called when the evaluation of an expression caused an execution failure.voidfailedAt(ITemplateLangElement element)Is called when the execution of a template language element failed.private voidincreaseIndentation()Increases the indentation by oneINDENTATION_STEP.protected booleanisEnabled()Returns whether the tracer is enabled.voidreset()Resets this tracer for reuse.voidtrace(java.lang.String text)Emits a trace string.voidtraceError(java.lang.String message)Emits an error trace string.voidtraceExecutionException(VilException exception)Traces a top-level execution exception, i.e., execution a VIL script or template failed.voidtraceMessage(java.lang.String message)Trace a message (usually going to System.out in an instantiator).voidtraceWarning(java.lang.String message)Emits a warning trace string.voidvalueDefined(VariableDeclaration var, FieldDescriptor field, java.lang.Object value)Is called when a value of a variable is defined.voidvisitAlternative(boolean takeIf)An alternative was visited.voidvisitDef(Def def, RuntimeEnvironment<?,?> environment)Starts visiting a sub-template.voidvisitedCallExpression(OperationDescriptor descriptor, CallExpression.CallType callType, java.lang.Object[] args, java.lang.Object result)Is called after a resolved call expression is actually executed.voidvisitedDef(Def def, RuntimeEnvironment<?,?> environment, java.lang.Object result)Ends visiting a sub-template.voidvisitedFlush()Is called after a content flush.voidvisitedInstantiator(java.lang.String name, java.lang.Object result)Is called when an instantiator was visited / executed.voidvisitedLoop(IEnumeratingLoop loop, RuntimeEnvironment<?,?> environment)Is called when visiting a map ends.voidvisitedLoop(VariableDeclaration var)Visiting a loop ended.voidvisitedRule(Rule rule, RuntimeEnvironment<?,?> environment, java.lang.Object result)Is called when visiting a rule ends.voidvisitedScript(Script script)Is called when visiting a script ends.voidvisitedSwitch(java.lang.Object select, int alternative, java.lang.Object value)A switch statement was visited.voidvisitedTemplate(Template template)Ends visiting a template.voidvisitedWhileBody()Is called when visiting a while body ends.voidvisitFlush()Is called before a content flush.voidvisitingCallExpression(OperationDescriptor descriptor, CallExpression.CallType callType, java.lang.Object[] args)Is called before a resolved call expression is actually executed.voidvisitingInstantiator(java.lang.String name)Is called when an instantiator is being visited / executed.voidvisitIteratorAssignment(IEnumeratingLoop loop, VariableDeclaration var, java.lang.Object value)Is called when a loop iterator variable is assigned.voidvisitLoop(IEnumeratingLoop map, RuntimeEnvironment<?,?> environment)Is called when visiting a map starts.voidvisitLoop(VariableDeclaration var)Visiting a loop started.voidvisitRule(Rule rule, RuntimeEnvironment<?,?> environment)Is called when visiting a rule starts.voidvisitScript(Script script, RuntimeEnvironment<?,?> environment)Is called when a script (header) is being visited.voidvisitScriptBody(Script script, RuntimeEnvironment<?,?> environment)Is called when a script (body) is being visited.voidvisitSystemCall(java.lang.String[] args)Is called before executing a system call.voidvisitTemplate(Template template)Starts visiting a template.voidvisitWhileBody()Is called when visiting a while body starts.protected voidwrite(java.lang.String msg)Writes a message and indents it.protected abstract voidwriteImpl(java.lang.String msg)Writes a message.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.AbstractTracerBase
getLocale, getRuntimeEnvironment, setLocale, setRuntimeEnvironment
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.expressions.ITracer
getLocale, getRuntimeEnvironment, setLocale, setRuntimeEnvironment
-
-
-
-
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
-
-
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 totrace(String)shall be emitted
-
-
Method Detail
-
increaseIndentation
private void increaseIndentation()
Increases the indentation by oneINDENTATION_STEP.
-
decreaseIndentation
private void decreaseIndentation()
Decreases the indentation by oneINDENTATION_STEPif 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:ITracerEmits a trace string.
-
valueDefined
public void valueDefined(VariableDeclaration var, FieldDescriptor field, java.lang.Object value)
Description copied from interface:ITracerIs called when a value of a variable is defined.- Specified by:
valueDefinedin interfaceITracer- Parameters:
var- the modified variablefield- the field invar, may be nullvalue- the actual value
-
traceExecutionException
public void traceExecutionException(VilException exception)
Description copied from interface:ITracerTraces a top-level execution exception, i.e., execution a VIL script or template failed.- Specified by:
traceExecutionExceptionin interfaceITracer- 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:ITracerIs called after a resolved call expression is actually executed. Do not modify the parameters!- Specified by:
visitedCallExpressionin interfaceITracer- Parameters:
descriptor- the descriptor to be calledcallType- the type of the callargs- the actual argumentsresult- the result of the call
-
visitingCallExpression
public void visitingCallExpression(OperationDescriptor descriptor, CallExpression.CallType callType, java.lang.Object[] args)
Description copied from interface:ITracerIs called before a resolved call expression is actually executed. Do not modify the parameters!- Specified by:
visitingCallExpressionin interfaceITracer- Parameters:
descriptor- the descriptor to be calledcallType- the type of the callargs- the actual arguments
-
visitRule
public void visitRule(Rule rule, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerIs called when visiting a rule starts.
-
visitedRule
public void visitedRule(Rule rule, RuntimeEnvironment<?,?> environment, java.lang.Object result)
Description copied from interface:ITracerIs called when visiting a rule ends.- Specified by:
visitedRulein interfaceITracer- Parameters:
rule- the rule being visitedenvironment- the runtime environmentresult- the result produced by the rule
-
visitLoop
public void visitLoop(IEnumeratingLoop map, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerIs called when visiting a map starts.
-
visitIteratorAssignment
public void visitIteratorAssignment(IEnumeratingLoop loop, VariableDeclaration var, java.lang.Object value)
Description copied from interface:ITracerIs called when a loop iterator variable is assigned.- Specified by:
visitIteratorAssignmentin interfaceITracer- Parameters:
loop- the loopvar- the iterator variablevalue- the actual value
-
visitedLoop
public void visitedLoop(IEnumeratingLoop loop, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerIs called when visiting a map ends.- Specified by:
visitedLoopin interfaceITracer- Parameters:
loop- the loop being visitedenvironment- the runtime environment
-
adjustSequenceForMap
public Collection<?> adjustSequenceForMap(Collection<?> collection)
Description copied from interface:ITracerAllows 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:
adjustSequenceForMapin interfaceITracer- 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:ITracerAllows 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:
adjustSequenceForJoinin interfaceITracer- 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:ITracerIs called before executing a system call.- Specified by:
visitSystemCallin interfaceITracer- Parameters:
args- the arguments for the system call
-
visitingInstantiator
public void visitingInstantiator(java.lang.String name)
Description copied from interface:ITracerIs called when an instantiator is being visited / executed.- Specified by:
visitingInstantiatorin interfaceITracer- Parameters:
name- the name of the instantiator
-
visitedInstantiator
public void visitedInstantiator(java.lang.String name, java.lang.Object result)Description copied from interface:ITracerIs called when an instantiator was visited / executed.- Specified by:
visitedInstantiatorin interfaceITracer- Parameters:
name- the name of the instantiatorresult- the result of the execution
-
failedAt
public void failedAt(Expression expression)
Description copied from interface:ITracerIs called when the evaluation of an expression caused an execution failure.
-
failedAt
public void failedAt(IBuildlangElement element)
Description copied from interface:ITracerIs called when the execution of a build language element failed.
-
visitScript
public void visitScript(Script script, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerIs called when a script (header) is being visited.- Specified by:
visitScriptin interfaceITracer- Parameters:
script- the scriptenvironment- the runtime environment
-
visitScriptBody
public void visitScriptBody(Script script, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerIs called when a script (body) is being visited.- Specified by:
visitScriptBodyin interfaceITracer- Parameters:
script- the scriptenvironment- the runtime environment
-
visitedScript
public void visitedScript(Script script)
Description copied from interface:ITracerIs called when visiting a script ends.- Specified by:
visitedScriptin interfaceITracer- Parameters:
script- the script
-
visitDef
public void visitDef(Def def, RuntimeEnvironment<?,?> environment)
Description copied from interface:ITracerStarts visiting a sub-template.
-
visitedDef
public void visitedDef(Def def, RuntimeEnvironment<?,?> environment, java.lang.Object result)
Description copied from interface:ITracerEnds visiting a sub-template.- Specified by:
visitedDefin interfaceITracer- Parameters:
def- the sub-templateenvironment- the runtime environmentresult- the execution result
-
visitedSwitch
public void visitedSwitch(java.lang.Object select, int alternative, java.lang.Object value)Description copied from interface:ITracerA switch statement was visited.- Specified by:
visitedSwitchin interfaceITracer- Parameters:
select- the select valuealternative- 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:ITracerVisiting a loop started.
-
visitedLoop
public void visitedLoop(VariableDeclaration var)
Description copied from interface:ITracerVisiting a loop ended.- Specified by:
visitedLoopin interfaceITracer- Parameters:
var- the loop/iterator variable
-
visitAlternative
public void visitAlternative(boolean takeIf)
Description copied from interface:ITracerAn alternative was visited.- Specified by:
visitAlternativein interfaceITracer- Specified by:
visitAlternativein interfaceITracer- Parameters:
takeIf- iftruethe if-branch is used,falseelse the else-branch
-
failedAt
public void failedAt(ITemplateLangElement element)
Description copied from interface:ITracerIs called when the execution of a template language element failed.
-
visitTemplate
public void visitTemplate(Template template)
Description copied from interface:ITracerStarts visiting a template.- Specified by:
visitTemplatein interfaceITracer- Parameters:
template- the template being visited
-
visitedTemplate
public void visitedTemplate(Template template)
Description copied from interface:ITracerEnds visiting a template.- Specified by:
visitedTemplatein interfaceITracer- Parameters:
template- the template
-
reset
public void reset()
Description copied from interface:ITracerResets this tracer for reuse.
-
traceMessage
public void traceMessage(java.lang.String message)
Trace a message (usually going to System.out in an instantiator).- Specified by:
traceMessagein interfaceIInstantiatorTracer- Parameters:
message- the message to be traced
-
traceError
public void traceError(java.lang.String message)
Description copied from interface:ITracerEmits an error trace string.- Specified by:
traceErrorin interfaceIInstantiatorTracer- Specified by:
traceErrorin interfaceITracer- Parameters:
message- the text to be emitted
-
traceWarning
public void traceWarning(java.lang.String message)
Description copied from interface:ITracerEmits a warning trace string.- Specified by:
traceWarningin interfaceITracer- Parameters:
message- the text to be emitted
-
visitWhileBody
public void visitWhileBody()
Description copied from interface:ITracerIs called when visiting a while body starts.- Specified by:
visitWhileBodyin interfaceITracer- Specified by:
visitWhileBodyin interfaceITracer
-
visitedWhileBody
public void visitedWhileBody()
Description copied from interface:ITracerIs called when visiting a while body ends.- Specified by:
visitedWhileBodyin interfaceITracer- Specified by:
visitedWhileBodyin interfaceITracer
-
isEnabled
protected boolean isEnabled()
Returns whether the tracer is enabled.- Returns:
trueenabled,falseelse
-
enable
public void enable(boolean enable)
Description copied from interface:ITracerEnables or disables the tracer. By default, a tracer is enabled.
-
visitFlush
public void visitFlush()
Description copied from interface:ITracerIs called before a content flush.- Specified by:
visitFlushin interfaceITracer
-
visitedFlush
public void visitedFlush()
Description copied from interface:ITracerIs called after a content flush.- Specified by:
visitedFlushin interfaceITracer
-
-