Skip to content

Commit

Permalink
Rust scope migration (#2344)
Browse files Browse the repository at this point in the history
## 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 <755842+pokey@users.noreply.github.com>
  • Loading branch information
AndreasArvidsson and pokey authored Jun 14, 2024
1 parent d0a2b2a commit 3a0d9c8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
9 changes: 0 additions & 9 deletions packages/cursorless-engine/src/languages/rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,11 @@ const nodeMatchers: Partial<
),
leadingMatcher(["*.match_pattern![condition]"], ["if"]),
),
functionCall: ["call_expression", "macro_invocation", "struct_expression"],
functionCallee: "call_expression[function]",
list: ["array_expression", "tuple_expression"],
collectionItem: argumentMatcher(
"array_expression",
"tuple_expression",
"tuple_type",
),
namedFunction: "function_item",
type: cascadingMatcher(
leadingMatcher(
[
Expand All @@ -191,8 +187,6 @@ const nodeMatchers: Partial<
"array_type[element]",
),
),
functionName: ["function_item[name]"],
anonymousFunction: "closure_expression",
argumentOrParameter: argumentMatcher(
"arguments",
"parameters",
Expand Down Expand Up @@ -221,8 +215,6 @@ const nodeMatchers: Partial<
),
trailingMatcher(["field_initializer[name]", "field_pattern[name]"], [":"]),
),
class: ["struct_item", "struct_expression", "enum_item"],
className: ["struct_item[name]", "enum_item[name]", "trait_item[name]"],
value: cascadingMatcher(
leadingMatcher(["let_declaration[value]"], ["="]),
leadingMatcher(
Expand All @@ -238,7 +230,6 @@ const nodeMatchers: Partial<
matcher(patternFinder("else_clause"), elseExtractor("if_expression")),
matcher(patternFinder("if_expression"), elseIfExtractor()),
),
["private.switchStatementSubject"]: "match_expression[value]",
};

export default createPatternMatchers(nodeMatchers);
40 changes: 40 additions & 0 deletions queries/rust.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,43 @@
(line_comment)
(block_comment)
] @comment @textFragment

[
(struct_item
name: (_) @className
)
(enum_item
name: (_) @className
)
] @class @className.domain

(struct_expression) @class

(trait_item
name: (_) @className
) @_.domain

(function_item
name: (_) @functionName
) @namedFunction @functionName.domain

[
(call_expression)
(macro_invocation)
(struct_expression)
] @functionCall

(call_expression
function: (_) @functionCallee
) @_.domain

(closure_expression) @anonymousFunction

[
(array_expression)
(tuple_expression)
] @list

(match_expression
value: (_) @private.switchStatementSubject
) @_.domain

0 comments on commit 3a0d9c8

Please sign in to comment.