Skip to content

1.6.0

Compare
Choose a tag to compare
@rvantonder rvantonder released this 21 May 10:10
· 69 commits to master since this release

Utility properties for holes. The following are introduced and recognized in rules and rewrite templates, and are substituted:

  • Length. Substitute the length of a hole in rules and rewrite templates
:[hole].length
  • String conversions. The following are recognized pattern that will substitute the value of :[hole] with the respective string processing in rewrite templates and rules
:[hole].lowercase
:[hole].UPPERCASE
:[hole].Capitalize
:[hole].uncapitalize
:[hole].UpperCamelCase
:[hole].lowerCamelCase
:[hole].UPPER_SNAKE_CASE
:[hole].lower_snake_case
  • Filepaths. Substitute the file name, file path, or directory
:[hole].file.path
:[hole].file.name
:[hole].file.directory

  • Simpler rule syntax modifications. Less strict parsing and more convenient/readable possibilities for rule syntax.
Expand for full list of changes
  • trailing commas for rule expressions are OK:
where :[x] == :[y],
where match :[x] {
|  :[y] -> :[z],
},
  • optional first | for pattern matching:
where match :[x] { :[y] -> :[z] }
  • convenience interpretations for _:
where match :[x] { _ -> :[z] }

implies

where match :[x] { :[_] -> :[z] }
  • convenience interpretation for regex ~:
where match :[x] { ~match-regex -> :[z] }

implies

where match :[x] { :[~match-regex] -> :[z] }
  • Single, double escapable quotes in match and rewrite cases (interprets \t, \n, \r, \\ escape sequences):
where match :[x] { '"yep"\n' -> :[z] }
  • Raw string quotes (no interpreting escape sequences)
where match :[x] { `"yep"\n` -> :[z] }
  • Heuristic parsing for patterns in match cases that require neither quotes nor recognized variable:
where match :[x] { foo(:[x]) -> :[x] }
where rewrite :[x] { foo(:[x]) -> :[x] }

Behavior looks for the first ->, so -> must be escaped if this should be matched literally. Trailing and leading spaces in pattern matches are ignored--use quotes for significant leading and trailing spaces


  • Added .hcl language definition

  • The experimental optional hole syntax is removed. Use regular expressions holes with optional modifiers ? instead.