I was missing the `go generate` runnable from other editors so I figured I'd implement one here! Now, comments of the form `//go:generate` can prompt for the `go generate <package>` task. Meanwhile, I've also added a global `go generate ./...` task. ~When making the global task, I noticed that the existing `go test ./...` task runs tests in subdirectories of the CWD of the active editor, whereas I would really expect it to run all tests across my project. I have changed to use the latter behavior (run relative to project root) for both `go generate ./...` and `go test ./...`. Please let me know if the prior behavior was intended, and I can revert.~ Release Notes: - Added runnable and tasks for `go generate` commands
70 lines
1.3 KiB
Scheme
70 lines
1.3 KiB
Scheme
; Functions names start with `Test`
|
|
(
|
|
(
|
|
(function_declaration name: (_) @run
|
|
(#match? @run "^Test.*"))
|
|
) @_
|
|
(#set! tag go-test)
|
|
)
|
|
|
|
; `go:generate` comments
|
|
(
|
|
((comment) @_comment @run
|
|
(#match? @_comment "^//go:generate"))
|
|
(#set! tag go-generate)
|
|
)
|
|
|
|
; `t.Run`
|
|
(
|
|
(
|
|
(call_expression
|
|
function: (
|
|
selector_expression
|
|
field: _ @run @_name
|
|
(#eq? @_name "Run")
|
|
)
|
|
arguments: (
|
|
argument_list
|
|
.
|
|
(interpreted_string_literal) @_subtest_name
|
|
.
|
|
(func_literal
|
|
parameters: (
|
|
parameter_list
|
|
(parameter_declaration
|
|
name: (identifier) @_param_name
|
|
type: (pointer_type
|
|
(qualified_type
|
|
package: (package_identifier) @_pkg
|
|
name: (type_identifier) @_type
|
|
(#eq? @_pkg "testing")
|
|
(#eq? @_type "T")
|
|
)
|
|
)
|
|
)
|
|
)
|
|
) @_second_argument
|
|
)
|
|
)
|
|
) @_
|
|
(#set! tag go-subtest)
|
|
)
|
|
|
|
; Functions names start with `Benchmark`
|
|
(
|
|
(
|
|
(function_declaration name: (_) @run @_name
|
|
(#match? @_name "^Benchmark.+"))
|
|
) @_
|
|
(#set! tag go-benchmark)
|
|
)
|
|
|
|
; go run
|
|
(
|
|
(
|
|
(function_declaration name: (_) @run
|
|
(#eq? @run "main"))
|
|
) @_
|
|
(#set! tag go-main)
|
|
)
|