Class Debugger
java.lang.Object
org.apache.commons.jexl3.parser.ParserVisitor
org.apache.commons.jexl3.internal.Debugger
- All Implemented Interfaces:
JexlInfo.Detail
- Direct Known Subclasses:
TemplateDebugger
Helps pinpoint the cause of problems in expressions that fail during evaluation.
It rebuilds an expression string from the tree and the start/end offsets of the cause in that string. This implies that exceptions during evaluation do always carry the node that's causing the error.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringArrow symbol.protected final StringBuilderThe builder to compose messages.protected JexlNodeThe cause of the issue to debug.protected intAccept() relative depth.protected intThe ending character location offset of the cause in the builder.protected intPerform indentation?.protected intThe indentation level.protected StringEOL.protected booleanPragmas out.protected static final PatternChecks identifiers that contain spaces or punctuation (but underscore, at-sign, sharp-sign and dollar).protected intThe starting character location offset of the cause in the builder. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectChecks if a child node is the cause to debug & adds its representation to the rebuilt expression.protected ObjectacceptStatement(JexlNode child, Object data) Adds a statement node to the rebuilt expression.protected ObjectadditiveNode(JexlNode node, String op, Object data) Rebuilds an additive expression.protected ObjectChecks if a terminal node is the cause to debug & adds its representation to the rebuilt expression.Rebuilds an expression from a JEXL node.booleandebug(JexlExpression jscript) Position the debugger on the root of an expression.booleandebug(JexlScript jscript) Position the debugger on the root of a script.booleanSeeks the location of an error cause (a node) in an expression.booleanSeeks the location of an error cause (a node) in an expression.depth(int rdepth) Sets this debugger relative maximum depth.intend()protected JexlFeaturesgetFeatures(JexlNode node) Tries (hard) to find the features used to parse a node.indentation(int level) Sets the indentation level.protected ObjectinfixChildren(JexlNode node, String infix, boolean paren, Object data) Checks if the children of a node using infix notation is the cause to debug, adds their representation to the rebuilt expression.private static booleanisLambdaExpr(ASTJexlLambda lambda) private static booleanisStatement(JexlNode child) Whether a node is a statement (vs an expression).Sets this debugger line-feed string.protected booleanneedQuotes(String str) Checks whether an identifier should be quoted or not.outputPragmas(boolean flag) Lets the debugger write out pragmas if any.protected ObjectpostfixChild(JexlNode node, String prefix, Object data) Postfix operators.protected ObjectprefixChild(JexlNode node, String prefix, Object data) Checks if the child of a node using prefix notation is the cause to debug, adds their representation to the rebuilt expression.voidreset()Resets this debugger state.private static booleanWhether a script or expression ends with a semicolumn.protected voidsetArrowSymbol(JexlNode node) Sets the arrow style (fat or thin) depending on features.voidsetIndentation(int level) Sets the indentation level.intstart()toString()protected Objectvisit(ASTAddNode node, Object data) protected Objectvisit(ASTAndNode node, Object data) protected Objectvisit(ASTAnnotatedStatement node, Object data) protected Objectvisit(ASTAnnotation node, Object data) protected Objectvisit(ASTArguments node, Object data) protected Objectvisit(ASTArrayAccess node, Object data) protected Objectvisit(ASTArrayLiteral node, Object data) protected Objectvisit(ASTAssignment node, Object data) protected Objectvisit(ASTBitwiseAndNode node, Object data) protected Objectvisit(ASTBitwiseComplNode node, Object data) protected Objectvisit(ASTBitwiseOrNode node, Object data) protected Objectvisit(ASTBitwiseXorNode node, Object data) protected Objectprotected Objectprotected Objectvisit(ASTConstructorNode node, Object data) protected Objectvisit(ASTContinue node, Object data) protected Objectvisit(ASTDecrementGetNode node, Object data) protected Objectvisit(ASTDefineVars node, Object data) protected Objectvisit(ASTDivNode node, Object data) protected Objectvisit(ASTDoWhileStatement node, Object data) protected Objectvisit(ASTEmptyFunction node, Object data) protected Objectprotected Objectvisit(ASTEQSNode node, Object data) protected Objectprotected Objectprotected Objectvisit(ASTExtendedLiteral node, Object data) protected Objectvisit(ASTFalseNode node, Object data) protected Objectvisit(ASTForeachStatement node, Object data) protected Objectvisit(ASTFunctionNode node, Object data) protected Objectprotected Objectvisit(ASTGetDecrementNode node, Object data) protected Objectvisit(ASTGetIncrementNode node, Object data) protected Objectprotected Objectvisit(ASTIdentifierAccess node, Object data) protected Objectvisit(ASTIdentifier node, Object data) protected Objectvisit(ASTIfStatement node, Object data) protected Objectvisit(ASTIncrementGetNode node, Object data) protected Objectvisit(ASTInstanceOf node, Object data) protected Objectvisit(ASTJexlScript node, Object arg) protected Objectvisit(ASTJxltLiteral node, Object data) protected Objectprotected Objectprotected Objectvisit(ASTMapEntry node, Object data) protected Objectvisit(ASTMapLiteral node, Object data) protected Objectvisit(ASTMethodNode node, Object data) protected Objectvisit(ASTModNode node, Object data) protected Objectvisit(ASTMulNode node, Object data) protected Objectprotected Objectvisit(ASTNESNode node, Object data) protected Objectvisit(ASTNEWNode node, Object data) protected Objectvisit(ASTNotInstanceOf node, Object data) protected Objectvisit(ASTNotNode node, Object data) protected Objectprotected Objectvisit(ASTNSWNode node, Object data) protected Objectvisit(ASTNullLiteral node, Object data) protected Objectvisit(ASTNullpNode node, Object data) protected Objectvisit(ASTNumberLiteral node, Object data) protected Objectprotected Objectvisit(ASTQualifiedIdentifier node, Object data) protected Objectvisit(ASTRangeNode node, Object data) protected Objectvisit(ASTReferenceExpression node, Object data) protected Objectvisit(ASTReference node, Object data) protected Objectvisit(ASTRegexLiteral node, Object data) protected Objectvisit(ASTReturnStatement node, Object data) protected Objectvisit(ASTSetAddNode node, Object data) protected Objectvisit(ASTSetAndNode node, Object data) protected Objectvisit(ASTSetDivNode node, Object data) protected Objectvisit(ASTSetLiteral node, Object data) protected Objectvisit(ASTSetModNode node, Object data) protected Objectvisit(ASTSetMultNode node, Object data) protected Objectvisit(ASTSetOrNode node, Object data) protected Objectvisit(ASTSetShiftLeftNode node, Object data) protected Objectvisit(ASTSetShiftRightNode node, Object data) protected Objectvisit(ASTSetShiftRightUnsignedNode node, Object data) protected Objectvisit(ASTSetSubNode node, Object data) protected Objectvisit(ASTSetXorNode node, Object data) protected Objectvisit(ASTShiftLeftNode node, Object data) protected Objectvisit(ASTShiftRightNode node, Object data) protected Objectvisit(ASTShiftRightUnsignedNode node, Object data) protected Objectvisit(ASTSizeFunction node, Object data) protected Objectvisit(ASTStringLiteral node, Object data) protected Objectvisit(ASTSubNode node, Object data) protected Objectprotected Objectvisit(ASTTernaryNode node, Object data) protected Objectvisit(ASTThrowStatement node, Object data) protected Objectvisit(ASTTrueNode node, Object data) protected Objectvisit(ASTTryResources node, Object data) protected Objectvisit(ASTTryStatement node, Object data) protected Objectvisit(ASTUnaryMinusNode node, Object data) protected Objectvisit(ASTUnaryPlusNode node, Object data) protected Objectprotected Objectvisit(ASTWhileStatement node, Object data) protected StringvisitParameter(String p, Object data) A pseudo visitor for parameters.private static voidwritePragmas(StringBuilder builder, Map<String, Object> pragmas) Stringifies the pragmas.Methods inherited from class org.apache.commons.jexl3.parser.ParserVisitor
visit, visit
-
Field Details
-
QUOTED_IDENTIFIER
Checks identifiers that contain spaces or punctuation (but underscore, at-sign, sharp-sign and dollar). -
builder
The builder to compose messages. -
cause
The cause of the issue to debug. -
start
protected int startThe starting character location offset of the cause in the builder. -
end
protected int endThe ending character location offset of the cause in the builder. -
indentLevel
protected int indentLevelThe indentation level. -
indent
protected int indentPerform indentation?. -
depth
protected int depthAccept() relative depth. -
arrow
Arrow symbol. -
lf
EOL. -
outputPragmas
protected boolean outputPragmasPragmas out.
-
-
Constructor Details
-
Debugger
public Debugger()Creates a Debugger.
-
-
Method Details
-
isLambdaExpr
-
isStatement
Whether a node is a statement (vs an expression).- Parameters:
child- the node- Returns:
- true if node is a statement
-
semicolTerminated
Whether a script or expression ends with a semicolumn.- Parameters:
cs- the string- Returns:
- true if a semicolumn is the last non-whitespace character
-
writePragmas
Stringifies the pragmas.- Parameters:
builder- where to stringifypragmas- the pragmas, may be null
-
accept
Checks if a child node is the cause to debug & adds its representation to the rebuilt expression.- Parameters:
node- the child nodedata- visitor pattern argument- Returns:
- visitor pattern value
-
acceptStatement
Adds a statement node to the rebuilt expression.- Parameters:
child- the child nodedata- visitor pattern argument- Returns:
- visitor pattern value
-
additiveNode
Rebuilds an additive expression.- Parameters:
node- the nodeop- the operatordata- visitor pattern argument- Returns:
- visitor pattern value
-
check
Checks if a terminal node is the cause to debug & adds its representation to the rebuilt expression.- Parameters:
node- the child nodeimage- the child node token image (optionally null)data- visitor pattern argument- Returns:
- visitor pattern value
-
data
Rebuilds an expression from a JEXL node.- Parameters:
node- the node to rebuilt from- Returns:
- the rebuilt expression
- Since:
- 3.0
-
debug
Position the debugger on the root of an expression.- Parameters:
jscript- the expression- Returns:
- true if the expression was a
Scriptinstance, false otherwise
-
debug
Seeks the location of an error cause (a node) in an expression.- Parameters:
node- the node to debug- Returns:
- true if the cause was located, false otherwise
-
debug
Seeks the location of an error cause (a node) in an expression.- Parameters:
node- the node to debugr- whether we should actively find the root node of the debugged node- Returns:
- true if the cause was located, false otherwise
-
debug
Position the debugger on the root of a script.- Parameters:
jscript- the script- Returns:
- true if the script was a
Scriptinstance, false otherwise
-
depth
Sets this debugger relative maximum depth.- Parameters:
rdepth- the maximum relative depth from the debugged node- Returns:
- this debugger instance
-
end
public int end()- Specified by:
endin interfaceJexlInfo.Detail- Returns:
- The end offset location of the cause in the expression
-
getFeatures
Tries (hard) to find the features used to parse a node.- Parameters:
node- the node- Returns:
- the features or null
-
indentation
Sets the indentation level.- Parameters:
level- the number of spaces for indentation, none if less or equal to zero- Returns:
- this debugger instance
-
infixChildren
Checks if the children of a node using infix notation is the cause to debug, adds their representation to the rebuilt expression.- Parameters:
node- the child nodeinfix- the child node tokenparen- whether the child should be parenthesizeddata- visitor pattern argument- Returns:
- visitor pattern value
-
lineFeed
Sets this debugger line-feed string.- Parameters:
lf- the string used to delineate lines (usually "\" or "")- Returns:
- this debugger instance
-
needQuotes
Checks whether an identifier should be quoted or not.- Parameters:
str- the identifier- Returns:
- true if needing quotes, false otherwise
-
outputPragmas
Lets the debugger write out pragmas if any.- Parameters:
flag- turn on or off- Returns:
- this debugger instance
-
postfixChild
Postfix operators.- Parameters:
node- a postfix operatorprefix- the postfixdata- visitor pattern argument- Returns:
- visitor pattern value
-
prefixChild
Checks if the child of a node using prefix notation is the cause to debug, adds their representation to the rebuilt expression.- Parameters:
node- the nodeprefix- the node tokendata- visitor pattern argument- Returns:
- visitor pattern value
-
reset
public void reset()Resets this debugger state. -
setArrowSymbol
Sets the arrow style (fat or thin) depending on features.- Parameters:
node- the node to start seeking features from.
-
setIndentation
public void setIndentation(int level) Sets the indentation level.- Parameters:
level- the number of spaces for indentation, none if less or equal to zero
-
start
public int start()- Specified by:
startin interfaceJexlInfo.Detail- Returns:
- The starting offset location of the cause in the expression
-
toString
- Specified by:
toStringin interfaceJexlInfo.Detail- Overrides:
toStringin classObject- Returns:
- The rebuilt expression
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visit
- Specified by:
visitin classParserVisitor
-
visitParameter
A pseudo visitor for parameters.- Parameters:
p- the parameter namedata- the visitor argument- Returns:
- the parameter name to use
-