Module: util/nodeSelectors
Functions
argumentSelectionExtractor
▸ argumentSelectionExtractor(): SelectionExtractor
Returns
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
Name | Type | Default value | Description |
---|---|---|---|
typesToExclude | string [] | [] | Ensure these child types are excluded in the contiguous range returned. |
typesToInclude | string [] | [] | Ensure these child types are included in the contiguous range returned. |
Returns
fn
A selection extractor
▸ (editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
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
Name | Type | Default value | Description |
---|---|---|---|
isDelimiterNode | (node : SyntaxNode ) => boolean | undefined | A function used to determine whether a given node is a delimiter node |
defaultDelimiter | string | undefined | The default list separator to use if we can't determine it by looking before or after the given node |
getStartNode | (node : SyntaxNode ) => SyntaxNode | identity | A 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 ) => SyntaxNode | identity | A 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
A selection extractor
Defined in
util/nodeSelectors.ts:339
delimitersSelector
▸ delimitersSelector(...delimiters
): SelectionExtractor
Parameters
Name | Type |
---|---|
...delimiters | string [] |
Returns
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
Name | Type | Description |
---|---|---|
...delimiters | string [] | Allowable next node type |
Returns
fn
An extractor
▸ (editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
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
Name | Type | Description |
---|---|---|
editor | TextEditor | The text editor containing the given node |
node | SyntaxNode | The node from which to extend |
nodeFinder | NodeFinder | The finder to use to determine whether a given node matches |
Returns
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
Name | Type |
---|---|
editor | TextEditor |
leadingDelimiterRange | undefined | Range |
trailingDelimiterRange | undefined | Range |
defaultDelimiterInsertion | string |
Returns
undefined
| string
Defined in
util/nodeSelectors.ts:421
getNodeInternalRange
▸ getNodeInternalRange(node
): Range
Returns node range excluding the first and last child
Parameters
Name | Type | Description |
---|---|---|
node | SyntaxNode | The note for which to get the internal range |
Returns
The internal range of the given node
Defined in
util/nodeSelectors.ts:49
getNodeRange
▸ getNodeRange(node
): Range
Parameters
Name | Type |
---|---|
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:26
makeNodePairSelection
▸ makeNodePairSelection(anchor
, active
): Selection
Parameters
Name | Type |
---|---|
anchor | SyntaxNode |
active | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:35
makeRangeFromPositions
▸ makeRangeFromPositions(startPosition
, endPosition
): Range
Parameters
Name | Type |
---|---|
startPosition | Point |
endPosition | Point |
Returns
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
Name | Type |
---|---|
editor | TextEditor |
node1 | SyntaxNode |
node2 | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:126
positionFromPoint
▸ positionFromPoint(point
): Position
Parameters
Name | Type |
---|---|
point | Point |
Returns
Defined in
util/nodeSelectors.ts:22
selectWithLeadingDelimiter
▸ selectWithLeadingDelimiter(...delimiters
): (editor
: TextEditor
, node
: SyntaxNode
) => SelectionWithContext
Parameters
Name | Type |
---|---|
...delimiters | string [] |
Returns
fn
▸ (editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:180
selectWithTrailingDelimiter
▸ selectWithTrailingDelimiter(...delimiters
): (editor
: TextEditor
, node
: SyntaxNode
) => SelectionWithContext
Parameters
Name | Type |
---|---|
...delimiters | string [] |
Returns
fn
▸ (editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:254
simpleSelectionExtractor
▸ simpleSelectionExtractor(editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:58
unwrapSelectionExtractor
▸ unwrapSelectionExtractor(editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:159
xmlElementExtractor
▸ xmlElementExtractor(editor
, node
): SelectionWithContext
Parameters
Name | Type |
---|---|
editor | TextEditor |
node | SyntaxNode |
Returns
Defined in
util/nodeSelectors.ts:398