ast-grep-py 0.39.2__tar.gz → 0.39.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ast-grep-py might be problematic. Click here for more details.

Files changed (97) hide show
  1. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/Cargo.lock +33 -22
  2. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/Cargo.toml +6 -6
  3. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/PKG-INFO +1 -2
  4. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/Cargo.toml +2 -0
  5. ast_grep_py-0.39.3/crates/language/src/hcl.rs +47 -0
  6. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/lib.rs +8 -1
  7. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/parsers.rs +3 -0
  8. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/Cargo.toml +1 -0
  9. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/pyproject.toml +1 -1
  10. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/README.md +0 -0
  11. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/ast_grep_py/__init__.py +0 -0
  12. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/ast_grep_py/ast_grep_py.pyi +0 -0
  13. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/ast_grep_py/py.typed +0 -0
  14. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/Cargo.toml +0 -0
  15. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/check_var.rs +0 -0
  16. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/combined.rs +0 -0
  17. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/fixer.rs +0 -0
  18. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/label.rs +0 -0
  19. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/lib.rs +0 -0
  20. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/maybe.rs +0 -0
  21. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/deserialize_env.rs +0 -0
  22. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/mod.rs +0 -0
  23. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/nth_child.rs +0 -0
  24. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/range.rs +0 -0
  25. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/referent_rule.rs +0 -0
  26. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/relational_rule.rs +0 -0
  27. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/selector.rs +0 -0
  28. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule/stop_by.rs +0 -0
  29. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule_collection.rs +0 -0
  30. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule_config.rs +0 -0
  31. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/rule_core.rs +0 -0
  32. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/transform/mod.rs +0 -0
  33. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/transform/parse.rs +0 -0
  34. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/transform/rewrite.rs +0 -0
  35. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/transform/string_case.rs +0 -0
  36. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/config/src/transform/trans.rs +0 -0
  37. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/Cargo.toml +0 -0
  38. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/language.rs +0 -0
  39. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/lib.rs +0 -0
  40. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/match_tree/match_node.rs +0 -0
  41. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/match_tree/mod.rs +0 -0
  42. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/match_tree/strictness.rs +0 -0
  43. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/matcher/kind.rs +0 -0
  44. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/matcher/node_match.rs +0 -0
  45. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/matcher/pattern.rs +0 -0
  46. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/matcher/text.rs +0 -0
  47. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/matcher.rs +0 -0
  48. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/meta_var.rs +0 -0
  49. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/node.rs +0 -0
  50. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/ops.rs +0 -0
  51. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/pinned.rs +0 -0
  52. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/replacer/indent.rs +0 -0
  53. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/replacer/structural.rs +0 -0
  54. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/replacer/template.rs +0 -0
  55. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/replacer.rs +0 -0
  56. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/source.rs +0 -0
  57. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/tree_sitter/mod.rs +0 -0
  58. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/core/src/tree_sitter/traversal.rs +0 -0
  59. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/dynamic/Cargo.toml +0 -0
  60. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/dynamic/src/custom_lang.rs +0 -0
  61. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/dynamic/src/lib.rs +0 -0
  62. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/bash.rs +0 -0
  63. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/cpp.rs +0 -0
  64. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/csharp.rs +0 -0
  65. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/css.rs +0 -0
  66. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/elixir.rs +0 -0
  67. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/go.rs +0 -0
  68. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/haskell.rs +0 -0
  69. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/html.rs +0 -0
  70. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/json.rs +0 -0
  71. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/kotlin.rs +0 -0
  72. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/lua.rs +0 -0
  73. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/nix.rs +0 -0
  74. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/php.rs +0 -0
  75. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/python.rs +0 -0
  76. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/ruby.rs +0 -0
  77. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/rust.rs +0 -0
  78. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/scala.rs +0 -0
  79. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/solidity.rs +0 -0
  80. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/swift.rs +0 -0
  81. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/language/src/yaml.rs +0 -0
  82. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/README.md +0 -0
  83. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/__init__.py +0 -0
  84. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/ast_grep_py.pyi +0 -0
  85. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/py.typed +0 -0
  86. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/src/lib.rs +0 -0
  87. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/src/py_lang.rs +0 -0
  88. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/src/py_node.rs +0 -0
  89. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/src/range.rs +0 -0
  90. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/src/unicode_position.rs +0 -0
  91. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_fix.py +0 -0
  92. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_range.py +0 -0
  93. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_register_lang.py +0 -0
  94. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_rule.py +0 -0
  95. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_simple.py +0 -0
  96. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_traversal.py +0 -0
  97. {ast_grep_py-0.39.2 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_wrong_usage.py +0 -0
@@ -109,7 +109,7 @@ dependencies = [
109
109
 
110
110
  [[package]]
111
111
  name = "ast-grep"
112
- version = "0.39.2"
112
+ version = "0.39.3"
113
113
  dependencies = [
114
114
  "ansi_term",
115
115
  "anyhow",
@@ -143,7 +143,7 @@ dependencies = [
143
143
 
144
144
  [[package]]
145
145
  name = "ast-grep-config"
146
- version = "0.39.2"
146
+ version = "0.39.3"
147
147
  dependencies = [
148
148
  "ast-grep-core",
149
149
  "bit-set",
@@ -158,7 +158,7 @@ dependencies = [
158
158
 
159
159
  [[package]]
160
160
  name = "ast-grep-core"
161
- version = "0.39.2"
161
+ version = "0.39.3"
162
162
  dependencies = [
163
163
  "bit-set",
164
164
  "regex",
@@ -169,7 +169,7 @@ dependencies = [
169
169
 
170
170
  [[package]]
171
171
  name = "ast-grep-dynamic"
172
- version = "0.39.2"
172
+ version = "0.39.3"
173
173
  dependencies = [
174
174
  "ast-grep-core",
175
175
  "ignore",
@@ -183,7 +183,7 @@ dependencies = [
183
183
 
184
184
  [[package]]
185
185
  name = "ast-grep-language"
186
- version = "0.39.2"
186
+ version = "0.39.3"
187
187
  dependencies = [
188
188
  "ast-grep-core",
189
189
  "ignore",
@@ -197,6 +197,7 @@ dependencies = [
197
197
  "tree-sitter-elixir",
198
198
  "tree-sitter-go",
199
199
  "tree-sitter-haskell",
200
+ "tree-sitter-hcl",
200
201
  "tree-sitter-html",
201
202
  "tree-sitter-java",
202
203
  "tree-sitter-javascript",
@@ -217,7 +218,7 @@ dependencies = [
217
218
 
218
219
  [[package]]
219
220
  name = "ast-grep-lsp"
220
- version = "0.39.2"
221
+ version = "0.39.3"
221
222
  dependencies = [
222
223
  "ast-grep-config",
223
224
  "ast-grep-core",
@@ -231,7 +232,7 @@ dependencies = [
231
232
 
232
233
  [[package]]
233
234
  name = "ast-grep-napi"
234
- version = "0.39.2"
235
+ version = "0.39.3"
235
236
  dependencies = [
236
237
  "ast-grep-config",
237
238
  "ast-grep-core",
@@ -247,7 +248,7 @@ dependencies = [
247
248
 
248
249
  [[package]]
249
250
  name = "ast-grep-py"
250
- version = "0.39.2"
251
+ version = "0.39.3"
251
252
  dependencies = [
252
253
  "anyhow",
253
254
  "ast-grep-config",
@@ -364,9 +365,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
364
365
 
365
366
  [[package]]
366
367
  name = "clap"
367
- version = "4.5.41"
368
+ version = "4.5.42"
368
369
  source = "registry+https://github.com/rust-lang/crates.io-index"
369
- checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9"
370
+ checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882"
370
371
  dependencies = [
371
372
  "clap_builder",
372
373
  "clap_derive",
@@ -374,9 +375,9 @@ dependencies = [
374
375
 
375
376
  [[package]]
376
377
  name = "clap_builder"
377
- version = "4.5.41"
378
+ version = "4.5.42"
378
379
  source = "registry+https://github.com/rust-lang/crates.io-index"
379
- checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d"
380
+ checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966"
380
381
  dependencies = [
381
382
  "anstream",
382
383
  "anstyle",
@@ -1083,9 +1084,9 @@ dependencies = [
1083
1084
 
1084
1085
  [[package]]
1085
1086
  name = "napi"
1086
- version = "3.1.3"
1087
+ version = "3.1.4"
1087
1088
  source = "registry+https://github.com/rust-lang/crates.io-index"
1088
- checksum = "afaf586c21f260e9dc327ae3585fc6efcbb24a416d5151da38bbd35a1f2663c8"
1089
+ checksum = "bb4ea803c02e45ebdc6bb45627279e8bdc4e16662e442080cbbc97a8e54d49f7"
1089
1090
  dependencies = [
1090
1091
  "anyhow",
1091
1092
  "bitflags 2.9.0",
@@ -1106,9 +1107,9 @@ checksum = "dcae8ad5609d14afb3a3b91dee88c757016261b151e9dcecabf1b2a31a6cab14"
1106
1107
 
1107
1108
  [[package]]
1108
1109
  name = "napi-derive"
1109
- version = "3.1.1"
1110
+ version = "3.1.2"
1110
1111
  source = "registry+https://github.com/rust-lang/crates.io-index"
1111
- checksum = "43e61844e0c0bb81e711f2084abe7cff187b03ca21ff8b000cb59bbda61e15a9"
1112
+ checksum = "7e6d190d5e09d449b2b38127cdcdb7aed860599e492a15c73f977d5d87df69a5"
1112
1113
  dependencies = [
1113
1114
  "convert_case 0.8.0",
1114
1115
  "ctor",
@@ -1120,9 +1121,9 @@ dependencies = [
1120
1121
 
1121
1122
  [[package]]
1122
1123
  name = "napi-derive-backend"
1123
- version = "2.0.2"
1124
+ version = "2.0.3"
1124
1125
  source = "registry+https://github.com/rust-lang/crates.io-index"
1125
- checksum = "b7ab19e9b98efb13895f492a2e367ca50c955ac3c4723613af73fdda4011afcc"
1126
+ checksum = "15158ced16693eaa0c709e4c9768ca08eb56325691e68510db8440d27ccd41d1"
1126
1127
  dependencies = [
1127
1128
  "convert_case 0.8.0",
1128
1129
  "proc-macro2",
@@ -1781,9 +1782,9 @@ dependencies = [
1781
1782
 
1782
1783
  [[package]]
1783
1784
  name = "tokio"
1784
- version = "1.47.0"
1785
+ version = "1.47.1"
1785
1786
  source = "registry+https://github.com/rust-lang/crates.io-index"
1786
- checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35"
1787
+ checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
1787
1788
  dependencies = [
1788
1789
  "backtrace",
1789
1790
  "bytes",
@@ -2015,6 +2016,16 @@ dependencies = [
2015
2016
  "tree-sitter-language",
2016
2017
  ]
2017
2018
 
2019
+ [[package]]
2020
+ name = "tree-sitter-hcl"
2021
+ version = "1.1.0"
2022
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2023
+ checksum = "5a7b2cc3d7121553b84309fab9d11b3ff3d420403eef9ae50f9fd1cd9d9cf012"
2024
+ dependencies = [
2025
+ "cc",
2026
+ "tree-sitter-language",
2027
+ ]
2028
+
2018
2029
  [[package]]
2019
2030
  name = "tree-sitter-html"
2020
2031
  version = "0.23.2"
@@ -2143,9 +2154,9 @@ dependencies = [
2143
2154
 
2144
2155
  [[package]]
2145
2156
  name = "tree-sitter-solidity"
2146
- version = "1.2.12"
2157
+ version = "1.2.13"
2147
2158
  source = "registry+https://github.com/rust-lang/crates.io-index"
2148
- checksum = "92f0b44ef36f0779873ec118f2cbad31cfc18d6ae7ba48ce75d5ce09870884d1"
2159
+ checksum = "4eacf8875b70879f0cb670c60b233ad0b68752d9e1474e6c3ef168eea8a90b25"
2149
2160
  dependencies = [
2150
2161
  "cc",
2151
2162
  "tree-sitter-language",
@@ -7,7 +7,7 @@ resolver = "2"
7
7
  lto = true
8
8
 
9
9
  [workspace.package]
10
- version = "0.39.2"
10
+ version = "0.39.3"
11
11
  authors = ["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"]
12
12
  edition = "2021"
13
13
  license = "MIT"
@@ -18,11 +18,11 @@ rust-version = "1.79"
18
18
  readme = "README.md"
19
19
 
20
20
  [workspace.dependencies]
21
- ast-grep-core = { path = "crates/core", version = "0.39.2", default-features = false }
22
- ast-grep-config = { path = "crates/config", version = "0.39.2" }
23
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.39.2" }
24
- ast-grep-language = { path = "crates/language", version = "0.39.2" }
25
- ast-grep-lsp = { path = "crates/lsp", version = "0.39.2" }
21
+ ast-grep-core = { path = "crates/core", version = "0.39.3", default-features = false }
22
+ ast-grep-config = { path = "crates/config", version = "0.39.3" }
23
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.39.3" }
24
+ ast-grep-language = { path = "crates/language", version = "0.39.3" }
25
+ ast-grep-lsp = { path = "crates/lsp", version = "0.39.3" }
26
26
 
27
27
  bit-set = { version = "0.8.0" }
28
28
  ignore = { version = "0.4.22" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ast-grep-py
3
- Version: 0.39.2
3
+ Version: 0.39.3
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -15,7 +15,6 @@ Requires-Dist: pytest>=7 ; extra == 'test'
15
15
  Provides-Extra: test
16
16
  Summary: Structural Search and Rewrite code at large scale using precise AST pattern.
17
17
  Keywords: ast,pattern,codemod,structural search,rewrite
18
- Author: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
19
18
  Author-email: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
20
19
  Maintainer-email: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
21
20
  License: MIT
@@ -41,6 +41,7 @@ tree-sitter-solidity = { version = "1.2.11", optional = true }
41
41
  tree-sitter-swift = { version = "0.7.0", optional = true }
42
42
  tree-sitter-typescript = { version = "0.23.2", optional = true }
43
43
  tree-sitter-yaml = { version = "0.7.0", optional = true }
44
+ tree-sitter-hcl = { version = "1.1.0", optional = true }
44
45
 
45
46
  [features]
46
47
  builtin-parser = [
@@ -52,6 +53,7 @@ builtin-parser = [
52
53
  "tree-sitter-elixir",
53
54
  "tree-sitter-go",
54
55
  "tree-sitter-haskell",
56
+ "tree-sitter-hcl",
55
57
  "tree-sitter-html",
56
58
  "tree-sitter-java",
57
59
  "tree-sitter-javascript",
@@ -0,0 +1,47 @@
1
+ #![cfg(test)]
2
+ use super::*;
3
+ use crate::test::{test_match_lang,test_replace_lang};
4
+
5
+ fn test_match(s1: &str, s2: &str) {
6
+ test_match_lang(s1, s2, Hcl)
7
+ }
8
+
9
+ #[test]
10
+ fn test_hcl_pattern() {
11
+ test_match("$A = $B", "foo = \"bar\"");
12
+ test_match("resource $TYPE $NAME $BODY", "resource \"aws_instance\" \"example\" { ami = \"ami-123\" }");
13
+ test_match("$BLOCK $BODY", "terraform { required_providers { aws = { source = \"hashicorp/aws\" } } }");
14
+ test_match("variable $NAME $CONFIG", "variable \"region\" { default = \"us-west-2\" }");
15
+ test_match("output $NAME $VALUE", "output \"instance_ip\" { value = aws_instance.example.public_ip }");
16
+ test_match("$VAR = [$$$ITEMS]", "tags = [\"production\", \"web\"]");
17
+ test_match("$VAR = { $$$PAIRS }", "labels = { environment = \"prod\", team = \"backend\" }");
18
+ test_match("$VAR = \"$CONTENT\"", "name = \"instance\"");
19
+ }
20
+
21
+ fn test_replace(src: &str, pattern: &str, replacer: &str) -> String {
22
+ test_replace_lang(src, pattern, replacer, Hcl)
23
+ }
24
+
25
+ #[test]
26
+ fn test_hcl_replace() {
27
+ let ret = test_replace(
28
+ "foo = \"bar\"",
29
+ "$A = $B",
30
+ "$B = $A"
31
+ );
32
+ assert_eq!(ret, "\"bar\" = foo");
33
+
34
+ let ret = test_replace(
35
+ "resource \"aws_instance\" \"example\" { ami = \"ami-123\" }",
36
+ "resource $TYPE $NAME $BODY",
37
+ "resource $NAME $TYPE $BODY",
38
+ );
39
+ assert_eq!(ret, "resource \"example\" \"aws_instance\" { ami = \"ami-123\" }");
40
+
41
+ let ret = test_replace(
42
+ "variable \"region\" { default = \"us-west-2\" }",
43
+ "variable \"region\" { default = $DEFAULT }",
44
+ "variable \"region\" { default = \"eu-west-1\" }",
45
+ );
46
+ assert_eq!(ret, "variable \"region\" { default = \"eu-west-1\" }");
47
+ }
@@ -14,6 +14,7 @@ mod css;
14
14
  mod elixir;
15
15
  mod go;
16
16
  mod haskell;
17
+ mod hcl;
17
18
  mod html;
18
19
  mod json;
19
20
  mod kotlin;
@@ -205,6 +206,8 @@ impl_lang_expando!(Go, language_go, 'µ');
205
206
  // https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/unicode_syntax.html
206
207
  // and the tree-sitter-haskell grammar parses it too.
207
208
  impl_lang_expando!(Haskell, language_haskell, 'µ');
209
+ // https://developer.hashicorp.com/terraform/language/syntax/configuration#identifiers
210
+ impl_lang_expando!(Hcl, language_hcl, 'µ');
208
211
  // https://github.com/fwcd/tree-sitter-kotlin/pull/93
209
212
  impl_lang_expando!(Kotlin, language_kotlin, 'µ');
210
213
  // Nix uses $ for string interpolation (e.g., "${pkgs.hello}")
@@ -249,6 +252,7 @@ pub enum SupportLang {
249
252
  Go,
250
253
  Elixir,
251
254
  Haskell,
255
+ Hcl,
252
256
  Html,
253
257
  Java,
254
258
  JavaScript,
@@ -272,7 +276,7 @@ impl SupportLang {
272
276
  pub const fn all_langs() -> &'static [SupportLang] {
273
277
  use SupportLang::*;
274
278
  &[
275
- Bash, C, Cpp, CSharp, Css, Elixir, Go, Haskell, Html, Java, JavaScript, Json, Kotlin, Lua,
279
+ Bash, C, Cpp, CSharp, Css, Elixir, Go, Haskell, Hcl, Html, Java, JavaScript, Json, Kotlin, Lua,
276
280
  Nix, Php, Python, Ruby, Rust, Scala, Solidity, Swift, Tsx, TypeScript, Yaml,
277
281
  ]
278
282
  }
@@ -362,6 +366,7 @@ impl_aliases! {
362
366
  Elixir => &["ex", "elixir"],
363
367
  Go => &["go", "golang"],
364
368
  Haskell => &["hs", "haskell"],
369
+ Hcl => &["hcl"],
365
370
  Html => &["html"],
366
371
  Java => &["java"],
367
372
  JavaScript => &["javascript", "js", "jsx"],
@@ -408,6 +413,7 @@ macro_rules! execute_lang_method {
408
413
  S::Elixir => Elixir.$method($($pname,)*),
409
414
  S::Go => Go.$method($($pname,)*),
410
415
  S::Haskell => Haskell.$method($($pname,)*),
416
+ S::Hcl => Hcl.$method($($pname,)*),
411
417
  S::Html => Html.$method($($pname,)*),
412
418
  S::Java => Java.$method($($pname,)*),
413
419
  S::JavaScript => JavaScript.$method($($pname,)*),
@@ -479,6 +485,7 @@ fn extensions(lang: SupportLang) -> &'static [&'static str] {
479
485
  Elixir => &["ex", "exs"],
480
486
  Go => &["go"],
481
487
  Haskell => &["hs"],
488
+ Hcl => &["hcl"],
482
489
  Html => &["html", "htm", "xhtml"],
483
490
  Java => &["java"],
484
491
  JavaScript => &["cjs", "js", "mjs", "jsx"],
@@ -67,6 +67,9 @@ pub fn language_go() -> TSLanguage {
67
67
  pub fn language_haskell() -> TSLanguage {
68
68
  into_lang!(tree_sitter_haskell)
69
69
  }
70
+ pub fn language_hcl() -> TSLanguage {
71
+ into_lang!(tree_sitter_hcl)
72
+ }
70
73
  pub fn language_html() -> TSLanguage {
71
74
  into_napi_lang!(tree_sitter_html::LANGUAGE)
72
75
  }
@@ -10,6 +10,7 @@ rust-version.workspace = true
10
10
  version.workspace = true
11
11
  edition.workspace = true
12
12
  publish = false
13
+ readme = "README.md"
13
14
 
14
15
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15
16
  [lib]
@@ -5,7 +5,7 @@ build-backend = "maturin"
5
5
  [project]
6
6
  name = "ast-grep-py"
7
7
  requires-python = ">=3.8"
8
- version = "0.39.2"
8
+ version = "0.39.3"
9
9
  description = "Structural Search and Rewrite code at large scale using precise AST pattern."
10
10
  authors = [{ name = "Herrington Darkholme", email = "2883231+HerringtonDarkholme@users.noreply.github.com" }]
11
11
  maintainers = [{ name = "Herrington Darkholme", email = "2883231+HerringtonDarkholme@users.noreply.github.com" }]
File without changes