Skip to main content

Module: util/nodeSelectors

Functions

argumentSelectionExtractor

argumentSelectionExtractor(): SelectionExtractor

Returns

SelectionExtractor

Defined in

util/nodeSelectors.ts:143


childRangeSelector

childRangeSelector(typesToExclude?, typesToInclude?): (editor: TextEditor, node: SyntaxNode) => SelectionWithContext

Creates an extractor that returns a contiguous range between children of a node. When no arguments are passed, the function will return a range from the first to the last child node. Pass in either inclusions If an inclusion or exclusion list is passed, we return the first range of children such that every child in the range matches the inclusion / exclusion criteria.

Parameters

NameTypeDefault valueDescription
typesToExcludestring[][]Ensure these child types are excluded in the contiguous range returned.
typesToIncludestring[][]Ensure these child types are included in the contiguous range returned.

Returns

fn

A selection extractor

▸ (editor, node): SelectionWithContext

Parameters
NameType
editorTextEditor
nodeSyntaxNode
Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:227


delimitedSelector

delimitedSelector(isDelimiterNode, defaultDelimiter, getStartNode?, getEndNode?): SelectionExtractor

Creates a selector which can be used to automatically clean up after elements in a list by removing leading or trailing delimiters

Parameters

NameTypeDefault valueDescription
isDelimiterNode(node: SyntaxNode) => booleanundefinedA function used to determine whether a given node is a delimiter node
defaultDelimiterstringundefinedThe default list separator to use if we can't determine it by looking before or after the given node
getStartNode(node: SyntaxNode) => SyntaxNodeidentityA function to be applied to the node to determine which node is the start node if we really want to expand to a sequence of nodes
getEndNode(node: SyntaxNode) => SyntaxNodeidentityA function to be applied to the node to determine which node is the end node if we really want to expand to a sequence of nodes

Returns

SelectionExtractor

A selection extractor

Defined in

util/nodeSelectors.ts:339


delimitersSelector

delimitersSelector(...delimiters): SelectionExtractor

Parameters

NameType
...delimitersstring[]

Returns

SelectionExtractor

Defined in

util/nodeSelectors.ts:322


extendForwardPastOptional

extendForwardPastOptional(...delimiters): (editor: TextEditor, node: SyntaxNode) => SelectionWithContext

Creates an extractor that will extend past the next node if it has one of the types defined in {@link delimiters}

Parameters

NameTypeDescription
...delimitersstring[]Allowable next node type

Returns

fn

An extractor

▸ (editor, node): SelectionWithContext

Parameters
NameType
editorTextEditor
nodeSyntaxNode
Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:110


extendUntilNextMatchingSiblingOrLast

extendUntilNextMatchingSiblingOrLast(editor, node, nodeFinder): SelectionWithContext

Given a node and a node finder extends the selection from the given node until just before the next matching sibling node or the final node if no sibling matches

Parameters

NameTypeDescription
editorTextEditorThe text editor containing the given node
nodeSyntaxNodeThe node from which to extend
nodeFinderNodeFinderThe finder to use to determine whether a given node matches

Returns

SelectionWithContext

A range from the start node until just before the next matching sibling or the final sibling if non matches

Defined in

util/nodeSelectors.ts:81


getInsertionDelimiter

getInsertionDelimiter(editor, leadingDelimiterRange, trailingDelimiterRange, defaultDelimiterInsertion): undefined | string

Parameters

NameType
editorTextEditor
leadingDelimiterRangeundefined | Range
trailingDelimiterRangeundefined | Range
defaultDelimiterInsertionstring

Returns

undefined | string

Defined in

util/nodeSelectors.ts:421


getNodeInternalRange

getNodeInternalRange(node): Range

Returns node range excluding the first and last child

Parameters

NameTypeDescription
nodeSyntaxNodeThe note for which to get the internal range

Returns

Range

The internal range of the given node

Defined in

util/nodeSelectors.ts:49


getNodeRange

getNodeRange(node): Range

Parameters

NameType
nodeSyntaxNode

Returns

Range

Defined in

util/nodeSelectors.ts:26


makeNodePairSelection

makeNodePairSelection(anchor, active): Selection

Parameters

NameType
anchorSyntaxNode
activeSyntaxNode

Returns

Selection

Defined in

util/nodeSelectors.ts:35


makeRangeFromPositions

makeRangeFromPositions(startPosition, endPosition): Range

Parameters

NameType
startPositionPoint
endPositionPoint

Returns

Range

Defined in

util/nodeSelectors.ts:10


pairSelectionExtractor

pairSelectionExtractor(editor, node1, node2): SelectionWithContext

Extracts a selection from the first node to the second node. Both nodes are included in the selected nodes

Parameters

NameType
editorTextEditor
node1SyntaxNode
node2SyntaxNode

Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:126


positionFromPoint

positionFromPoint(point): Position

Parameters

NameType
pointPoint

Returns

Position

Defined in

util/nodeSelectors.ts:22


selectWithLeadingDelimiter

selectWithLeadingDelimiter(...delimiters): (editor: TextEditor, node: SyntaxNode) => SelectionWithContext

Parameters

NameType
...delimitersstring[]

Returns

fn

▸ (editor, node): SelectionWithContext

Parameters
NameType
editorTextEditor
nodeSyntaxNode
Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:180


selectWithTrailingDelimiter

selectWithTrailingDelimiter(...delimiters): (editor: TextEditor, node: SyntaxNode) => SelectionWithContext

Parameters

NameType
...delimitersstring[]

Returns

fn

▸ (editor, node): SelectionWithContext

Parameters
NameType
editorTextEditor
nodeSyntaxNode
Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:254


simpleSelectionExtractor

simpleSelectionExtractor(editor, node): SelectionWithContext

Parameters

NameType
editorTextEditor
nodeSyntaxNode

Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:58


unwrapSelectionExtractor

unwrapSelectionExtractor(editor, node): SelectionWithContext

Parameters

NameType
editorTextEditor
nodeSyntaxNode

Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:159


xmlElementExtractor

xmlElementExtractor(editor, node): SelectionWithContext

Parameters

NameType
editorTextEditor
nodeSyntaxNode

Returns

SelectionWithContext

Defined in

util/nodeSelectors.ts:398