Skip to content

JSONPath Tools / @jsonpath-tools/jsonpath / IndexSelector

Class: IndexSelector

Index selector.

Extends

Constructors

Constructor

ts
new IndexSelector(indexToken, index): IndexSelector;

Parameters

indexToken

SyntaxTreeToken

Index token.

index

number

Index.

Returns

IndexSelector

Overrides

Selector.constructor

Properties

_parent

ts
_parent: SyntaxTreeNode | null = null;

Internal

Inherited from

Selector._parent


children

ts
readonly children: SyntaxTree[];

Children.

Inherited from

Selector.children


index

ts
readonly index: number;

Index.


indexToken

ts
readonly indexToken: SyntaxTreeToken;

Index token.


length

ts
readonly length: number;

Length in the text.

Inherited from

Selector.length


position

ts
readonly position: number;

Position in the text.

Inherited from

Selector.position

Accessors

parent

Get Signature

ts
get parent(): SyntaxTreeNode | null;

Parent or null when no parent is assigned.

Returns

SyntaxTreeNode | null

Inherited from

Selector.parent


skippedTextBefore

Get Signature

ts
get skippedTextBefore(): string;

Text that was skipped during parsing.

Returns

string

Text that was skipped during parsing.

Inherited from

Selector.skippedTextBefore


textRange

Get Signature

ts
get textRange(): TextRange;

Range in the text.

Returns

TextRange

Inherited from

Selector.textRange


textRangeWithoutSkipped

Get Signature

ts
get textRangeWithoutSkipped(): TextRange;

Range in the text excluding skipped text before.

Returns

TextRange

Inherited from

Selector.textRangeWithoutSkipped


type

Get Signature

ts
get type(): SyntaxTreeType;

Type.

Returns

SyntaxTreeType

Type.

Overrides

Selector.type

Methods

forEach()

ts
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

Inherited from

Selector.forEach


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

Inherited from

Selector.getAtPosition


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

Inherited from

Selector.getContainingAtPosition


getTouchingAtPosition()

ts
getTouchingAtPosition(caretPosition): SyntaxTree[];

Returns all innermost subtrees that touch the given caret position.

Parameters

caretPosition

number

Position (caret position index).

Returns

SyntaxTree[]

Inherited from

Selector.getTouchingAtPosition


select()

ts
select(
   input, 
   output, 
   queryContext): void;

Selects nodes from the input node to the output array.

Parameters

input

Node

Input node.

output

PushOnlyArray<Node>

Output nodes.

queryContext

QueryContext

Query context.

Returns

void

Overrides

Selector.select