From 3d39dc4885ed7c30b2ce28f9b49794fb87a39890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Ota=CC=81vio=20Biondo?= Date: Thu, 30 May 2024 21:38:14 -0300 Subject: [PATCH 1/2] Add runnable tasks to elixir --- .../elixir/languages/elixir/runnables.scm | 20 +++++++++++++++++++ extensions/elixir/languages/elixir/tasks.json | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 extensions/elixir/languages/elixir/runnables.scm diff --git a/extensions/elixir/languages/elixir/runnables.scm b/extensions/elixir/languages/elixir/runnables.scm new file mode 100644 index 0000000000000..55d8da3e1b09d --- /dev/null +++ b/extensions/elixir/languages/elixir/runnables.scm @@ -0,0 +1,20 @@ +; Macros `describe` and `test`. +; This matches the ExUnit test style. +( + (call + target: (identifier) @run (#any-of? @run "describe" "test") + ) @elixir-test + (#set! tag elixir-test) +) + +; Modules containing at least one `describe` or `test`. +; This matches the ExUnit test style. +( + (call + target: (identifier) @run (#eq? @run "defmodule") + (do_block + (call target: (identifier) @keyword (#any-of? @keyword "describe" "test")) + ) + ) @elixir-module-test + (#set! tag elixir-module-test) +) diff --git a/extensions/elixir/languages/elixir/tasks.json b/extensions/elixir/languages/elixir/tasks.json index e1db25cd373f8..d5026f00348cb 100644 --- a/extensions/elixir/languages/elixir/tasks.json +++ b/extensions/elixir/languages/elixir/tasks.json @@ -13,12 +13,14 @@ { "label": "mix test $ZED_RELATIVE_FILE", "command": "mix", - "args": ["test", "$ZED_RELATIVE_FILE"] + "args": ["test", "$ZED_RELATIVE_FILE"], + "tags": ["elixir-module-test"] }, { "label": "mix test $ZED_RELATIVE_FILE:$ZED_ROW", "command": "mix", - "args": ["test", "$ZED_RELATIVE_FILE:$ZED_ROW"] + "args": ["test", "$ZED_RELATIVE_FILE:$ZED_ROW"], + "tags": ["elixir-test"] }, { "label": "Elixir: break line", From 3e0f0900348304925ba41c6c02afa6e46f5fc956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Ota=CC=81vio=20Biondo?= Date: Fri, 31 May 2024 11:03:13 -0300 Subject: [PATCH 2/2] Rename captures to start with underscore --- extensions/elixir/languages/elixir/runnables.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/elixir/languages/elixir/runnables.scm b/extensions/elixir/languages/elixir/runnables.scm index 55d8da3e1b09d..13dc860586192 100644 --- a/extensions/elixir/languages/elixir/runnables.scm +++ b/extensions/elixir/languages/elixir/runnables.scm @@ -3,7 +3,7 @@ ( (call target: (identifier) @run (#any-of? @run "describe" "test") - ) @elixir-test + ) @_elixir-test (#set! tag elixir-test) ) @@ -13,8 +13,8 @@ (call target: (identifier) @run (#eq? @run "defmodule") (do_block - (call target: (identifier) @keyword (#any-of? @keyword "describe" "test")) + (call target: (identifier) @_keyword (#any-of? @_keyword "describe" "test")) ) - ) @elixir-module-test + ) @_elixir-module-test (#set! tag elixir-module-test) )