Files
oak-gpui/crates/languages/src/rust/runnables.scm
T
Coenen Benjamin dff47a8436 rust: Add support for doctest runnables (#24806)
Screenshot:


![image](https://github.com/user-attachments/assets/0ac88029-76c1-4135-bef2-373636e3587d)

I would be happy to add tests if you point me to the right place to do
it please.

Release Notes:

- Added support for doc test in tasks for Rust

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
2025-02-21 10:57:09 +01:00

82 lines
1.6 KiB
Scheme

; Rust mod test
(
(mod_item
name: (_) @run
(#eq? @run "tests")
)
(#set! tag rust-mod-test)
)
; Rust test
(
(
(attribute_item (attribute
[((identifier) @_attribute)
(scoped_identifier (identifier) @_attribute)
])
(#match? @_attribute "test")
) @_start
.
(attribute_item) *
.
[(line_comment) (block_comment)] *
.
(function_item
name: (_) @run
body: _
) @_end
)
(#set! tag rust-test)
)
; Rust doc test
(
(
(line_comment) *
(line_comment
doc: (_) @_comment_content
) @start
(#match? @_comment_content "```")
(line_comment) *
(line_comment
doc: (_) @_end_comment_content
) @_end_code_block
(#match? @_end_comment_content "```")
.
(attribute_item) *
.
[(line_comment) (block_comment)] *
.
[(function_item
name: (_) @run
body: _
) (function_signature_item
name: (_) @run
) (struct_item
name: (_) @run
) (enum_item
name: (_) @run
body: _
) (
(attribute_item) ?
(macro_definition
name: (_) @run)
) (mod_item
name: (_) @run
)] @_end
)
(#set! tag rust-doc-test)
)
; Rust main function
(
(
(function_item
name: (_) @run
body: _
) @_rust_main_function_end
(#eq? @run "main")
)
(#set! tag rust-main)
)