mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-05 05:17:38 +03:00
Add support for generators in js/ts (#600)
This commit is contained in:
parent
aefbcbe996
commit
cfbfcb1168
@ -162,7 +162,10 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
|
||||
patternMatcher("return_statement.~return!")
|
||||
),
|
||||
ifStatement: "if_statement",
|
||||
anonymousFunction: ["arrow_function", "function"],
|
||||
anonymousFunction: [
|
||||
"arrow_function",
|
||||
"function",
|
||||
],
|
||||
name: [
|
||||
"*[name]",
|
||||
"optional_parameter.identifier!",
|
||||
@ -182,6 +185,8 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
|
||||
functionName: [
|
||||
// function
|
||||
"function_declaration[name]",
|
||||
// generator function
|
||||
"generator_function_declaration[name]",
|
||||
// export default function
|
||||
"function[name]",
|
||||
// class method
|
||||
@ -218,6 +223,8 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
|
||||
"assignment_expression.function",
|
||||
// foo = () => { }
|
||||
"assignment_expression.arrow_function",
|
||||
// foo = function*() { }
|
||||
"generator_function_declaration",
|
||||
],
|
||||
type: cascadingMatcher(
|
||||
// Typed parameters, properties, and functions
|
||||
|
@ -0,0 +1,26 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change funk
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: namedFunction, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
function* generator(i) {
|
||||
yield i + 10;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 15}
|
||||
active: {line: 1, character: 15}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: ""
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
thatMark:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: namedFunction, includeSiblings: false}, isImplicit: false}]
|
@ -0,0 +1,29 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change name
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: name, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
function* generator(i) {
|
||||
yield i + 10;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 15}
|
||||
active: {line: 1, character: 15}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
function* (i) {
|
||||
yield i + 10;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 10}
|
||||
active: {line: 0, character: 10}
|
||||
thatMark:
|
||||
- anchor: {line: 0, character: 10}
|
||||
active: {line: 0, character: 10}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: name, includeSiblings: false}, isImplicit: false}]
|
Loading…
Reference in New Issue
Block a user