Skip to content

Commit 4197265

Browse files
Merge branch 'main' into insert-snippet
2 parents a8e8139 + a22b4bf commit 4197265

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1445
-8
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"nonlocal",
2222
"pojo",
2323
"subword"
24-
]
24+
],
25+
"files.eol": "\n"
2526
}

cursorless-talon/src/modifiers/containing_scope.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"arg": "argumentOrParameter",
1616
"attribute": "attribute",
1717
"call": "functionCall",
18+
"callee": "functionCallee",
1819
"class name": "className",
1920
"class": "class",
2021
"comment": "comment",

docs/user/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ For programming languages where Cursorless has rich parse tree support, we suppo
133133
| `"arg"` | function parameter or function call argument |
134134
| `"attribute"` | attribute, eg on html element |
135135
| `"call"` | function call, eg `foo(1, 2)` |
136+
| `"callee"` | the function being called in a function call |
136137
| `"class name"` | the name in a class declaration |
137138
| `"class"` | class definition |
138139
| `"comment"` | comment |

src/languages/clojure.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ const nodeMatchers: Partial<
167167
string: "str_lit",
168168

169169
functionCall: functionCallPattern,
170+
functionCallee: chainedMatcher([
171+
functionCallFinder,
172+
(functionNode) => getValueNodes(functionNode)[0],
173+
]),
170174

171175
namedFunction: matcher(functionFinder),
172176

