Skip to content

Commit 3a0d9c8

Browse files
Rust scope migration (#2344)
## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent d0a2b2a commit 3a0d9c8

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

packages/cursorless-engine/src/languages/rust.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,11 @@ const nodeMatchers: Partial<
156156
),
157157
leadingMatcher(["*.match_pattern![condition]"], ["if"]),
158158
),
159-
functionCall: ["call_expression", "macro_invocation", "struct_expression"],
160-
functionCallee: "call_expression[function]",
161-
list: ["array_expression", "tuple_expression"],
162159
collectionItem: argumentMatcher(
163160
"array_expression",
164161
"tuple_expression",
165162
"tuple_type",
166163
),
167-
namedFunction: "function_item",
168164
type: cascadingMatcher(
169165
leadingMatcher(
170166
[
@@ -191,8 +187,6 @@ const nodeMatchers: Partial<
191187
"array_type[element]",
192188
),
193189
),
194-
functionName: ["function_item[name]"],
195-
anonymousFunction: "closure_expression",
196190
argumentOrParameter: argumentMatcher(
197191
"arguments",
198192
"parameters",
@@ -221,8 +215,6 @@ const nodeMatchers: Partial<
221215
),
222216
trailingMatcher(["field_initializer[name]", "field_pattern[name]"], [":"]),
223217
),
224-
class: ["struct_item", "struct_expression", "enum_item"],
225-
className: ["struct_item[name]", "enum_item[name]", "trait_item[name]"],
226218
value: cascadingMatcher(
227219
leadingMatcher(["let_declaration[value]"], ["="]),
228220
leadingMatcher(
@@ -238,7 +230,6 @@ const nodeMatchers: Partial<
238230
matcher(patternFinder("else_clause"), elseExtractor("if_expression")),
239231
matcher(patternFinder("if_expression"), elseIfExtractor()),
240232
),
241-
["private.switchStatementSubject"]: "match_expression[value]",
242233
};
243234

244235
export default createPatternMatchers(nodeMatchers);

queries/rust.scm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,43 @@
1515
(line_comment)
1616
(block_comment)
1717
] @comment @textFragment
18+
19+
[
20+
(struct_item
21+
name: (_) @className
22+
)
23+
(enum_item
24+
name: (_) @className
25+
)
26+
] @class @className.domain
27+
28+
(struct_expression) @class
29+
30+
(trait_item
31+
name: (_) @className
32+
) @_.domain
33+
34+
(function_item
35+
name: (_) @functionName
36+
) @namedFunction @functionName.domain
37+
38+
[
39+
(call_expression)
40+
(macro_invocation)
41+
(struct_expression)
42+
] @functionCall
43+
44+
(call_expression
45+
function: (_) @functionCallee
46+
) @_.domain
47+
48+
(closure_expression) @anonymousFunction
49+
50+
[
51+
(array_expression)
52+
(tuple_expression)
53+
] @list
54+
55+
(match_expression
56+
value: (_) @private.switchStatementSubject
57+
) @_.domain

0 commit comments

Comments
 (0)