Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/languages/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -79,7 +82,10 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
),
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);
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]
Original file line number Diff line number Diff line change
@@ -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}]