Skip to content

JSONPath Tools / @jsonpath-tools/jsonpath / SyntaxTree

Abstract Class: SyntaxTree ​

Part of a query syntax tree.

Extended by ​

Constructors ​

Constructor ​

ts
new SyntaxTree(position, length): SyntaxTree;

Parameters ​

position ​

number

Position in the text.

length ​

number

Length in the text.

Returns ​

SyntaxTree

Properties ​

_parent ​

ts
_parent: SyntaxTreeNode | null = null;

Internal


length ​

ts
readonly length: number;

Length in the text.


position ​

ts
readonly position: number;

Position in the text.


skippedTextBefore ​

ts
abstract readonly skippedTextBefore: string;

Text that was skipped during parsing.


type ​

ts
abstract readonly type: SyntaxTreeType;

Type.

Accessors ​

parent ​

Get Signature ​

ts
get parent(): SyntaxTreeNode | null;

Parent or null when no parent is assigned.

Returns ​

SyntaxTreeNode | null


textRange ​

Get Signature ​

ts
get textRange(): TextRange;

Range in the text.

Returns ​

TextRange


textRangeWithoutSkipped ​

Get Signature ​

ts
get textRangeWithoutSkipped(): TextRange;

Range in the text excluding skipped text before.

Returns ​

TextRange

Methods ​

forEach() ​

ts
abstract forEach(action): void;

Executes the given action for this and all descendant trees in a pre-order tree traversal.

Parameters ​

action ​

(tree) => boolean | void

Action.

Returns ​

void


getAtPosition() ​

ts
getAtPosition(characterPosition): SyntaxTree | null;

Returns 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 ​

SyntaxTree | null


getContainingAtPosition() ​

ts
getContainingAtPosition(caretPosition): SyntaxTree | null;

Returns 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 ​

SyntaxTree | null


getTouchingAtPosition() ​

ts
getTouchingAtPosition(caretPosition): SyntaxTree[];

Returns all innermost subtrees that touch the given caret position.

Parameters ​

caretPosition ​

number

Position (caret position index).

Returns ​

SyntaxTree[]