1; Rust mod test
2(
3 (mod_item
4 name: (_) @run
5 (#eq? @run "tests")
6 )
7 (#set! tag rust-mod-test)
8)
9
10; Rust test
11(
12 (
13 (attribute_item (attribute
14 [((identifier) @_attribute)
15 (scoped_identifier (identifier) @_attribute)
16 ])
17 (#match? @_attribute "test")
18 ) @_start
19 .
20 (attribute_item) *
21 .
22 [(line_comment) (block_comment)] *
23 .
24 (function_item
25 name: (_) @run
26 body: _
27 ) @_end
28 )
29 (#set! tag rust-test)
30)
31
32; Rust doc test
33(
34 (
35 (line_comment) *
36 (line_comment
37 doc: (_) @_comment_content
38 ) @start
39 (#match? @_comment_content "```")
40 (line_comment) *
41 (line_comment
42 doc: (_) @_end_comment_content
43 ) @_end_code_block
44 (#match? @_end_comment_content "```")
45 .
46 (attribute_item) *
47 .
48 [(line_comment) (block_comment)] *
49 .
50 [(function_item
51 name: (_) @run
52 body: _
53 ) (function_signature_item
54 name: (_) @run
55 ) (struct_item
56 name: (_) @run
57 ) (enum_item
58 name: (_) @run
59 body: _
60 ) (
61 (attribute_item) ?
62 (macro_definition
63 name: (_) @run)
64 ) (mod_item
65 name: (_) @run
66 )] @_end
67 )
68 (#set! tag rust-doc-test)
69)
70
71; Rust main function
72(
73 (
74 (function_item
75 name: (_) @run
76 body: _
77 ) @_rust_main_function_end
78 (#eq? @run "main")
79 )
80 (#set! tag rust-main)
81)