Module: util/nodeMatchers
Functions
ancestorChainNodeMatcher
▸ ancestorChainNodeMatcher(nodeFinders, nodeToReturn?, selector?): NodeMatcher
Given a sequence of node finders, returns a new node matcher which applies
them in reverse, walking up the ancestor chain from node.
Returns null if any finder in the chain returns null. For example:
ancestorChainNodeMatcher([patternFinder("foo", "bar"), patternFinder("bongo")], 0)
is equivalent to:
patternFinder("foo.bongo", "bar.bongo")
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
nodeFinders | NodeFinder[] | undefined | A list of node finders to apply in sequence |
nodeToReturn | number | 0 | The index of the node from the sequence to return. For example, 0 returns the top ancestor in the chain |
selector | SelectionExtractor | simpleSelectionExtractor | The selector to apply to the final node |
Returns
A node finder which is a chain of the input node finders
Defined in
util/nodeMatchers.ts:89
argumentMatcher
▸ argumentMatcher(...parentTypes): NodeMatcher
Parameters
| Name | Type |
|---|---|
...parentTypes | string[] |
Returns
Defined in
util/nodeMatchers.ts:108
cascadingMatcher
▸ cascadingMatcher(...matchers): NodeMatcher
Create a new matcher that will try the given matchers in sequence until one returns non-null
Parameters
| Name | Type | Description |
|---|---|---|
...matchers | NodeMatcher[] | A list of matchers to try in sequence until one doesn't return null |
Returns
A NodeMatcher that tries the given matchers in sequence
Defined in
util/nodeMatchers.ts:158
chainedMatcher
▸ chainedMatcher(finders, selector?): NodeMatcher
Given a list of node finders returns a matcher which applies them in sequence returning null if any of the sequence returns null otherwise returning the output of the final node finder
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
finders | NodeFinder[] | undefined | - |
selector | SelectionExtractor | simpleSelectionExtractor | The selector to apply to the final node |
Returns
A matcher which is a chain of the input node finders
Defined in
util/nodeMatchers.ts:50
conditionMatcher
▸ conditionMatcher(...patterns): NodeMatcher
Parameters
| Name | Type |
|---|---|
...patterns | string[] |
Returns
Defined in
util/nodeMatchers.ts:115
createPatternMatchers
▸ createPatternMatchers(nodeMatchers): Record<SimpleScopeTypeType, NodeMatcher>
Parameters
| Name | Type |
|---|---|
nodeMatchers | Partial<Record<SimpleScopeTypeType, NodeMatcherAlternative>> |
Returns
Record<SimpleScopeTypeType, NodeMatcher>
Defined in
util/nodeMatchers.ts:178
leadingMatcher
▸ leadingMatcher(patterns, delimiters?): NodeMatcher
Given patterns, creates a node matcher that will add leading delimiter to
removal range.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
patterns | string[] | undefined | Patterns for pattern finder |
delimiters | string[] | [] | - |
Returns
A node matcher
Defined in
util/nodeMatchers.ts:125
matcher
▸ matcher(finder, selector?): NodeMatcher
Parameters
| Name | Type | Default value |
|---|---|---|
finder | NodeFinder | undefined |
selector | SelectionExtractor | simpleSelectionExtractor |
Returns
Defined in
util/nodeMatchers.ts:25
notSupported
▸ Const notSupported(selection, node): null | NodeMatcherValue[]
Parameters
| Name | Type |
|---|---|
selection | SelectionWithEditor |
node | SyntaxNode |
Returns
null | NodeMatcherValue[]
Defined in
util/nodeMatchers.ts:171
patternMatcher
▸ patternMatcher(...patterns): NodeMatcher
Parameters
| Name | Type |
|---|---|
...patterns | string[] |
Returns
Defined in
util/nodeMatchers.ts:104
trailingMatcher
▸ trailingMatcher(patterns, delimiters?): NodeMatcher
Given patterns, creates a node matcher that will add trailing delimiter to
removal range.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
patterns | string[] | undefined | Patterns for pattern finder |
delimiters | string[] | [] | - |
Returns
A node matcher
Defined in
util/nodeMatchers.ts:141
typeMatcher
▸ typeMatcher(...typeNames): NodeMatcher
Parameters
| Name | Type |
|---|---|
...typeNames | string[] |
Returns
Defined in
util/nodeMatchers.ts:100