ast-grep-cli 0.25.2__tar.gz → 0.25.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.
Files changed (105) hide show
  1. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/Cargo.lock +29 -29
  2. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/Cargo.toml +7 -7
  3. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/PKG-INFO +1 -1
  4. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/config.rs +5 -1
  5. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/error.rs +7 -1
  6. ast_grep_cli-0.25.3/crates/cli/src/lang/injection.rs +244 -0
  7. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/lang.rs +9 -9
  8. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/new.rs +3 -2
  9. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/dynamic/src/lib.rs +1 -1
  10. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/pyproject.toml +1 -1
  11. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/LICENSE +0 -0
  12. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/README.md +0 -0
  13. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/Cargo.toml +0 -0
  14. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/bin/ast-grep.rs +0 -0
  15. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/completions.rs +0 -0
  16. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/debug.rs +0 -0
  17. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/lang/custom_lang.rs +0 -0
  18. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/lang/lang_globs.rs +0 -0
  19. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/lib.rs +0 -0
  20. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/lsp.rs +0 -0
  21. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/main.rs +0 -0
  22. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/cloud_print.rs +0 -0
  23. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/colored_print/test.rs +0 -0
  24. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/colored_print.rs +0 -0
  25. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/interactive_print.rs +0 -0
  26. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/json_print.rs +0 -0
  27. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/print/mod.rs +0 -0
  28. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/run.rs +0 -0
  29. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/scan.rs +0 -0
  30. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/utils.rs +0 -0
  31. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/case_result.rs +0 -0
  32. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/find_file.rs +0 -0
  33. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/mod.rs +0 -0
  34. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/reporter.rs +0 -0
  35. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/snapshot.rs +0 -0
  36. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/src/verify/test_case.rs +0 -0
  37. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/tests/common/mod.rs +0 -0
  38. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/tests/run_test.rs +0 -0
  39. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/tests/scan_test.rs +0 -0
  40. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/cli/tests/verify_test.rs +0 -0
  41. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/Cargo.toml +0 -0
  42. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/check_var.rs +0 -0
  43. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/combined.rs +0 -0
  44. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/fixer.rs +0 -0
  45. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/lib.rs +0 -0
  46. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/maybe.rs +0 -0
  47. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/deserialize_env.rs +0 -0
  48. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/mod.rs +0 -0
  49. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/nth_child.rs +0 -0
  50. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/referent_rule.rs +0 -0
  51. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/relational_rule.rs +0 -0
  52. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule/stop_by.rs +0 -0
  53. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule_collection.rs +0 -0
  54. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule_config.rs +0 -0
  55. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/rule_core.rs +0 -0
  56. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/transform/mod.rs +0 -0
  57. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/transform/rewrite.rs +0 -0
  58. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/transform/string_case.rs +0 -0
  59. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/config/src/transform/transformation.rs +0 -0
  60. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/Cargo.toml +0 -0
  61. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/language.rs +0 -0
  62. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/lib.rs +0 -0
  63. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/match_tree/match_node.rs +0 -0
  64. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/match_tree/mod.rs +0 -0
  65. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/match_tree/strictness.rs +0 -0
  66. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/matcher/kind.rs +0 -0
  67. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/matcher/node_match.rs +0 -0
  68. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/matcher/pattern.rs +0 -0
  69. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/matcher/text.rs +0 -0
  70. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/matcher.rs +0 -0
  71. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/meta_var.rs +0 -0
  72. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/node.rs +0 -0
  73. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/ops.rs +0 -0
  74. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/pinned.rs +0 -0
  75. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/replacer/indent.rs +0 -0
  76. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/replacer/structural.rs +0 -0
  77. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/replacer/template.rs +0 -0
  78. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/replacer.rs +0 -0
  79. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/source.rs +0 -0
  80. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/core/src/traversal.rs +0 -0
  81. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/dynamic/Cargo.toml +0 -0
  82. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/Cargo.toml +0 -0
  83. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/bash.rs +0 -0
  84. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/cpp.rs +0 -0
  85. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/csharp.rs +0 -0
  86. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/css.rs +0 -0
  87. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/elixir.rs +0 -0
  88. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/go.rs +0 -0
  89. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/haskell.rs +0 -0
  90. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/html.rs +0 -0
  91. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/json.rs +0 -0
  92. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/kotlin.rs +0 -0
  93. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/lib.rs +0 -0
  94. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/lua.rs +0 -0
  95. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/parsers.rs +0 -0
  96. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/php.rs +0 -0
  97. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/python.rs +0 -0
  98. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/ruby.rs +0 -0
  99. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/rust.rs +0 -0
  100. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/scala.rs +0 -0
  101. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/language/src/swift.rs +0 -0
  102. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/lsp/Cargo.toml +0 -0
  103. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/lsp/src/lib.rs +0 -0
  104. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/lsp/src/utils.rs +0 -0
  105. {ast_grep_cli-0.25.2 → ast_grep_cli-0.25.3}/crates/lsp/tests/basic.rs +0 -0
