ast-grep-py 0.39.1__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.
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/Cargo.lock +75 -43
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/Cargo.toml +7 -7
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/PKG-INFO +1 -2
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/maybe.rs +7 -3
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/relational_rule.rs +3 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/stop_by.rs +24 -3
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule_config.rs +9 -14
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/match_tree/match_node.rs +9 -4
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/match_tree/strictness.rs +44 -5
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/Cargo.toml +2 -0
- ast_grep_py-0.39.3/crates/language/src/hcl.rs +47 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/lib.rs +8 -1
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/parsers.rs +3 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/Cargo.toml +1 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/pyproject.toml +1 -1
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/README.md +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/ast_grep_py/__init__.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/ast_grep_py/ast_grep_py.pyi +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/ast_grep_py/py.typed +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/Cargo.toml +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/check_var.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/combined.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/fixer.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/label.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/lib.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/deserialize_env.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/mod.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/nth_child.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/range.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/referent_rule.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule/selector.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule_collection.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/rule_core.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/transform/mod.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/transform/parse.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/transform/rewrite.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/transform/string_case.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/config/src/transform/trans.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/Cargo.toml +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/language.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/lib.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/match_tree/mod.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/matcher/kind.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/matcher/node_match.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/matcher/pattern.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/matcher/text.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/matcher.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/meta_var.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/node.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/ops.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/pinned.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/replacer/indent.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/replacer/structural.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/replacer/template.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/replacer.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/source.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/tree_sitter/mod.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/core/src/tree_sitter/traversal.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/dynamic/Cargo.toml +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/dynamic/src/custom_lang.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/dynamic/src/lib.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/bash.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/cpp.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/csharp.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/css.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/elixir.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/go.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/haskell.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/html.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/json.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/kotlin.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/lua.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/nix.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/php.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/python.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/ruby.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/rust.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/scala.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/solidity.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/swift.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/language/src/yaml.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/README.md +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/__init__.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/ast_grep_py.pyi +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/ast_grep_py/py.typed +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/src/lib.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/src/py_lang.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/src/py_node.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/src/range.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/src/unicode_position.rs +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_fix.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_range.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_register_lang.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_rule.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_simple.py +0 -0
- {ast_grep_py-0.39.1 → ast_grep_py-0.39.3}/crates/pyo3/tests/test_traversal.py +0 -0
- {ast_grep_py-0.39.1 → 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
368
|
+
version = "4.5.42"
|
|
368
369
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
369
|
-
checksum = "
|
|
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.
|
|
378
|
+
version = "4.5.42"
|
|
378
379
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
379
|
-
checksum = "
|
|
380
|
+
checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966"
|
|
380
381
|
dependencies = [
|
|
381
382
|
"anstream",
|
|
382
383
|
"anstyle",
|
|
@@ -686,7 +687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
686
687
|
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
|
|
687
688
|
dependencies = [
|
|
688
689
|
"libc",
|
|
689
|
-
"windows-sys 0.
|
|
690
|
+
"windows-sys 0.59.0",
|
|
690
691
|
]
|
|
691
692
|
|
|
692
693
|
[[package]]
|
|
@@ -980,7 +981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
980
981
|
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
|
|
981
982
|
dependencies = [
|
|
982
983
|
"cfg-if",
|
|
983
|
-
"windows-targets 0.
|
|
984
|
+
"windows-targets 0.52.6",
|
|
984
985
|
]
|
|
985
986
|
|
|
986
987
|
[[package]]
|
|
@@ -1083,9 +1084,9 @@ dependencies = [
|
|
|
1083
1084
|
|
|
1084
1085
|
[[package]]
|
|
1085
1086
|
name = "napi"
|
|
1086
|
-
version = "3.
|
|
1087
|
+
version = "3.1.4"
|
|
1087
1088
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1088
|
-
checksum = "
|
|
1089
|
+
checksum = "bb4ea803c02e45ebdc6bb45627279e8bdc4e16662e442080cbbc97a8e54d49f7"
|
|
1089
1090
|
dependencies = [
|
|
1090
1091
|
"anyhow",
|
|
1091
1092
|
"bitflags 2.9.0",
|
|
@@ -1100,15 +1101,15 @@ dependencies = [
|
|
|
1100
1101
|
|
|
1101
1102
|
[[package]]
|
|
1102
1103
|
name = "napi-build"
|
|
1103
|
-
version = "2.2.
|
|
1104
|
+
version = "2.2.3"
|
|
1104
1105
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1105
|
-
checksum = "
|
|
1106
|
+
checksum = "dcae8ad5609d14afb3a3b91dee88c757016261b151e9dcecabf1b2a31a6cab14"
|
|
1106
1107
|
|
|
1107
1108
|
[[package]]
|
|
1108
1109
|
name = "napi-derive"
|
|
1109
|
-
version = "3.
|
|
1110
|
+
version = "3.1.2"
|
|
1110
1111
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1111
|
-
checksum = "
|
|
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.
|
|
1124
|
+
version = "2.0.3"
|
|
1124
1125
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1125
|
-
checksum = "
|
|
1126
|
+
checksum = "15158ced16693eaa0c709e4c9768ca08eb56325691e68510db8440d27ccd41d1"
|
|
1126
1127
|
dependencies = [
|
|
1127
1128
|
"convert_case 0.8.0",
|
|
1128
1129
|
"proc-macro2",
|
|
@@ -1279,9 +1280,9 @@ dependencies = [
|
|
|
1279
1280
|
|
|
1280
1281
|
[[package]]
|
|
1281
1282
|
name = "pyo3"
|
|
1282
|
-
version = "0.25.
|
|
1283
|
+
version = "0.25.1"
|
|
1283
1284
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1284
|
-
checksum = "
|
|
1285
|
+
checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
|
|
1285
1286
|
dependencies = [
|
|
1286
1287
|
"anyhow",
|
|
1287
1288
|
"indoc",
|
|
@@ -1297,9 +1298,9 @@ dependencies = [
|
|
|
1297
1298
|
|
|
1298
1299
|
[[package]]
|
|
1299
1300
|
name = "pyo3-build-config"
|
|
1300
|
-
version = "0.25.
|
|
1301
|
+
version = "0.25.1"
|
|
1301
1302
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1302
|
-
checksum = "
|
|
1303
|
+
checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
|
|
1303
1304
|
dependencies = [
|
|
1304
1305
|
"once_cell",
|
|
1305
1306
|
"target-lexicon",
|
|
@@ -1307,9 +1308,9 @@ dependencies = [
|
|
|
1307
1308
|
|
|
1308
1309
|
[[package]]
|
|
1309
1310
|
name = "pyo3-ffi"
|
|
1310
|
-
version = "0.25.
|
|
1311
|
+
version = "0.25.1"
|
|
1311
1312
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1312
|
-
checksum = "
|
|
1313
|
+
checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
|
|
1313
1314
|
dependencies = [
|
|
1314
1315
|
"libc",
|
|
1315
1316
|
"pyo3-build-config",
|
|
@@ -1317,9 +1318,9 @@ dependencies = [
|
|
|
1317
1318
|
|
|
1318
1319
|
[[package]]
|
|
1319
1320
|
name = "pyo3-macros"
|
|
1320
|
-
version = "0.25.
|
|
1321
|
+
version = "0.25.1"
|
|
1321
1322
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1322
|
-
checksum = "
|
|
1323
|
+
checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
|
|
1323
1324
|
dependencies = [
|
|
1324
1325
|
"proc-macro2",
|
|
1325
1326
|
"pyo3-macros-backend",
|
|
@@ -1329,9 +1330,9 @@ dependencies = [
|
|
|
1329
1330
|
|
|
1330
1331
|
[[package]]
|
|
1331
1332
|
name = "pyo3-macros-backend"
|
|
1332
|
-
version = "0.25.
|
|
1333
|
+
version = "0.25.1"
|
|
1333
1334
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1334
|
-
checksum = "
|
|
1335
|
+
checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
|
|
1335
1336
|
dependencies = [
|
|
1336
1337
|
"heck",
|
|
1337
1338
|
"proc-macro2",
|
|
@@ -1374,6 +1375,26 @@ dependencies = [
|
|
|
1374
1375
|
"bitflags 2.9.0",
|
|
1375
1376
|
]
|
|
1376
1377
|
|
|
1378
|
+
[[package]]
|
|
1379
|
+
name = "ref-cast"
|
|
1380
|
+
version = "1.0.24"
|
|
1381
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1382
|
+
checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf"
|
|
1383
|
+
dependencies = [
|
|
1384
|
+
"ref-cast-impl",
|
|
1385
|
+
]
|
|
1386
|
+
|
|
1387
|
+
[[package]]
|
|
1388
|
+
name = "ref-cast-impl"
|
|
1389
|
+
version = "1.0.24"
|
|
1390
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1391
|
+
checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7"
|
|
1392
|
+
dependencies = [
|
|
1393
|
+
"proc-macro2",
|
|
1394
|
+
"quote",
|
|
1395
|
+
"syn",
|
|
1396
|
+
]
|
|
1397
|
+
|
|
1377
1398
|
[[package]]
|
|
1378
1399
|
name = "regex"
|
|
1379
1400
|
version = "1.11.1"
|
|
@@ -1425,7 +1446,7 @@ dependencies = [
|
|
|
1425
1446
|
"errno",
|
|
1426
1447
|
"libc",
|
|
1427
1448
|
"linux-raw-sys",
|
|
1428
|
-
"windows-sys 0.
|
|
1449
|
+
"windows-sys 0.59.0",
|
|
1429
1450
|
]
|
|
1430
1451
|
|
|
1431
1452
|
[[package]]
|
|
@@ -1445,11 +1466,12 @@ dependencies = [
|
|
|
1445
1466
|
|
|
1446
1467
|
[[package]]
|
|
1447
1468
|
name = "schemars"
|
|
1448
|
-
version = "0.
|
|
1469
|
+
version = "1.0.4"
|
|
1449
1470
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1450
|
-
checksum = "
|
|
1471
|
+
checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
|
|
1451
1472
|
dependencies = [
|
|
1452
1473
|
"dyn-clone",
|
|
1474
|
+
"ref-cast",
|
|
1453
1475
|
"schemars_derive",
|
|
1454
1476
|
"serde",
|
|
1455
1477
|
"serde_json",
|
|
@@ -1457,9 +1479,9 @@ dependencies = [
|
|
|
1457
1479
|
|
|
1458
1480
|
[[package]]
|
|
1459
1481
|
name = "schemars_derive"
|
|
1460
|
-
version = "0.
|
|
1482
|
+
version = "1.0.4"
|
|
1461
1483
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1462
|
-
checksum = "
|
|
1484
|
+
checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
|
|
1463
1485
|
dependencies = [
|
|
1464
1486
|
"proc-macro2",
|
|
1465
1487
|
"quote",
|
|
@@ -1662,7 +1684,7 @@ dependencies = [
|
|
|
1662
1684
|
"getrandom",
|
|
1663
1685
|
"once_cell",
|
|
1664
1686
|
"rustix",
|
|
1665
|
-
"windows-sys 0.
|
|
1687
|
+
"windows-sys 0.59.0",
|
|
1666
1688
|
]
|
|
1667
1689
|
|
|
1668
1690
|
[[package]]
|
|
@@ -1760,9 +1782,9 @@ dependencies = [
|
|
|
1760
1782
|
|
|
1761
1783
|
[[package]]
|
|
1762
1784
|
name = "tokio"
|
|
1763
|
-
version = "1.
|
|
1785
|
+
version = "1.47.1"
|
|
1764
1786
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1765
|
-
checksum = "
|
|
1787
|
+
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
|
1766
1788
|
dependencies = [
|
|
1767
1789
|
"backtrace",
|
|
1768
1790
|
"bytes",
|
|
@@ -1994,6 +2016,16 @@ dependencies = [
|
|
|
1994
2016
|
"tree-sitter-language",
|
|
1995
2017
|
]
|
|
1996
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
|
+
|
|
1997
2029
|
[[package]]
|
|
1998
2030
|
name = "tree-sitter-html"
|
|
1999
2031
|
version = "0.23.2"
|
|
@@ -2122,9 +2154,9 @@ dependencies = [
|
|
|
2122
2154
|
|
|
2123
2155
|
[[package]]
|
|
2124
2156
|
name = "tree-sitter-solidity"
|
|
2125
|
-
version = "1.2.
|
|
2157
|
+
version = "1.2.13"
|
|
2126
2158
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2127
|
-
checksum = "
|
|
2159
|
+
checksum = "4eacf8875b70879f0cb670c60b233ad0b68752d9e1474e6c3ef168eea8a90b25"
|
|
2128
2160
|
dependencies = [
|
|
2129
2161
|
"cc",
|
|
2130
2162
|
"tree-sitter-language",
|
|
@@ -2258,7 +2290,7 @@ version = "0.1.9"
|
|
|
2258
2290
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2259
2291
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
|
2260
2292
|
dependencies = [
|
|
2261
|
-
"windows-sys 0.
|
|
2293
|
+
"windows-sys 0.59.0",
|
|
2262
2294
|
]
|
|
2263
2295
|
|
|
2264
2296
|
[[package]]
|
|
@@ -7,7 +7,7 @@ resolver = "2"
|
|
|
7
7
|
lto = true
|
|
8
8
|
|
|
9
9
|
[workspace.package]
|
|
10
|
-
version = "0.39.
|
|
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.
|
|
22
|
-
ast-grep-config = { path = "crates/config", version = "0.39.
|
|
23
|
-
ast-grep-dynamic = { path = "crates/dynamic", version = "0.39.
|
|
24
|
-
ast-grep-language = { path = "crates/language", version = "0.39.
|
|
25
|
-
ast-grep-lsp = { path = "crates/lsp", version = "0.39.
|
|
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" }
|
|
@@ -31,6 +31,6 @@ serde = { version = "1.0.200", features = ["derive"] }
|
|
|
31
31
|
serde_yaml = "0.9.33"
|
|
32
32
|
tree-sitter = { version = "0.25.4" }
|
|
33
33
|
thiserror = "2.0.0"
|
|
34
|
-
schemars = "0.
|
|
34
|
+
schemars = "1.0.0"
|
|
35
35
|
anyhow = "1.0.82"
|
|
36
36
|
dashmap = "6.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ast-grep-py
|
|
3
|
-
Version: 0.39.
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use schemars::{
|
|
1
|
+
use schemars::{JsonSchema, Schema, SchemaGenerator};
|
|
2
2
|
use serde::{de, ser, Deserialize, Serialize};
|
|
3
3
|
use std::borrow::Cow;
|
|
4
4
|
|
|
@@ -70,8 +70,8 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Maybe<T> {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
impl<T: JsonSchema> JsonSchema for Maybe<T> {
|
|
73
|
-
fn schema_name() ->
|
|
74
|
-
format!("Maybe_{}", T::schema_name())
|
|
73
|
+
fn schema_name() -> Cow<'static, str> {
|
|
74
|
+
Cow::Owned(format!("Maybe_{}", T::schema_name()))
|
|
75
75
|
}
|
|
76
76
|
fn schema_id() -> Cow<'static, str> {
|
|
77
77
|
Cow::Owned(format!("Maybe<{}>", T::schema_id()))
|
|
@@ -80,6 +80,10 @@ impl<T: JsonSchema> JsonSchema for Maybe<T> {
|
|
|
80
80
|
gen.subschema_for::<T>()
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
fn inline_schema() -> bool {
|
|
84
|
+
true
|
|
85
|
+
}
|
|
86
|
+
|
|
83
87
|
fn _schemars_private_non_optional_json_schema(gen: &mut SchemaGenerator) -> Schema {
|
|
84
88
|
T::_schemars_private_non_optional_json_schema(gen)
|
|
85
89
|
}
|
|
@@ -12,6 +12,9 @@ use std::collections::HashSet;
|
|
|
12
12
|
|
|
13
13
|
#[derive(Serialize, Deserialize, Clone, JsonSchema)]
|
|
14
14
|
#[serde(rename_all = "camelCase")]
|
|
15
|
+
#[schemars(
|
|
16
|
+
description = "A relational rule object, which is a Rule object with two additional fields stopBy and field."
|
|
17
|
+
)]
|
|
15
18
|
pub struct Relation {
|
|
16
19
|
#[serde(flatten)]
|
|
17
20
|
pub rule: SerializableRule,
|
|
@@ -4,17 +4,17 @@ use crate::rule::{Rule, RuleSerializeError, SerializableRule};
|
|
|
4
4
|
use ast_grep_core::language::Language;
|
|
5
5
|
use ast_grep_core::{Doc, Node};
|
|
6
6
|
|
|
7
|
-
use schemars::JsonSchema;
|
|
7
|
+
use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator};
|
|
8
8
|
use serde::de::{self, Deserializer, MapAccess, Visitor};
|
|
9
9
|
use serde::{Deserialize, Serialize};
|
|
10
10
|
|
|
11
|
+
use std::borrow::Cow;
|
|
11
12
|
use std::collections::HashSet;
|
|
12
13
|
use std::fmt;
|
|
13
14
|
|
|
14
15
|
// NB StopBy's JsonSchema is changed in xtask/schema.rs
|
|
15
16
|
// revise schema is easier than manually implementation
|
|
16
|
-
#[derive(Clone, Default
|
|
17
|
-
#[serde(rename_all = "camelCase")]
|
|
17
|
+
#[derive(Clone, Default)]
|
|
18
18
|
pub enum SerializableStopBy {
|
|
19
19
|
#[default]
|
|
20
20
|
Neighbor,
|
|
@@ -22,6 +22,27 @@ pub enum SerializableStopBy {
|
|
|
22
22
|
Rule(Box<SerializableRule>),
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
impl JsonSchema for SerializableStopBy {
|
|
26
|
+
fn schema_name() -> Cow<'static, str> {
|
|
27
|
+
Cow::Borrowed("SerializableStopBy")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
|
31
|
+
json_schema!({
|
|
32
|
+
"description": "Control how the relational rule search should stop",
|
|
33
|
+
"oneOf": [
|
|
34
|
+
{
|
|
35
|
+
"type": "string",
|
|
36
|
+
"enum": [SerializableStopBy::NEIGHBOR_KEY, SerializableStopBy::END_KEY],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"$ref": "#/$defs/SerializableRule"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
impl SerializableStopBy {
|
|
26
47
|
/// String key used for serializing the Neighbor variant
|
|
27
48
|
const NEIGHBOR_KEY: &str = "neighbor";
|
|
@@ -11,7 +11,7 @@ use ast_grep_core::replacer::Replacer;
|
|
|
11
11
|
use ast_grep_core::source::Content;
|
|
12
12
|
use ast_grep_core::{Doc, Matcher, NodeMatch};
|
|
13
13
|
|
|
14
|
-
use schemars::{
|
|
14
|
+
use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator};
|
|
15
15
|
use serde::{Deserialize, Serialize};
|
|
16
16
|
use serde_yaml::Error as YamlError;
|
|
17
17
|
use serde_yaml::{with::singleton_map_recursive::deserialize, Deserializer};
|
|
@@ -64,6 +64,7 @@ pub struct SerializableRewriter {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
#[derive(Serialize, Deserialize, Clone, JsonSchema)]
|
|
67
|
+
#[schemars(title = "ast-grep rule")]
|
|
67
68
|
pub struct SerializableRuleConfig<L: Language> {
|
|
68
69
|
#[serde(flatten)]
|
|
69
70
|
pub core: SerializableRuleCore,
|
|
@@ -102,24 +103,18 @@ pub struct SerializableRuleConfig<L: Language> {
|
|
|
102
103
|
pub struct Metadata(HashMap<String, serde_yaml::Value>);
|
|
103
104
|
|
|
104
105
|
impl JsonSchema for Metadata {
|
|
105
|
-
fn schema_name() ->
|
|
106
|
-
"Metadata"
|
|
106
|
+
fn schema_name() -> Cow<'static, str> {
|
|
107
|
+
Cow::Borrowed("Metadata")
|
|
107
108
|
}
|
|
108
109
|
fn schema_id() -> Cow<'static, str> {
|
|
109
110
|
Cow::Borrowed("Metadata")
|
|
110
111
|
}
|
|
111
112
|
fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
additional_properties: Some(Box::new(subschema)),
|
|
118
|
-
..Default::default()
|
|
119
|
-
})),
|
|
120
|
-
..Default::default()
|
|
121
|
-
}
|
|
122
|
-
.into()
|
|
113
|
+
json_schema!({
|
|
114
|
+
"type": "object",
|
|
115
|
+
"additionalProperties": true,
|
|
116
|
+
"description": "Additional metadata for the rule, can be used to store extra information."
|
|
117
|
+
})
|
|
123
118
|
}
|
|
124
119
|
}
|
|
125
120
|
|
|
@@ -28,10 +28,15 @@ pub(super) fn match_node_impl<'tree, D: Doc>(
|
|
|
28
28
|
}
|
|
29
29
|
c => c,
|
|
30
30
|
},
|
|
31
|
-
P::MetaVar { meta_var, .. } =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
P::MetaVar { meta_var, .. } => {
|
|
32
|
+
if strictness.should_skip_cand_for_metavar(candidate) {
|
|
33
|
+
return MatchOneNode::SkipCandidate;
|
|
34
|
+
}
|
|
35
|
+
match agg.match_meta_var(meta_var, candidate) {
|
|
36
|
+
Some(()) => MatchOneNode::MatchedBoth,
|
|
37
|
+
None => MatchOneNode::NoMatch, // TODO: this may be wrong
|
|
38
|
+
}
|
|
39
|
+
}
|
|
35
40
|
P::Internal {
|
|
36
41
|
kind_id, children, ..
|
|
37
42
|
} => {
|
|
@@ -23,12 +23,15 @@ pub(crate) enum MatchOneNode {
|
|
|
23
23
|
NoMatch,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
fn skip_comment(n: &Node<impl Doc>) -> bool {
|
|
27
|
+
n.kind().contains("comment")
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
fn skip_comment_or_unnamed(n: &Node<impl Doc>) -> bool {
|
|
27
31
|
if !n.is_named() {
|
|
28
32
|
return true;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
kind.contains("comment")
|
|
34
|
+
skip_comment(n)
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
impl MatchStrictness {
|
|
@@ -86,6 +89,14 @@ impl MatchStrictness {
|
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
pub(crate) fn should_skip_cand_for_metavar<D: Doc>(&self, candidate: &Node<D>) -> bool {
|
|
93
|
+
use MatchStrictness as M;
|
|
94
|
+
match self {
|
|
95
|
+
M::Cst | M::Ast | M::Smart => false,
|
|
96
|
+
M::Relaxed | M::Signature | M::Template => skip_comment(candidate),
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
// TODO: this is a method for working around trailing nodes after pattern is matched
|
|
90
101
|
pub(crate) fn should_skip_trailing<D: Doc>(&self, candidate: &Node<D>) -> bool {
|
|
91
102
|
use MatchStrictness as M;
|
|
@@ -95,7 +106,7 @@ impl MatchStrictness {
|
|
|
95
106
|
M::Ast => false,
|
|
96
107
|
M::Relaxed => skip_comment_or_unnamed(candidate),
|
|
97
108
|
M::Signature => skip_comment_or_unnamed(candidate),
|
|
98
|
-
M::Template =>
|
|
109
|
+
M::Template => skip_comment(candidate),
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
|
|
@@ -158,14 +169,18 @@ mod test {
|
|
|
158
169
|
use crate::language::Tsx;
|
|
159
170
|
use crate::{Pattern, Root};
|
|
160
171
|
|
|
161
|
-
fn
|
|
172
|
+
fn test_match(p: &str, n: &str, strictness: MatchStrictness) -> bool {
|
|
162
173
|
let mut pattern = Pattern::new(p, Tsx);
|
|
163
|
-
pattern.strictness =
|
|
174
|
+
pattern.strictness = strictness;
|
|
164
175
|
let root = Root::str(n, Tsx);
|
|
165
176
|
let node = root.root();
|
|
166
177
|
node.find(pattern).is_some()
|
|
167
178
|
}
|
|
168
179
|
|
|
180
|
+
fn template_pattern(p: &str, n: &str) -> bool {
|
|
181
|
+
test_match(p, n, MatchStrictness::Template)
|
|
182
|
+
}
|
|
183
|
+
|
|
169
184
|
#[test]
|
|
170
185
|
fn test_template_pattern() {
|
|
171
186
|
assert!(template_pattern("$A = $B", "a = b"));
|
|
@@ -174,4 +189,28 @@ mod test {
|
|
|
174
189
|
assert!(template_pattern("$A = $B", "const a = b"));
|
|
175
190
|
assert!(template_pattern("$A = $B", "class A { a = b }"));
|
|
176
191
|
}
|
|
192
|
+
|
|
193
|
+
fn relaxed_pattern(p: &str, n: &str) -> bool {
|
|
194
|
+
test_match(p, n, MatchStrictness::Relaxed)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#[test]
|
|
198
|
+
fn test_ignore_comment() {
|
|
199
|
+
assert!(relaxed_pattern("$A($B)", "foo(bar /* .. */)"));
|
|
200
|
+
assert!(relaxed_pattern(
|
|
201
|
+
"$A($B)",
|
|
202
|
+
"
|
|
203
|
+
foo(
|
|
204
|
+
bar, // ..
|
|
205
|
+
)"
|
|
206
|
+
));
|
|
207
|
+
assert!(relaxed_pattern("$A($B)", "foo(/* .. */ bar)"));
|
|
208
|
+
assert!(relaxed_pattern(
|
|
209
|
+
"$A($B)",
|
|
210
|
+
"
|
|
211
|
+
foo( // ..
|
|
212
|
+
bar
|
|
213
|
+
)"
|
|
214
|
+
));
|
|
215
|
+
}
|
|
177
216
|
}
|
|
@@ -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
|
}
|
|
@@ -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.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|