JSONPath Tools / @jsonpath-tools/jsonpath / SyntaxTree
Class: abstract SyntaxTree
Part of a query syntax tree.
Extended by
Constructors
new SyntaxTree()
new SyntaxTree(position, length): SyntaxTreeParameters
position
number
Position in the text.
length
number
Length in the text.
Returns
SyntaxTree
Properties
_parent
_parent: null | SyntaxTreeNode = null;Internal
length
readonly length: number;Length in the text.
position
readonly position: number;Position in the text.
skippedTextBefore
abstract readonly skippedTextBefore: string;Text that was skipped during parsing.
type
abstract readonly type: SyntaxTreeType;Type.
Accessors
parent
Get Signature
get parent(): null | SyntaxTreeNodeParent or null when no parent is assigned.
Returns
null | SyntaxTreeNode
textRange
Get Signature
get textRange(): TextRangeRange in the text.
Returns
textRangeWithoutSkipped
Get Signature
get textRangeWithoutSkipped(): TextRangeRange in the text excluding skipped text before.
Returns
Methods
forEach()
abstract forEach(action): voidExecutes the given action for this and all descendant trees in a pre-order tree traversal.
Parameters
action
(tree) => boolean | void
Action.
Returns
void
getAtPosition()
getAtPosition(characterPosition): null | SyntaxTreeReturns the innermost subtree that spans the given character position or null when the position is outside of a range of the current tree.
Parameters
characterPosition
number
Position (character index).
Returns
null | SyntaxTree
getContainingAtPosition()
getContainingAtPosition(caretPosition): null | SyntaxTreeReturns the innermost subtree that fully contains the given caret position (not just touches) or null when the position is not contained in a range of the current tree.
Parameters
caretPosition
number
Position (caret position index).
Returns
null | SyntaxTree
getTouchingAtPosition()
getTouchingAtPosition(caretPosition): SyntaxTree[]Returns all innermost subtrees that touch the given caret position.
Parameters
caretPosition
number
Position (caret position index).
Returns
SyntaxTree[]