add test textobjects queries for erlang,gleam,go,python,rust
commit9f676dab57e6421dd4c33a7ccf16e12cfb9b62cf
authorMichael Davis <mcarsondavis@gmail.com>
dateSun 19 Jun 2022, 21:36 (4 years ago)
parent67f6c85
runtime/queries/erlang/textobjects.scm+8
@@ -6,3 +6,11 @@
66 (stab_clause body: (_) @function.inside)) @function.around
77
88(comment (comment_content) @comment.inside) @comment.around
9+
10+; EUnit test names.
11+; (CommonTest cases are not recognizable by syntax alone.)
12+((function_clause
13+ name: (atom) @_name
14+ pattern: (arguments (_)? @parameter.inside)
15+ body: (_) @test.inside) @test.around
16+ (#match? @_name "_test$"))
runtime/queries/gleam/textobjects.scm+5
@@ -4,3 +4,8 @@
44
55(anonymous_function
66 body: (function_body) @function.inside) @function.around
7+
8+((function
9+ name: (identifier) @_name
10+ body: (function_body) @test.inside) @test.around
11+ (#match? @_name "_test$"))
runtime/queries/go/textobjects.scm+5
@@ -26,3 +26,8 @@
2626(comment) @comment.inside
2727
2828(comment)+ @comment.around
29+
30+((function_declaration
31+ name: (identifier) @_name
32+ body: (block)? @test.inside) @test.around
33+ (#match? @_name "^Test"))
runtime/queries/python/textobjects.scm+5
@@ -16,3 +16,8 @@
1616(comment) @comment.inside
1717
1818(comment)+ @comment.around
19+
20+((function_definition
21+ name: (identifier) @_name
22+ body: (block)? @test.inside) @test.around
23+ (#match? @_name "^test_"))
runtime/queries/rust/textobjects.scm+14
@@ -77,3 +77,17 @@
7777(line_comment)+ @comment.around
7878
7979(block_comment) @comment.around
80+
81+(; #[test]
82+ (attribute_item
83+ (meta_item
84+ (identifier) @_test_attribute))
85+ ; allow other attributes like #[should_panic] and comments
86+ [
87+ (attribute_item)
88+ (line_comment)
89+ ]*
90+ ; the test function
91+ (function_item
92+ body: (_) @test.inside) @test.around
93+ (#eq? @_test_attribute "test"))