src/languages/cpp.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ const nodeMatchers: Partial<
8484
comment: "comment",
8585
anonymousFunction: "lambda_expression",
8686
list: "initializer_list",
87-
functionCall: "call_expression",
87+
functionCall: ["call_expression", "declaration.init_declarator!"],
88+
functionCallee: [
89+
"call_expression[function]",
90+
"declaration.init_declarator[declarator]!",
91+
],
8892
name: [
8993
"*[declarator][declarator][name]",
9094
"*[declarator][name]",

src/languages/csharp.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
import { NodeMatcherAlternative } from "../typings/Types";
1414
import { SimpleScopeTypeType } from "../typings/targetDescriptor.types";
1515
import { nodeFinder, typedNodeFinder } from "../util/nodeFinders";
16-
import { delimitedSelector } from "../util/nodeSelectors";
16+
import { delimitedSelector, childRangeSelector } from "../util/nodeSelectors";
17+
import { patternFinder } from "../util/nodeFinders";
1718

1819
// Generated by the following command:
1920
// > curl https://github.com/raw/tree-sitter/tree-sitter-c-sharp/master/src/node-types.json \
@@ -229,7 +230,14 @@ const nodeMatchers: Partial<
229230
),
230231
statement: STATEMENT_TYPES,
231232
anonymousFunction: "lambda_expression",
232-
functionCall: "invocation_expression",
233+
functionCall: ["invocation_expression", "object_creation_expression"],
234+
functionCallee: cascadingMatcher(
235+
patternMatcher("invocation_expression[function]"),
236+
matcher(
237+
patternFinder("object_creation_expression"),
238+
childRangeSelector(["argument_list"], [])
239+
)
240+
),
233241
argumentOrParameter: matcher(
234242
nodeFinder(
235243
(node) =>

src/languages/go.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const nodeMatchers: Partial<
4545
statement: STATEMENT_TYPES,
4646
string: ["interpreted_string_literal", "raw_string_literal"],
4747
ifStatement: "if_statement",
48-
functionCall: "call_expression",
48+
functionCall: ["call_expression", "composite_literal"],
49+
functionCallee: ["call_expression[function]", "composite_literal[type]"],
4950
comment: "comment",
5051
namedFunction: ["function_declaration", "method_declaration"],
5152
type: [

src/languages/java.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
leadingMatcher,
55
conditionMatcher,
66
trailingMatcher,
7+
matcher,
8+
cascadingMatcher,
79
} from "../util/nodeMatchers";
10+
import { childRangeSelector } from "../util/nodeSelectors";
11+
import { patternFinder } from "../util/nodeFinders";
12+
813
import { NodeMatcherAlternative } from "../typings/Types";
914
import { SimpleScopeTypeType } from "../typings/targetDescriptor.types";
1015

@@ -55,7 +60,25 @@ const nodeMatchers: Partial<
5560
comment: "comment",
5661
anonymousFunction: "lambda_expression",
5762
list: "array_initializer",
58-
functionCall: "method_invocation",
63+
functionCall: [
64+
"method_invocation",
65+
"object_creation_expression",
66+
"explicit_constructor_invocation",
67+
],
68+
functionCallee: cascadingMatcher(
69+
matcher(
70+
patternFinder("method_invocation"),
71+
childRangeSelector(["argument_list"], [])
72+
),
73+
matcher(
74+
patternFinder("object_creation_expression"),
75+
childRangeSelector(["argument_list"], [])
76+
),
77+
matcher(
78+
patternFinder("explicit_constructor_invocation"),
79+
childRangeSelector(["argument_list", ";"], [])
80+
)
81+
),
5982
map: "block",
6083
name: [
6184
"*[declarator][name]",

src/languages/python.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const nodeMatchers: Partial<
6060
ifStatement: "if_statement",
6161
anonymousFunction: "lambda?.lambda",
6262
functionCall: "call",
63+
functionCallee: "call[function]",
6364
comment: "comment",
6465
class: "decorated_definition?.class_definition",
6566
className: "class_definition[name]",

src/languages/ruby.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ const nodeMatchers: Partial<
167167
ifStatement: "if",
168168
functionCall: "call",
169169
comment: "comment",
170-
namedFunction: "method",
171-
functionName: "method[name]",
170+
namedFunction: ["method", "singleton_method"],
171+
functionName: ["method[name]", "singleton_method[name]"],
172172
anonymousFunction: cascadingMatcher(
173173
patternMatcher("lambda", "do_block"),
174174
matcher(blockFinder)
@@ -189,6 +189,7 @@ const nodeMatchers: Partial<
189189
"operator_assignment[left]",
190190
"class[name]",
191191
"method[name]",
192+
"singleton_method[name]",
192193
],
193194
value: leadingMatcher(
194195
[

src/languages/scss.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const nodeMatchers: Partial<
101101
),
102102
string: "string_value",
103103
functionCall: "call_expression",
104+
functionCallee: "call_expression.function_name!",
104105
namedFunction: ["mixin_statement", "function_statement"],
105106
functionName: ["mixin_statement.name!", "function_statement.name!"],
106107
comment: ["comment", "single_line_comment"],

src/languages/typescript.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
pairSelectionExtractor,
2121
selectWithLeadingDelimiter,
2222
simpleSelectionExtractor,
23+
childRangeSelector,
2324
} from "../util/nodeSelectors";
2425
import { patternFinder } from "../util/nodeFinders";
2526

@@ -191,6 +192,13 @@ const nodeMatchers: Partial<
191192
regularExpression: "regex",
192193
className: ["class_declaration[name]", "class[name]"],
193194
functionCall: ["call_expression", "new_expression"],
195+
functionCallee: cascadingMatcher(
196+
patternMatcher("call_expression[function]"),
197+
matcher(
198+
patternFinder("new_expression"),
199+
childRangeSelector(["arguments"], [])
200+
)
201+
),
194202
statement: STATEMENT_TYPES.map((type) => `export_statement?.${type}`),
195203
condition: conditionMatcher("*[condition]"),
196204
class: [
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: clojure
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: (foo bar)
11+
selections:
12+
- anchor: {line: 0, character: 6}
13+
active: {line: 0, character: 6}
14+
marks: {}
15+
finalState:
16+
documentContents: ( bar)
17+
selections:
18+
- anchor: {line: 0, character: 1}
19+
active: {line: 0, character: 1}
20+
thatMark:
21+
- anchor: {line: 0, character: 1}
22+
active: {line: 0, character: 1}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: clojure
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: (defn messenger ([] (messenger "Hello world!")))
11+
selections:
12+
- anchor: {line: 0, character: 43}
13+
active: {line: 0, character: 43}
14+
marks: {}
15+
finalState:
16+
documentContents: (defn messenger ([] ( "Hello world!")))
17+
selections:
18+
- anchor: {line: 0, character: 25}
19+
active: {line: 0, character: 25}
20+
thatMark:
21+
- anchor: {line: 0, character: 25}
22+
active: {line: 0, character: 25}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: clojure
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: ( (fn [message] (println message)) "Hello world!" )
11+
selections:
12+
- anchor: {line: 0, character: 45}
13+
active: {line: 0, character: 45}
14+
marks: {}
15+
finalState:
16+
documentContents: ( "Hello world!" )
17+
selections:
18+
- anchor: {line: 0, character: 3}
19+
active: {line: 0, character: 3}
20+
thatMark:
21+
- anchor: {line: 0, character: 3}
22+
active: {line: 0, character: 3}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: clojure
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: (apply f '(1 2 3 4))
11+
selections:
12+
- anchor: {line: 0, character: 15}
13+
active: {line: 0, character: 16}
14+
marks: {}
15+
finalState:
16+
documentContents: ( f '(1 2 3 4))
17+
selections:
18+
- anchor: {line: 0, character: 1}
19+
active: {line: 0, character: 1}
20+
thatMark:
21+
- anchor: {line: 0, character: 1}
22+
active: {line: 0, character: 1}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: cpp
2+
command:
3+
version: 1
4+
spokenForm: change call
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCall, includeSiblings: false}
9+
initialState:
10+
documentContents: Car carObj1("BMW", "X5", 1999);
11+
selections:
12+
- anchor: {line: 0, character: 19}
13+
active: {line: 0, character: 19}
14+
marks: {}
15+
finalState:
16+
documentContents: Car ;
17+
selections:
18+
- anchor: {line: 0, character: 4}
19+
active: {line: 0, character: 4}
20+
thatMark:
21+
- anchor: {line: 0, character: 4}
22+
active: {line: 0, character: 4}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCall, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: cpp
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: obj.method[0]();
11+
selections:
12+
- anchor: {line: 0, character: 14}
13+
active: {line: 0, character: 14}
14+
marks: {}
15+
finalState:
16+
documentContents: ();
17+
selections:
18+
- anchor: {line: 0, character: 0}
19+
active: {line: 0, character: 0}
20+
thatMark:
21+
- anchor: {line: 0, character: 0}
22+
active: {line: 0, character: 0}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: cpp
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: obj.method[0]().otherMethod();
11+
selections:
12+
- anchor: {line: 0, character: 28}
13+
active: {line: 0, character: 28}
14+
marks: {}
15+
finalState:
16+
documentContents: ();
17+
selections:
18+
- anchor: {line: 0, character: 0}
19+
active: {line: 0, character: 0}
20+
thatMark:
21+
- anchor: {line: 0, character: 0}
22+
active: {line: 0, character: 0}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: cpp
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: Car carObj1("X5", 1999);
11+
selections:
12+
- anchor: {line: 0, character: 17}
13+
active: {line: 0, character: 17}
14+
marks: {}
15+
finalState:
16+
documentContents: Car ("X5", 1999);
17+
selections:
18+
- anchor: {line: 0, character: 4}
19+
active: {line: 0, character: 4}
20+
thatMark:
21+
- anchor: {line: 0, character: 4}
22+
active: {line: 0, character: 4}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: cpp
2+
command:
3+
version: 1
4+
spokenForm: change callee
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}
9+
initialState:
10+
documentContents: method();
11+
selections:
12+
- anchor: {line: 0, character: 7}
13+
active: {line: 0, character: 7}
14+
marks: {}
15+
finalState:
16+
documentContents: ();
17+
selections:
18+
- anchor: {line: 0, character: 0}
19+
active: {line: 0, character: 0}
20+
thatMark:
21+
- anchor: {line: 0, character: 0}
22+
active: {line: 0, character: 0}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: functionCallee, includeSiblings: false}, isImplicit: false}]

0 commit comments

Comments
 (0)