add ... alias for :[_]

This commit is contained in:
Rijnard van Tonder 2020-08-25 22:25:39 -07:00
parent 9613622b85
commit 29c3be4984
2 changed files with 17 additions and 0 deletions

View File

@ -705,6 +705,11 @@ let create
parse_templates ~warn_for_missing_file_in_dir:true omega templates
| _ -> assert false
in
let specifications =
List.map specifications ~f:(fun ({ match_template; _ } as spec) ->
{ spec with match_template =
String.substr_replace_all match_template ~pattern:"..." ~with_:":[_]" })
in
let file_filters =
match anonymous_arguments with
| None -> file_filters

View File

@ -1109,6 +1109,18 @@ let%expect_test "warn_on_match_template_starts_with_everything_hole" =
world
WARNING: The match template starts with a :[hole]. You almost never want to start a template with :[hole], since it matches everything including newlines up to the part that comes after it. This can make things slow. :[[hole]] might be what you're looking for instead, like when you want to match an assignment foo = bar(args) on a line, use :[[var]] = bar(args). :[hole] is typically useful inside balanced delimiters. |}]
let%expect_test "test_ellipses" =
let source = "foo(bar)" in
let match_ = "...(...)" in
let rewrite = "delete" in
let command_args =
Format.sprintf "-stdin -sequential -stdout '%s' '%s' -f .c" match_ rewrite
in
let command = Format.sprintf "%s %s" binary_path command_args in
let result = read_expect_stdin_and_stdout command source in
print_string result;
[%expect{|delete|}]
let%expect_test "test_valid_toml" =
let source = "main(void)\n" in
let config = "example" ^/ "toml" ^/ "plain" ^/ "config.toml" in