Skip to content

Commit 56c33f7

Browse files
Migrate condition
1 parent 979a7cc commit 56c33f7

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
patternMatcher,
1515
} from "../util/nodeMatchers";
1616
import {
17-
childRangeSelector,
1817
makeNodePairSelection,
1918
makeRangeFromPositions,
2019
} from "../util/nodeSelectors";
@@ -53,16 +52,6 @@ function traitBoundExtractor(
5352
const nodeMatchers: Partial<
5453
Record<SimpleScopeTypeType, NodeMatcherAlternative>
5554
> = {
56-
condition: cascadingMatcher(
57-
patternMatcher("while_expression[condition]", "if_expression[condition]"),
58-
matcher(
59-
patternFinder("while_let_expression", "if_let_expression"),
60-
childRangeSelector(["while", "if", "block"], [], {
61-
includeUnnamedChildren: true,
62-
}),
63-
),
64-
leadingMatcher(["*.match_pattern![condition]"], ["if"]),
65-
),
6655
type: cascadingMatcher(
6756
leadingMatcher(
6857
[

queries/rust.scm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,42 @@
225225
)
226226
)
227227

228+
;;!! if v < 0 {}
229+
;;! ^^^^^
230+
(if_expression
231+
condition: (_) @condition
232+
) @_.domain
233+
234+
;;!! if let Some(i) = number {}
235+
;;! ^^^^^^^^^^^^^^^^
236+
(if_let_expression
237+
"let" @condition.start
238+
value: (_) @condition.end
239+
) @_.domain
240+
241+
;;!! while v < 0 {}
242+
;;! ^^^^^
243+
(while_expression
244+
condition: (_) @condition
245+
) @_.domain
246+
247+
;;!! while let Some(i) = number {}
248+
;;! ^^^^^^^^^^^^^^^^^^^^
249+
(while_let_expression
250+
"let" @condition.start
251+
value: (_) @condition.end
252+
) @_.domain
253+
254+
;;!! User { value } if value.use() => {}
255+
;;! ^^^^^^^^^^^
256+
(_
257+
(match_pattern
258+
(_) @_.leading.endOf
259+
.
260+
condition: (_) @condition
261+
)
262+
) @_.domain
263+
228264
operator: [
229265
"<"
230266
"<<"

0 commit comments

Comments
 (0)