diff --git a/src/languages/python.ts b/src/languages/python.ts index 9159c34048..fcec4a3117 100644 --- a/src/languages/python.ts +++ b/src/languages/python.ts @@ -7,8 +7,11 @@ import { cascadingMatcher, patternMatcher, conditionMatcher, + matcher, } from "../util/nodeMatchers"; +import { patternFinder } from "../util/nodeFinders"; import { NodeMatcherAlternative, ScopeType } from "../typings/Types"; +import { childRangeSelector } from "../util/nodeSelectors"; // Generated by the following command: // > curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-python/d6210ceab11e8d812d4ab59c07c81458ec6e5184/src/node-types.json \ @@ -79,7 +82,10 @@ const nodeMatchers: Partial> = { ), patternMatcher("return_statement.~return!") ), - argumentOrParameter: argumentMatcher("parameters", "argument_list"), + argumentOrParameter: cascadingMatcher( + argumentMatcher("parameters", "argument_list"), + matcher(patternFinder("call.generator_expression!"), childRangeSelector()) + ), }; export default createPatternMatchers(nodeMatchers); diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckArgDrum.yml b/src/test/suite/fixtures/recorded/languages/python/chuckArgDrum.yml new file mode 100644 index 0000000000..99226b71a0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckArgDrum.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck arg drum + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: d} +initialState: + documentContents: "\" \".join((word for word in word_list), (word for word in word_list))" + selections: + - anchor: {line: 0, character: 39} + active: {line: 0, character: 67} + marks: + default.d: + start: {line: 0, character: 19} + end: {line: 0, character: 23} +finalState: + documentContents: "\" \".join((word for word in word_list))" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 37} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: d}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckArgFine.yml b/src/test/suite/fixtures/recorded/languages/python/chuckArgFine.yml new file mode 100644 index 0000000000..6b2b226a2a --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckArgFine.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck arg fine + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: f} +initialState: + documentContents: "\" \".join((word for word in word_list), \"words\")" + selections: + - anchor: {line: 0, character: 47} + active: {line: 0, character: 47} + marks: + default.f: + start: {line: 0, character: 15} + end: {line: 0, character: 18} +finalState: + documentContents: "\" \".join(\"words\")" + selections: + - anchor: {line: 0, character: 17} + active: {line: 0, character: 17} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckArgWhale.yml b/src/test/suite/fixtures/recorded/languages/python/chuckArgWhale.yml new file mode 100644 index 0000000000..c4c5b66f21 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckArgWhale.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck arg whale + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: w} +initialState: + documentContents: "\" \".join(word for word in word_list)" + selections: + - anchor: {line: 0, character: 36} + active: {line: 0, character: 36} + marks: + default.w: + start: {line: 0, character: 18} + end: {line: 0, character: 22} +finalState: + documentContents: "\" \".join()" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgAir.yml b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgAir.yml new file mode 100644 index 0000000000..7981378ea0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgAir.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck every arg air + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true} + mark: {type: decoratedSymbol, symbolColor: default, character: a} +initialState: + documentContents: "\" \".join((word for word in word_list), (name for name in name_list))" + selections: + - anchor: {line: 0, character: 68} + active: {line: 0, character: 68} + marks: + default.a: + start: {line: 0, character: 40} + end: {line: 0, character: 44} +finalState: + documentContents: "\" \".join()" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgRed.yml b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgRed.yml new file mode 100644 index 0000000000..23298759dc --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgRed.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck every arg red + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true} + mark: {type: decoratedSymbol, symbolColor: default, character: r} +initialState: + documentContents: "\" \".join(word for word in word_list)" + selections: + - anchor: {line: 0, character: 36} + active: {line: 0, character: 36} + marks: + default.r: + start: {line: 0, character: 9} + end: {line: 0, character: 13} +finalState: + documentContents: "\" \".join()" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: r}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgSit.yml b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgSit.yml new file mode 100644 index 0000000000..1a7429197b --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckEveryArgSit.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: chuck every arg sit + action: remove + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true} + mark: {type: decoratedSymbol, symbolColor: default, character: i} +initialState: + documentContents: "\" \".join((word for word in word_list), another_argument)" + selections: + - anchor: {line: 0, character: 56} + active: {line: 0, character: 56} + marks: + default.i: + start: {line: 0, character: 24} + end: {line: 0, character: 26} +finalState: + documentContents: "\" \".join()" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: i}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/takeArgDrum.yml b/src/test/suite/fixtures/recorded/languages/python/takeArgDrum.yml new file mode 100644 index 0000000000..f599fa36c3 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/takeArgDrum.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: take arg drum + action: setSelection + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: d} +initialState: + documentContents: "\" \".join((word for word in word_list), \"words\")" + selections: + - anchor: {line: 0, character: 47} + active: {line: 0, character: 47} + marks: + default.d: + start: {line: 0, character: 19} + end: {line: 0, character: 23} +finalState: + documentContents: "\" \".join((word for word in word_list), \"words\")" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 37} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 37} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: d}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/takeArgRed.yml b/src/test/suite/fixtures/recorded/languages/python/takeArgRed.yml new file mode 100644 index 0000000000..a13f987eca --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/takeArgRed.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: take arg red + action: setSelection + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: r} +initialState: + documentContents: "\" \".join(word for word in word_list)" + selections: + - anchor: {line: 0, character: 36} + active: {line: 0, character: 36} + marks: + default.r: + start: {line: 0, character: 9} + end: {line: 0, character: 13} +finalState: + documentContents: "\" \".join(word for word in word_list)" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 35} + thatMark: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 35} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: r}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}] diff --git a/src/test/suite/fixtures/recorded/languages/python/takeArgWhale.yml b/src/test/suite/fixtures/recorded/languages/python/takeArgWhale.yml new file mode 100644 index 0000000000..6cc30ae7d1 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/takeArgWhale.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 1 + spokenForm: take arg whale + action: setSelection + targets: + - type: primitive + modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false} + mark: {type: decoratedSymbol, symbolColor: default, character: w} +initialState: + documentContents: "\" \".join((word for word in word_list), (word for word in word_list))" + selections: + - anchor: {line: 0, character: 68} + active: {line: 0, character: 68} + marks: + default.w: + start: {line: 0, character: 49} + end: {line: 0, character: 53} +finalState: + documentContents: "\" \".join((word for word in word_list), (word for word in word_list))" + selections: + - anchor: {line: 0, character: 39} + active: {line: 0, character: 67} + thatMark: + - anchor: {line: 0, character: 39} + active: {line: 0, character: 67} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}]