@@ -113,7 +113,7 @@ dependencies = [
113
113
 
114
114
  [[package]]
115
115
  name = "ast-grep"
116
- version = "0.25.2"
116
+ version = "0.25.3"
117
117
  dependencies = [
118
118
  "ansi_term",
119
119
  "anyhow",
@@ -145,7 +145,7 @@ dependencies = [
145
145
 
146
146
  [[package]]
147
147
  name = "ast-grep-config"
148
- version = "0.25.2"
148
+ version = "0.25.3"
149
149
  dependencies = [
150
150
  "anyhow",
151
151
  "ast-grep-core",
@@ -161,7 +161,7 @@ dependencies = [
161
161
 
162
162
  [[package]]
163
163
  name = "ast-grep-core"
164
- version = "0.25.2"
164
+ version = "0.25.3"
165
165
  dependencies = [
166
166
  "bit-set",
167
167
  "regex",
@@ -172,7 +172,7 @@ dependencies = [
172
172
 
173
173
  [[package]]
174
174
  name = "ast-grep-dynamic"
175
- version = "0.25.2"
175
+ version = "0.25.3"
176
176
  dependencies = [
177
177
  "ast-grep-core",
178
178
  "ignore",
@@ -184,7 +184,7 @@ dependencies = [
184
184
 
185
185
  [[package]]
186
186
  name = "ast-grep-language"
187
- version = "0.25.2"
187
+ version = "0.25.3"
188
188
  dependencies = [
189
189
  "ast-grep-core",
190
190
  "ignore",
@@ -215,7 +215,7 @@ dependencies = [
215
215
 
216
216
  [[package]]
217
217
  name = "ast-grep-lsp"
218
- version = "0.25.2"
218
+ version = "0.25.3"
219
219
  dependencies = [
220
220
  "ast-grep-config",
221
221
  "ast-grep-core",
@@ -229,7 +229,7 @@ dependencies = [
229
229
 
230
230
  [[package]]
231
231
  name = "ast-grep-napi"
232
- version = "0.25.2"
232
+ version = "0.25.3"
233
233
  dependencies = [
234
234
  "ast-grep-config",
235
235
  "ast-grep-core",
@@ -248,7 +248,7 @@ dependencies = [
248
248
 
249
249
  [[package]]
250
250
  name = "ast-grep-py"
251
- version = "0.25.2"
251
+ version = "0.25.3"
252
252
  dependencies = [
253
253
  "anyhow",
254
254
  "ast-grep-config",
@@ -314,7 +314,7 @@ dependencies = [
314
314
 
315
315
  [[package]]
316
316
  name = "benches"
317
- version = "0.25.2"
317
+ version = "0.25.3"
318
318
  dependencies = [
319
319
  "ast-grep-config",
320
320
  "ast-grep-core",
@@ -324,18 +324,18 @@ dependencies = [
324
324
 
325
325
  [[package]]
326
326
  name = "bit-set"
327
- version = "0.6.0"
327
+ version = "0.8.0"
328
328
  source = "registry+https://github.com/rust-lang/crates.io-index"
329
- checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f"
329
+ checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
330
330
  dependencies = [
331
331
  "bit-vec",
332
332
  ]
333
333
 
334
334
  [[package]]
335
335
  name = "bit-vec"
336
- version = "0.7.0"
336
+ version = "0.8.0"
337
337
  source = "registry+https://github.com/rust-lang/crates.io-index"
338
- checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
338
+ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
339
339
 
340
340
  [[package]]
341
341
  name = "bitflags"
@@ -963,9 +963,9 @@ checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
963
963
 
964
964
  [[package]]
965
965
  name = "libloading"
966
- version = "0.8.4"
966
+ version = "0.8.5"
967
967
  source = "registry+https://github.com/rust-lang/crates.io-index"
968
- checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
968
+ checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
969
969
  dependencies = [
970
970
  "cfg-if",
971
971
  "windows-targets 0.48.5",
@@ -1066,9 +1066,9 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a"
1066
1066
 
1067
1067
  [[package]]
1068
1068
  name = "napi-derive"
1069
- version = "2.16.8"
1069
+ version = "2.16.9"
1070
1070
  source = "registry+https://github.com/rust-lang/crates.io-index"
1071
- checksum = "eafd2b920906ea5b1f5f1f9d1eff9cc74e4ff8124dca41b501c1413079589187"
1071
+ checksum = "87c3b5d4ab13e20a4bb9d3a1e2f3d4e77eee4a205d0f810abfd226b971dc6ce5"
1072
1072
  dependencies = [
1073
1073
  "cfg-if",
1074
1074
  "convert_case",
@@ -1080,9 +1080,9 @@ dependencies = [
1080
1080
 
1081
1081
  [[package]]
1082
1082
  name = "napi-derive-backend"
1083
- version = "1.0.70"
1083
+ version = "1.0.71"
1084
1084
  source = "registry+https://github.com/rust-lang/crates.io-index"
1085
- checksum = "b370b784440c65eb9001d839012eb912ee43e3a2d0361e2c30c13052372c39fe"
1085
+ checksum = "96de436a6ab93265beef838f8333c8345438f059df6081fe0ad0b8648ee0c524"
1086
1086
  dependencies = [
1087
1087
  "convert_case",
1088
1088
  "once_cell",
@@ -1672,18 +1672,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
1672
1672
 
1673
1673
  [[package]]
1674
1674
  name = "thiserror"
1675
- version = "1.0.62"
1675
+ version = "1.0.63"
1676
1676
  source = "registry+https://github.com/rust-lang/crates.io-index"
1677
- checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb"
1677
+ checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
1678
1678
  dependencies = [
1679
1679
  "thiserror-impl",
1680
1680
  ]
1681
1681
 
1682
1682
  [[package]]
1683
1683
  name = "thiserror-impl"
1684
- version = "1.0.62"
1684
+ version = "1.0.63"
1685
1685
  source = "registry+https://github.com/rust-lang/crates.io-index"
1686
- checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c"
1686
+ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
1687
1687
  dependencies = [
1688
1688
  "proc-macro2",
1689
1689
  "quote",
@@ -1727,9 +1727,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
1727
1727
 
1728
1728
  [[package]]
1729
1729
  name = "tokio"
1730
- version = "1.38.0"
1730
+ version = "1.38.1"
1731
1731
  source = "registry+https://github.com/rust-lang/crates.io-index"
1732
- checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
1732
+ checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df"
1733
1733
  dependencies = [
1734
1734
  "backtrace",
1735
1735
  "bytes",
@@ -1758,9 +1758,9 @@ checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
1758
1758
 
1759
1759
  [[package]]
1760
1760
  name = "toml_edit"
1761
- version = "0.22.15"
1761
+ version = "0.22.16"
1762
1762
  source = "registry+https://github.com/rust-lang/crates.io-index"
1763
- checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1"
1763
+ checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788"
1764
1764
  dependencies = [
1765
1765
  "indexmap",
1766
1766
  "toml_datetime",
@@ -1900,9 +1900,9 @@ dependencies = [
1900
1900
 
1901
1901
  [[package]]
1902
1902
  name = "tree-sitter-cpp"
1903
- version = "0.22.2"
1903
+ version = "0.22.3"
1904
1904
  source = "registry+https://github.com/rust-lang/crates.io-index"
1905
- checksum = "537b7e0f0d8c89b8dd6f4d195814da94832f20720c09016c2a3ac3dc3c437993"
1905
+ checksum = "1d509a22a992790d38f2c291961ff8a1ff016c437c7ec6befc9220b8eec8918c"
1906
1906
  dependencies = [
1907
1907
  "cc",
1908
1908
  "tree-sitter",
@@ -7,7 +7,7 @@ resolver = "2"
7
7
  lto = true
8
8
 
9
9
  [workspace.package]
10
- version = "0.25.2"
10
+ version = "0.25.3"
11
11
  authors = ["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"]
12
12
  edition = "2021"
13
13
  license = "MIT"
@@ -18,13 +18,13 @@ rust-version = "1.67"
18
18
  readme = "README.md"
19
19
 
20
20
  [workspace.dependencies]
21
- ast-grep-core = { path = "crates/core", version = "0.25.2" }
22
- ast-grep-config = { path = "crates/config", version = "0.25.2" }
23
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.25.2" }
24
- ast-grep-language = { path = "crates/language", version = "0.25.2" }
25
- ast-grep-lsp = { path = "crates/lsp", version = "0.25.2" }
21
+ ast-grep-core = { path = "crates/core", version = "0.25.3" }
22
+ ast-grep-config = { path = "crates/config", version = "0.25.3" }
23
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.25.3" }
24
+ ast-grep-language = { path = "crates/language", version = "0.25.3" }
25
+ ast-grep-lsp = { path = "crates/lsp", version = "0.25.3" }
26
26
 
27
- bit-set = { version = "0.6.0" }
27
+ bit-set = { version = "0.8.0" }
28
28
  ignore = { version = "0.4.22" }
29
29
  regex = { version = "1.10.4" }
30
30
  serde = { version = "1.0.200", features = ["derive"] }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ast-grep-cli
3
- Version: 0.25.2
3
+ Version: 0.25.3
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -1,5 +1,5 @@
1
1
  use crate::error::ErrorContext as EC;
2
- use crate::lang::{CustomLang, LanguageGlobs, SgLang};
2
+ use crate::lang::{CustomLang, LanguageGlobs, SerializableInjection, SgLang};
3
3
 
4
4
  use anyhow::{Context, Result};
5
5
  use ast_grep_config::{
@@ -49,6 +49,9 @@ pub struct AstGrepConfig {
49
49
  /// additional file globs for languages
50
50
  #[serde(skip_serializing_if = "Option::is_none")]
51
51
  pub language_globs: Option<LanguageGlobs>,
52
+ /// injection config for embedded languages
53
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
54
+ pub language_injections: Vec<SerializableInjection>,
52
55
  }
53
56
 
54
57
  pub fn find_rules(
@@ -81,6 +84,7 @@ pub fn register_custom_language(config_path: Option<PathBuf>) -> Result<()> {
81
84
  if let Some(globs) = sg_config.language_globs {
82
85
  SgLang::register_globs(globs)?;
83
86
  }
87
+ SgLang::register_injections(sg_config.language_injections)?;
84
88
  Ok(())
85
89
  }
86
90
 
@@ -32,6 +32,7 @@ pub enum ErrorContext {
32
32
  InvalidGlobalUtils,
33
33
  GlobPattern,
34
34
  UnrecognizableLanguage(String),
35
+ LangInjection,
35
36
  // Run
36
37
  ParsePattern,
37
38
  LanguageNotSpecified,
@@ -71,7 +72,7 @@ impl ErrorContext {
71
72
  ReadConfiguration | ReadRule(_) | WalkRuleDir(_) | WriteFile(_) => 5,
72
73
  StdInIsNotInteractive => 6,
73
74
  ParseTest(_) | ParseRule(_) | ParseConfiguration | GlobPattern | ParsePattern
74
- | InvalidGlobalUtils => 8,
75
+ | InvalidGlobalUtils | LangInjection => 8,
75
76
  CannotInferShell => 10,
76
77
  ProjectAlreadyExist | FileAlreadyExist(_) => 17,
77
78
  InsufficientCLIArgument(_) => 22,
@@ -147,6 +148,11 @@ impl ErrorMessage {
147
148
  "The pattern in files/ignore is not a valid glob. Please refer to doc and fix the error.",
148
149
  CONFIG_GUIDE,
149
150
  ),
151
+ LangInjection => Self::new(
152
+ "Cannot parse languageInjections in config",
153
+ "The rule in languageInjections is not valid. Please refer to doc and fix the error.",
154
+ CONFIG_GUIDE,
155
+ ),
150
156
  InvalidGlobalUtils => Self::new(
151
157
  "Error occurs when parsing global utility rules",
152
158
  "Please check the YAML rules inside the rule directory",
@@ -0,0 +1,244 @@
1
+ use super::SgLang;
2
+ use crate::error::ErrorContext as EC;
3
+ use ast_grep_config::{DeserializeEnv, RuleCore, SerializableRuleCore};
4
+ use ast_grep_core::{
5
+ language::{TSPoint, TSRange},
6
+ Doc, Language, Node, StrDoc,
7
+ };
8
+
9
+ use anyhow::{Context, Result};
10
+ use serde::{Deserialize, Serialize};
11
+
12
+ use std::collections::{HashMap, HashSet};
13
+ use std::ptr::{addr_of, addr_of_mut};
14
+ use std::str::FromStr;
15
+
16
+ // NB, you should not use SgLang in the (de_serialize interface
17
+ // since Injected is used before lang registration in sgconfig.yml
18
+ #[derive(Serialize, Deserialize, Clone)]
19
+ #[serde(untagged)]
20
+ pub enum Injected {
21
+ Static(String),
22
+ Dynamic(Vec<String>),
23
+ }
24
+
25
+ #[derive(Serialize, Deserialize, Clone)]
26
+ #[serde(rename_all = "camelCase")]
27
+ pub struct SerializableInjection {
28
+ #[serde(flatten)]
29
+ core: SerializableRuleCore,
30
+ /// The host language, e.g. html, contains other languages
31
+ host_language: String,
32
+ /// Injected language according to the rule
33
+ /// It accepts either a string like js for single static language.
34
+ /// or an array of string like [js, ts] for dynamic language detection.
35
+ injected: Injected,
36
+ }
37
+
38
+ struct Injection {
39
+ host: SgLang,
40
+ rules: Vec<(RuleCore<SgLang>, Option<String>)>,
41
+ injectable: HashSet<String>,
42
+ }
43
+
44
+ impl Injection {
45
+ fn new(lang: SgLang) -> Self {
46
+ Self {
47
+ host: lang,
48
+ rules: vec![],
49
+ injectable: Default::default(),
50
+ }
51
+ }
52
+ }
53
+
54
+ pub unsafe fn register_injetables(injections: Vec<SerializableInjection>) -> Result<()> {
55
+ let mut injectable = HashMap::new();
56
+ for injection in injections {
57
+ register_injetable(injection, &mut injectable)?;
58
+ }
59
+ merge_default_injecatable(&mut injectable);
60
+ *addr_of_mut!(LANG_INJECTIONS) = injectable.into_values().collect();
61
+ let injects = unsafe { &*addr_of!(LANG_INJECTIONS) as &'static Vec<Injection> };
62
+ *addr_of_mut!(INJECTABLE_LANGS) = injects
63
+ .iter()
64
+ .map(|inj| {
65
+ (
66
+ inj.host,
67
+ inj.injectable.iter().map(|s| s.as_str()).collect(),
68
+ )
69
+ })
70
+ .collect();
71
+ Ok(())
72
+ }
73
+
74
+ fn merge_default_injecatable(ret: &mut HashMap<SgLang, Injection>) {
75
+ for (lang, injection) in ret {
76
+ let langs = match lang {
77
+ SgLang::Builtin(b) => b.injectable_languages(),
78
+ SgLang::Custom(c) => c.injectable_languages(),
79
+ };
80
+ let Some(langs) = langs else {
81
+ continue;
82
+ };
83
+ injection
84
+ .injectable
85
+ .extend(langs.iter().map(|s| s.to_string()));
86
+ }
87
+ }
88
+
89
+ fn register_injetable(
90
+ injection: SerializableInjection,
91
+ injectable: &mut HashMap<SgLang, Injection>,
92
+ ) -> Result<()> {
93
+ let lang = SgLang::from_str(&injection.host_language)?;
94
+ let env = DeserializeEnv::new(lang);
95
+ let rule = injection.core.get_matcher(env).context(EC::LangInjection)?;
96
+ let default_lang = match &injection.injected {
97
+ Injected::Static(s) => Some(s.clone()),
98
+ Injected::Dynamic(_) => None,
99
+ };
100
+ let entry = injectable
101
+ .entry(lang)
102
+ .or_insert_with(|| Injection::new(lang));
103
+ match injection.injected {
104
+ Injected::Static(s) => {
105
+ entry.injectable.insert(s);
106
+ }
107
+ Injected::Dynamic(v) => entry.injectable.extend(v),
108
+ }
109
+ entry.rules.push((rule, default_lang));
110
+ Ok(())
111
+ }
112
+
113
+ static mut LANG_INJECTIONS: Vec<Injection> = vec![];
114
+ static mut INJECTABLE_LANGS: Vec<(SgLang, Vec<&'static str>)> = vec![];
115
+
116
+ pub fn injectable_languages(lang: SgLang) -> Option<&'static [&'static str]> {
117
+ // NB: custom injection and builtin injections are resolved in INJECTABLE_LANGS
118
+ let injections =
119
+ unsafe { &*addr_of!(INJECTABLE_LANGS) as &'static Vec<(SgLang, Vec<&'static str>)> };
120
+ let Some(injection) = injections.iter().find(|i| i.0 == lang) else {
121
+ return match lang {
122
+ SgLang::Builtin(b) => b.injectable_languages(),
123
+ SgLang::Custom(c) => c.injectable_languages(),
124
+ };
125
+ };
126
+ Some(&injection.1)
127
+ }
128
+
129
+ pub fn extract_injections<D: Doc>(root: Node<D>) -> HashMap<String, Vec<TSRange>> {
130
+ // NB Only works in the CLI crate because we only has Node<SgLang>
131
+ let root: Node<StrDoc<SgLang>> = unsafe { std::mem::transmute(root) };
132
+ let mut ret = match root.lang() {
133
+ SgLang::Custom(c) => c.extract_injections(root.clone()),
134
+ SgLang::Builtin(b) => b.extract_injections(root.clone()),
135
+ };
136
+ let injections = unsafe { &*addr_of!(LANG_INJECTIONS) };
137
+ extract_custom_inject(injections, root, &mut ret);
138
+ ret
139
+ }
140
+
141
+ fn extract_custom_inject(
142
+ injections: &[Injection],
143
+ root: Node<StrDoc<SgLang>>,
144
+ ret: &mut HashMap<String, Vec<TSRange>>,
145
+ ) {
146
+ let Some(rules) = injections.iter().find(|n| n.host == *root.lang()) else {
147
+ return;
148
+ };
149
+ for (rule, default_lang) in &rules.rules {
150
+ for m in root.find_all(rule) {
151
+ let env = m.get_env();
152
+ let Some(region) = env.get_match("CONTENT") else {
153
+ continue;
154
+ };
155
+ let Some(lang) = env
156
+ .get_match("LANG")
157
+ .map(|n| n.text().to_string())
158
+ .or_else(|| default_lang.clone())
159
+ else {
160
+ continue;
161
+ };
162
+ let range = node_to_range(region);
163
+ ret.entry(lang).or_default().push(range);
164
+ }
165
+ }
166
+ }
167
+
168
+ fn node_to_range<D: Doc>(node: &Node<D>) -> TSRange {
169
+ let r = node.range();
170
+ let start = node.start_pos();
171
+ let sp = TSPoint::new(start.0 as u32, start.1 as u32);
172
+ let end = node.end_pos();
173
+ let ep = TSPoint::new(end.0 as u32, end.1 as u32);
174
+ TSRange::new(r.start as u32, r.end as u32, &sp, &ep)
175
+ }
176
+
177
+ #[cfg(test)]
178
+ mod test {
179
+ use super::*;
180
+ use ast_grep_config::from_str;
181
+ use ast_grep_language::SupportLang;
182
+ const DYNAMIC: &str = "
183
+ hostLanguage: js
184
+ rule:
185
+ pattern: styled.$LANG`$CONTENT`
186
+ injected: [css]";
187
+ const STATIC: &str = "
188
+ hostLanguage: js
189
+ rule:
190
+ pattern: styled`$CONTENT`
191
+ injected: css";
192
+ #[test]
193
+ fn test_deserialize() {
194
+ let inj: SerializableInjection = from_str(STATIC).expect("should ok");
195
+ assert!(matches!(inj.injected, Injected::Static(_)));
196
+ let inj: SerializableInjection = from_str(DYNAMIC).expect("should ok");
197
+ assert!(matches!(inj.injected, Injected::Dynamic(_)));
198
+ }
199
+
200
+ const BAD: &str = "
201
+ hostLanguage: HTML
202
+ rule:
203
+ kind: not_exist
204
+ injected: [js, ts, tsx]";
205
+
206
+ #[test]
207
+ fn test_bad_inject() {
208
+ let mut map = HashMap::new();
209
+ let inj: SerializableInjection = from_str(BAD).expect("should ok");
210
+ let ret = register_injetable(inj, &mut map);
211
+ assert!(ret.is_err());
212
+ let ec = ret.unwrap_err().downcast::<EC>().expect("should ok");
213
+ assert!(matches!(ec, EC::LangInjection));
214
+ }
215
+
216
+ #[test]
217
+ fn test_good_injection() {
218
+ let mut map = HashMap::new();
219
+ let inj: SerializableInjection = from_str(STATIC).expect("should ok");
220
+ let ret = register_injetable(inj, &mut map);
221
+ assert!(ret.is_ok());
222
+ let inj: SerializableInjection = from_str(DYNAMIC).expect("should ok");
223
+ let ret = register_injetable(inj, &mut map);
224
+ assert!(ret.is_ok());
225
+ assert_eq!(map.len(), 1);
226
+ let injections: Vec<_> = map.into_values().collect();
227
+ let mut ret = HashMap::new();
228
+ let sg =
229
+ SgLang::from(SupportLang::JavaScript).ast_grep("const a = styled`.btn { margin: 0; }`");
230
+ let root = sg.root();
231
+ extract_custom_inject(&injections, root, &mut ret);
232
+ assert_eq!(ret.len(), 1);
233
+ assert_eq!(ret["css"].len(), 1);
234
+ assert!(!ret.contains_key("js"));
235
+ ret.clear();
236
+ let sg =
237
+ SgLang::from(SupportLang::JavaScript).ast_grep("const a = styled.css`.btn { margin: 0; }`");
238
+ let root = sg.root();
239
+ extract_custom_inject(&injections, root, &mut ret);
240
+ assert_eq!(ret.len(), 1);
241
+ assert_eq!(ret["css"].len(), 1);
242
+ assert!(!ret.contains_key("js"));
243
+ }
244
+ }
@@ -1,4 +1,5 @@
1
1
  mod custom_lang;
2
+ mod injection;
2
3
  mod lang_globs;
3
4
 
4
5
  use anyhow::Result;
@@ -18,9 +19,10 @@ use std::path::{Path, PathBuf};
18
19
  use std::str::FromStr;
19
20
 
20
21
  pub use custom_lang::CustomLang;
22
+ pub use injection::SerializableInjection;
21
23
  pub use lang_globs::LanguageGlobs;
22
24
 
23
- #[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
25
+ #[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
24
26
  #[serde(untagged)]
25
27
  pub enum SgLang {
26
28
  // inlined support lang expando char
@@ -51,6 +53,10 @@ impl SgLang {
51
53
  Ok(())
52
54
  }
53
55
 
56
+ pub fn register_injections(injections: Vec<SerializableInjection>) -> Result<()> {
57
+ unsafe { injection::register_injetables(injections) }
58
+ }
59
+
54
60
  pub fn all_langs() -> Vec<Self> {
55
61
  let builtin = SupportLang::all_langs().iter().copied().map(Self::Builtin);
56
62
  let customs = DynamicLang::all_langs().into_iter().map(Self::Custom);
@@ -180,17 +186,11 @@ impl Language for SgLang {
180
186
  }
181
187
 
182
188
  fn injectable_languages(&self) -> Option<&'static [&'static str]> {
183
- match self {
184
- Builtin(b) => b.injectable_languages(),
185
- Custom(c) => c.injectable_languages(),
186
- }
189
+ injection::injectable_languages(*self)
187
190
  }
188
191
 
189
192
  fn extract_injections<D: Doc>(&self, root: Node<D>) -> HashMap<String, Vec<TSRange>> {
190
- match self {
191
- Builtin(b) => b.extract_injections(root),
192
- Custom(c) => c.extract_injections(root),
193
- }
193
+ injection::extract_injections(root)
194
194
  }
195
195
  }
196
196
 
@@ -212,8 +212,9 @@ fn create_new_project(arg: NewArg) -> Result<()> {
212
212
  rule_dirs: vec![rule_dirs],
213
213
  test_configs: test_dirs.map(|t| vec![t]),
214
214
  util_dirs: utils.map(|u| vec![u]),
215
- custom_languages: None, // advanced feature, skip now
216
- language_globs: None, // advanced feature, skip now
215
+ custom_languages: None, // advanced feature, skip now
216
+ language_globs: None, // advanced feature, skip now
217
+ language_injections: vec![], // advanced feature
217
218
  };
218
219
  let config_path = arg.base_dir.join("sgconfig.yml");
219
220
  let f = File::create(config_path)?;
@@ -16,7 +16,7 @@ use std::str::FromStr;
16
16
  type LangIndex = u32;
17
17
 
18
18
  /// Represents a tree-sitter language loaded as dynamic lib.
19
- #[derive(Copy, Clone, PartialEq, Eq)]
19
+ #[derive(Copy, Clone, PartialEq, Eq, Hash)]
20
20
  pub struct DynamicLang {
21
21
  index: LangIndex,
22
22
  // inline expando char since it is used frequently
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "ast-grep-cli"
7
- version = "0.25.2"
7
+ version = "0.25.3"
8
8
  description = "Structural Search and Rewrite code at large scale using precise AST pattern."
9
9
  authors = [{ name = "Herrington Darkholme", email = "2883231+HerringtonDarkholme@users.noreply.github.com" }]
10
10
  maintainers = [{ name = "Herrington Darkholme", email = "2883231+HerringtonDarkholme@users.noreply.github.com" }]
File without changes
File without changes