diff --git a/runtime/queries/erlang/textobjects.scm b/runtime/queries/erlang/textobjects.scm index c46b5c6f6..013629f88 100644 --- a/runtime/queries/erlang/textobjects.scm +++ b/runtime/queries/erlang/textobjects.scm @@ -6,3 +6,11 @@ (stab_clause body: (_) @function.inside)) @function.around (comment (comment_content) @comment.inside) @comment.around + +; EUnit test names. +; (CommonTest cases are not recognizable by syntax alone.) +((function_clause + name: (atom) @_name + pattern: (arguments (_)? @parameter.inside) + body: (_) @test.inside) @test.around + (#match? @_name "_test$")) diff --git a/runtime/queries/gleam/textobjects.scm b/runtime/queries/gleam/textobjects.scm index b382f4bd0..19cd0dcf9 100644 --- a/runtime/queries/gleam/textobjects.scm +++ b/runtime/queries/gleam/textobjects.scm @@ -4,3 +4,8 @@ (anonymous_function body: (function_body) @function.inside) @function.around + +((function + name: (identifier) @_name + body: (function_body) @test.inside) @test.around + (#match? @_name "_test$")) diff --git a/runtime/queries/go/textobjects.scm b/runtime/queries/go/textobjects.scm index a48ccce18..df1b0866f 100644 --- a/runtime/queries/go/textobjects.scm +++ b/runtime/queries/go/textobjects.scm @@ -26,3 +26,8 @@ (comment) @comment.inside (comment)+ @comment.around + +((function_declaration + name: (identifier) @_name + body: (block)? @test.inside) @test.around + (#match? @_name "^Test")) diff --git a/runtime/queries/python/textobjects.scm b/runtime/queries/python/textobjects.scm index 5c6a61d17..966e47446 100644 --- a/runtime/queries/python/textobjects.scm +++ b/runtime/queries/python/textobjects.scm @@ -16,3 +16,8 @@ (comment) @comment.inside (comment)+ @comment.around + +((function_definition + name: (identifier) @_name + body: (block)? @test.inside) @test.around + (#match? @_name "^test_")) diff --git a/runtime/queries/rust/textobjects.scm b/runtime/queries/rust/textobjects.scm index ba86050b5..94c8c9f8b 100644 --- a/runtime/queries/rust/textobjects.scm +++ b/runtime/queries/rust/textobjects.scm @@ -77,3 +77,17 @@ (line_comment)+ @comment.around (block_comment) @comment.around + +(; #[test] + (attribute_item + (meta_item + (identifier) @_test_attribute)) + ; allow other attributes like #[should_panic] and comments + [ + (attribute_item) + (line_comment) + ]* + ; the test function + (function_item + body: (_) @test.inside) @test.around + (#eq? @_test_attribute "test"))