File tree Expand file tree Collapse file tree 3 files changed +51
-27
lines changed
packages/cursorless-engine/src/languages Expand file tree Collapse file tree 3 files changed +51
-27
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import {
1717 makeNodePairSelection ,
1818 makeRangeFromPositions ,
1919} from "../util/nodeSelectors" ;
20- import { elseExtractor , elseIfExtractor } from "./elseIfExtractor" ;
2120
2221/**
2322 * Returns "impl_item[type]" node higher in the chain
@@ -85,11 +84,6 @@ const nodeMatchers: Partial<
8584 "type_parameters" ,
8685 "ordered_field_declaration_list" ,
8786 ) ,
88- branch : cascadingMatcher (
89- patternMatcher ( "match_arm" ) ,
90- matcher ( patternFinder ( "else_clause" ) , elseExtractor ( "if_expression" ) ) ,
91- matcher ( patternFinder ( "if_expression" ) , elseIfExtractor ( ) ) ,
92- ) ,
9387} ;
9488
9589export default createPatternMatchers ( nodeMatchers ) ;
Original file line number Diff line number Diff line change 194194 (if_statement
195195 "if" @branch.start @branch.removal.start
196196 condition: (_) @condition
197- consequence: (block ) @branch.end @branch.removal.end
198- alternative: (if_statement )? @branch.removal.end.startOf
197+ consequence: (_ ) @branch.end @branch.removal.end
198+ alternative: (_ )? @branch.removal.end.startOf
199199 ) @condition.domain
200200 (#not-parent-type? @condition.domain "if_statement")
201201 (#child-range! @condition 0 -1 true true)
207207 "else" @branch.start @condition.domain.start
208208 alternative: (if_statement
209209 condition: (_) @condition
210- consequence: (block ) @branch.end @condition.domain.end
210+ consequence: (_ ) @branch.end @condition.domain.end
211211 (#child-range! @condition 0 -1 true true)
212212 )
213213)
216216;; ! ^^^^^^^
217217(if_statement
218218 "else" @branch.start
219- alternative: (block ) @branch.end
219+ alternative: (_ ) @branch.end
220220)
221221
222222(
Original file line number Diff line number Diff line change 3232 (#type? @_dummy source_file block declaration_list)
3333)
3434
35- [
36- (if_expression)
37- (if_let_expression)
38- ] @ifStatement
35+ ;; !! if v < 0 {}
36+ ;; ! ^^^^^^^^^^^
37+ (if_expression) @ifStatement
38+
39+ ;; !! if let Some(i) = number {}
40+ ;; ! ^^^^^^^^^^^^^^^^^^^^^^^^^^
41+ ;; ! ^^^^^^^^^^^^^^^^
42+ (if_let_expression
43+ "let" @condition.start
44+ value: (_) @condition.end
45+ ) @ifStatement @_.domain
46+
47+ ;; !! if true {}
48+ ;; ! ^^^^^^^^^^
49+ (_
50+ (if_expression
51+ "if" @branch.start @branch.removal.start
52+ condition: (_) @condition
53+ consequence: (_) @branch.end @branch.removal.end
54+ alternative: (else_clause
55+ (if_expression) @branch.removal.end.startOf
56+ )?
57+ ) @condition.domain
58+ (#not-parent-type? @condition.domain else_clause)
59+ )
60+
61+ ;; !! else if true {}
62+ ;; ! ^^^^^^^^^^^^^^^
63+ (else_clause
64+ "else" @branch.start @condition.domain.start
65+ (if_expression
66+ condition: (_) @condition
67+ consequence: (_) @branch.end @condition.domain.end
68+ )
69+ )
70+
71+ ;; !! else {}
72+ ;; ! ^^^^^^^
73+ (
74+ (else_clause
75+ (block)
76+ ) @branch
77+ )
3978
4079;; !! "hello"
4180(
225264 )
226265)
227266
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-
241267;; !! while v < 0 {}
242268;; ! ^^^^^
243269(while_expression
261287 )
262288) @_.domain
263289
290+ ;; !! match value { 5 => {} }
291+ ;; ! ^^^^^^^
292+ (match_arm) @branch
293+
264294operator: [
265295 "<"
266296 "<<"
You can’t perform that action at this time.
0 commit comments