Skip to content

Commit b8b4014

Browse files
Migrate statement
1 parent 9fc0822 commit b8b4014

File tree

2 files changed

+30
-44
lines changed

2 files changed

+30
-44
lines changed

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import type { TextEditor } from "@cursorless/common";
1+
import type { SimpleScopeTypeType, TextEditor } from "@cursorless/common";
22
import type { Node } from "web-tree-sitter";
3-
import type { SimpleScopeTypeType } from "@cursorless/common";
43
import type {
54
NodeMatcherAlternative,
65
SelectionWithContext,
76
} from "../typings/Types";
87
import { patternFinder } from "../util/nodeFinders";
98
import {
10-
ancestorChainNodeMatcher,
119
argumentMatcher,
1210
cascadingMatcher,
1311
createPatternMatchers,
@@ -50,11 +48,6 @@ const STATEMENT_TYPES = [
5048
"expression_statement",
5149
];
5250

53-
/**
54-
* Scope types allowed to be parents of a statement
55-
*/
56-
const STATEMENT_PARENT_TYPES = ["source_file", "block", "declaration_list"];
57-
5851
/**
5952
* Returns "impl_item[type]" node higher in the chain
6053
* @param node The node which we will start our search from
@@ -142,13 +135,6 @@ function returnValueFinder(node: Node) {
142135
const nodeMatchers: Partial<
143136
Record<SimpleScopeTypeType, NodeMatcherAlternative>
144137
> = {
145-
statement: ancestorChainNodeMatcher(
146-
[
147-
patternFinder(...STATEMENT_PARENT_TYPES),
148-
patternFinder(...STATEMENT_TYPES),
149-
],
150-
1,
151-
),
152138
condition: cascadingMatcher(
153139
patternMatcher("while_expression[condition]", "if_expression[condition]"),
154140
matcher(

queries/rust.scm

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22

33
;; Generated by the following command:
44
;; `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-
;; )
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+
)
3434

3535
[
3636
(if_expression)

0 commit comments

Comments
 (0)