From 4ed87d06c64a65007dc866f7c3f9de2c52607199 Mon Sep 17 00:00:00 2001 From: Roman Cinis <52065414+tsinis@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:23:38 +0100 Subject: [PATCH 1/3] feat(tasks): add dart run task to tasks.json Added a new task for running Dart applications with the label "dart run $ZED_STEM". --- languages/dart/tasks.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/languages/dart/tasks.json b/languages/dart/tasks.json index 9f954e5..3244a8d 100644 --- a/languages/dart/tasks.json +++ b/languages/dart/tasks.json @@ -1,4 +1,10 @@ [ + { + "label": "dart run $ZED_STEM", + "command": "dart", + "args": ["run", "$ZED_FILE"], + "tags": ["dart-main"] + }, { "label": "flutter run", "command": "flutter", From f61e3bce3330d6e6ec846ad4446451da8ba4b1e3 Mon Sep 17 00:00:00 2001 From: Roman Cinis <52065414+tsinis@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:24:22 +0100 Subject: [PATCH 2/3] feat: add fallback for standalone dart files in runnables.scm This change introduces a fallback pattern for standalone Dart files, ensuring that more specific patterns for Flutter and test files take priority. --- languages/dart/runnables.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/languages/dart/runnables.scm b/languages/dart/runnables.scm index 363c5c6..41d0685 100644 --- a/languages/dart/runnables.scm +++ b/languages/dart/runnables.scm @@ -1,3 +1,11 @@ +; Dart main — fallback for standalone Dart files. +; Must be first so that more specific patterns below (Flutter, test) +; take priority via Zed's "last target wins" behavior on the same row. +((function_signature + name: (_) @run) + (#eq? @run "main") + (#set! tag dart-main)) + ; Flutter main ((import_or_export (library_import From 3d6793699397842d1988b0363c5205581a27d7e6 Mon Sep 17 00:00:00 2001 From: Roman Cinis <52065414+tsinis@users.noreply.github.com> Date: Sat, 21 Mar 2026 10:29:14 +0100 Subject: [PATCH 3/3] feat: enhance dart and flutter test tasks for group and single tests Added new tasks for running flutter tests with specific line numbers for group and single tests, improving the testing workflow for developers. --- languages/dart/runnables.scm | 218 ++++++++++++++++++++++++++++------- languages/dart/tasks.json | 24 ++++ 2 files changed, 201 insertions(+), 41 deletions(-) diff --git a/languages/dart/runnables.scm b/languages/dart/runnables.scm index 41d0685..a3a2c19 100644 --- a/languages/dart/runnables.scm +++ b/languages/dart/runnables.scm @@ -1,64 +1,178 @@ -; Dart main — fallback for standalone Dart files. -; Must be first so that more specific patterns below (Flutter, test) -; take priority via Zed's "last target wins" behavior on the same row. -((function_signature - name: (_) @run) - (#eq? @run "main") +; Dart main — matches dart: SDK imports. +; Since `dart format` places dart: imports first, the @_import capture +; position will be earlier than flutter/test imports, so specific patterns +; (flutter-main, flutter-test-main, etc.) overwrite this when they match. +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "^\"dart:")))))) + (function_signature + name: (_) @run + (#eq? @run "main")) + (#set! tag dart-main)) + +; Dart main for parse errors (ERROR root). +(ERROR + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "^\"dart:")))))) + (function_signature + name: (_) @run + (#eq? @run "main")) (#set! tag dart-main)) ; Flutter main -((import_or_export - (library_import - (import_specification - ("import" +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:flutter/(material|widgets|cupertino).dart")))))) + (function_signature + name: (_) @run + (#eq? @run "main")) + (#set! tag flutter-main)) + +; Flutter main (parse error fallback) +(ERROR + (import_or_export + (library_import + (import_specification (configurable_uri (uri (string_literal) @_import - (#match? @_import "package:flutter/(material|widgets|cupertino).dart") - (#not-match? @_import "package:flutter_test/flutter_test.dart") - (#not-match? @_import "package:test/test.dart"))))))) - ((function_signature - name: (_) @run) + (#match? @_import "package:flutter/(material|widgets|cupertino).dart")))))) + (function_signature + name: (_) @run (#eq? @run "main")) (#set! tag flutter-main)) ; Flutter test main -((import_or_export - (library_import - (import_specification - ("import" +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:flutter_test/flutter_test.dart")))))) + (function_signature + name: (_) @run + (#eq? @run "main")) + (#set! tag flutter-test-main)) + +; Flutter test main (parse error fallback) +(ERROR + (import_or_export + (library_import + (import_specification (configurable_uri (uri (string_literal) @_import - (#match? @_import "package:flutter_test/flutter_test.dart"))))))) - ((function_signature - name: (_) @run) + (#match? @_import "package:flutter_test/flutter_test.dart")))))) + (function_signature + name: (_) @run (#eq? @run "main")) (#set! tag flutter-test-main)) +; Flutter test group (block body: void main() { group(...) }) +; Arrow-body variant removed: when main() => group(...), both identifiers +; share the same line, causing group to overwrite the more useful test-main tag. +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:flutter_test/flutter_test.dart")))))) + (function_body + (block + (expression_statement + ((identifier) @run + (#eq? @run "group"))))) + (#set! tag flutter-test-group)) + +; Flutter test single (block body) +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:flutter_test/flutter_test.dart")))))) + (function_body + (block + (expression_statement + (selector + (argument_part + (arguments + (argument + (function_expression + (function_expression_body + (block + (expression_statement + ((identifier) @run + (#eq? @run "test"))))))))))))) + (#set! tag flutter-test-single)) + +; Flutter test single (arrow body: void main() => group("name", () { test(...) })) +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:flutter_test/flutter_test.dart")))))) + (function_body + (selector + (argument_part + (arguments + (argument + (function_expression + (function_expression_body + (block + (expression_statement + ((identifier) @run + (#eq? @run "test"))))))))))) + (#set! tag flutter-test-single)) + ; Dart test file -((import_or_export - (library_import - (import_specification - ("import" +(program + (import_or_export + (library_import + (import_specification (configurable_uri (uri (string_literal) @_import - (#match? @_import "package:test/test.dart"))))))) - ((function_signature - name: (_) @run) + (#match? @_import "package:test/test.dart")))))) + (function_signature + name: (_) @run (#eq? @run "main")) (#set! tag dart-test-file)) -; Dart test group -((import_or_export - (library_import - (import_specification - ("import" +; Dart test group (block body: void main() { group(...) }) +; Arrow-body variant removed: same reason as flutter-test-group. +(program + (import_or_export + (library_import + (import_specification (configurable_uri (uri (string_literal) @_import - (#match? @_import "package:test/test.dart"))))))) + (#match? @_import "package:test/test.dart")))))) (function_body (block (expression_statement @@ -66,15 +180,15 @@ (#eq? @run "group"))))) (#set! tag dart-test-group)) -; Dart test single -((import_or_export - (library_import - (import_specification - ("import" +; Dart test single (block body) +(program + (import_or_export + (library_import + (import_specification (configurable_uri (uri (string_literal) @_import - (#match? @_import "package:test/test.dart"))))))) + (#match? @_import "package:test/test.dart")))))) (function_body (block (expression_statement @@ -89,3 +203,25 @@ ((identifier) @run (#eq? @run "test"))))))))))))) (#set! tag dart-test-single)) + +; Dart test single (arrow body) +(program + (import_or_export + (library_import + (import_specification + (configurable_uri + (uri + (string_literal) @_import + (#match? @_import "package:test/test.dart")))))) + (function_body + (selector + (argument_part + (arguments + (argument + (function_expression + (function_expression_body + (block + (expression_statement + ((identifier) @run + (#eq? @run "test"))))))))))) + (#set! tag dart-test-single)) diff --git a/languages/dart/tasks.json b/languages/dart/tasks.json index 3244a8d..c43194f 100644 --- a/languages/dart/tasks.json +++ b/languages/dart/tasks.json @@ -29,6 +29,30 @@ "args": ["test", "$ZED_FILE"], "tags": ["flutter-test-main"] }, + { + "label": "flutter test group $ZED_STEM", + "command": "flutter", + "args": ["test", "\"$ZED_FILE?line=$ZED_ROW\""], + "tags": ["flutter-test-group"] + }, + { + "label": "fvm flutter test group $ZED_STEM", + "command": "fvm flutter", + "args": ["test", "\"$ZED_FILE?line=$ZED_ROW\""], + "tags": ["flutter-test-group"] + }, + { + "label": "flutter test single $ZED_STEM", + "command": "flutter", + "args": ["test", "\"$ZED_FILE?line=$ZED_ROW\""], + "tags": ["flutter-test-single"] + }, + { + "label": "fvm flutter test single $ZED_STEM", + "command": "fvm flutter", + "args": ["test", "\"$ZED_FILE?line=$ZED_ROW\""], + "tags": ["flutter-test-single"] + }, { "label": "dart test file $ZED_STEM", "command": "dart",