Skip to content

Commit bb9cdec

Browse files
Migrate attribute
1 parent 7054ef7 commit bb9cdec

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ const nodeMatchers: Partial<
222222
patternMatcher("meta_item[value]", "const_item[value]"),
223223
matcher(returnValueFinder),
224224
),
225-
attribute: trailingMatcher(["mutable_specifier", "attribute_item"]),
226225
branch: cascadingMatcher(
227226
patternMatcher("match_arm"),
228227
matcher(patternFinder("else_clause"), elseExtractor("if_expression")),

queries/rust.scm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
;; https://github.com/tree-sitter/tree-sitter-rust/blob/master/src/grammar.json
22

3+
;; Generated by the following command:
4+
;; `curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-rust/36ae187ed6dd3803a8a89dbb54f3124c8ee74662/src/node-types.STATEMENT_TYPES | jq '[.[] | select(.type == "_declaration_statement") | .subtypes[].type, "expression_statement"]'`
5+
;; (
6+
;; (_
7+
;; [
8+
;; (associated_type)
9+
;; (attribute_item)
10+
;; (const_item)
11+
;; (empty_statement)
12+
;; (enum_item)
13+
;; (extern_crate_declaration)
14+
;; (foreign_mod_item)
15+
;; (impl_item)
16+
;; (inner_attribute_item)
17+
;; (let_declaration)
18+
;; (macro_definition)
19+
;; (macro_invocation)
20+
;; (function_item)
21+
;; (function_signature_item)
22+
;; (mod_item)
23+
;; (static_item)
24+
;; (struct_item)
25+
;; (trait_item)
26+
;; (type_item)
27+
;; (union_item)
28+
;; (use_declaration)
29+
;; (expression_statement)
30+
;; ] @statement
31+
;; ) @_dummy
32+
;; (#type? @_dummy source_file block declaration_list)
33+
;; )
34+
335
[
436
(if_expression)
537
(if_let_expression)
@@ -63,6 +95,18 @@
6395
value: (_) @private.switchStatementSubject
6496
) @_.domain
6597

98+
;;!! #[derive(Debug)]
99+
;;! ^^^^^^^^^^^^^^^^
100+
(attribute_item) @attribute
101+
102+
;;!! &mut x;
103+
;;! ^^^
104+
(_
105+
(mutable_specifier) @attribute
106+
.
107+
(_) @_.trailing.startOf
108+
) @_.domain
109+
66110
operator: [
67111
"<"
68112
"<<"

0 commit comments

Comments
 (0)