ast-grep-cli 0.26.2__tar.gz → 0.27.0__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 (106) hide show
  1. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/Cargo.lock +47 -22
  2. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/Cargo.toml +6 -6
  3. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/PKG-INFO +1 -1
  4. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/mod.rs +2 -2
  5. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/Cargo.toml +1 -1
  6. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/combined.rs +5 -5
  7. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule_collection.rs +1 -1
  8. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule_config.rs +6 -1
  9. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/transform/mod.rs +26 -0
  10. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/transform/transformation.rs +37 -18
  11. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/Cargo.toml +1 -1
  12. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/match_tree/strictness.rs +4 -1
  13. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/meta_var.rs +14 -2
  14. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/replacer/indent.rs +21 -0
  15. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/replacer.rs +2 -0
  16. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/dynamic/Cargo.toml +1 -1
  17. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/Cargo.toml +4 -2
  18. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/lib.rs +7 -1
  19. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/parsers.rs +4 -0
  20. ast_grep_cli-0.27.0/crates/language/src/yaml.rs +60 -0
  21. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/lsp/Cargo.toml +2 -2
  22. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/pyproject.toml +1 -1
  23. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/LICENSE +0 -0
  24. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/README.md +0 -0
  25. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/Cargo.toml +0 -0
  26. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/bin/ast-grep.rs +0 -0
  27. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/completions.rs +0 -0
  28. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/config.rs +0 -0
  29. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/debug.rs +0 -0
  30. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/error.rs +0 -0
  31. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lang/custom_lang.rs +0 -0
  32. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lang/injection.rs +0 -0
  33. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lang/lang_globs.rs +0 -0
  34. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lang.rs +0 -0
  35. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lib.rs +0 -0
  36. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/lsp.rs +0 -0
  37. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/main.rs +0 -0
  38. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/new.rs +0 -0
  39. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/cloud_print.rs +0 -0
  40. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/colored_print/test.rs +0 -0
  41. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/colored_print.rs +0 -0
  42. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/interactive_print.rs +0 -0
  43. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/json_print.rs +0 -0
  44. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/print/mod.rs +0 -0
  45. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/run.rs +0 -0
  46. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/scan.rs +0 -0
  47. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/utils.rs +0 -0
  48. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/case_result.rs +0 -0
  49. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/find_file.rs +0 -0
  50. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/reporter.rs +0 -0
  51. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/snapshot.rs +0 -0
  52. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/src/verify/test_case.rs +0 -0
  53. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/tests/common/mod.rs +0 -0
  54. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/tests/run_test.rs +0 -0
  55. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/tests/scan_test.rs +0 -0
  56. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/cli/tests/verify_test.rs +0 -0
  57. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/check_var.rs +0 -0
  58. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/fixer.rs +0 -0
  59. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/lib.rs +0 -0
  60. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/maybe.rs +0 -0
  61. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/deserialize_env.rs +0 -0
  62. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/mod.rs +0 -0
  63. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/nth_child.rs +0 -0
  64. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/referent_rule.rs +0 -0
  65. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/relational_rule.rs +0 -0
  66. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule/stop_by.rs +0 -0
  67. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/rule_core.rs +0 -0
  68. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/transform/rewrite.rs +0 -0
  69. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/config/src/transform/string_case.rs +0 -0
  70. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/language.rs +0 -0
  71. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/lib.rs +0 -0
  72. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/match_tree/match_node.rs +0 -0
  73. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/match_tree/mod.rs +0 -0
  74. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/matcher/kind.rs +0 -0
  75. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/matcher/node_match.rs +0 -0
  76. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/matcher/pattern.rs +0 -0
  77. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/matcher/text.rs +0 -0
  78. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/matcher.rs +0 -0
  79. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/node.rs +0 -0
  80. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/ops.rs +0 -0
  81. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/pinned.rs +0 -0
  82. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/replacer/structural.rs +0 -0
  83. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/replacer/template.rs +0 -0
  84. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/source.rs +0 -0
  85. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/core/src/traversal.rs +0 -0
  86. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/dynamic/src/lib.rs +0 -0
  87. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/bash.rs +0 -0
  88. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/cpp.rs +0 -0
  89. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/csharp.rs +0 -0
  90. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/css.rs +0 -0
  91. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/elixir.rs +0 -0
  92. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/go.rs +0 -0
  93. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/haskell.rs +0 -0
  94. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/html.rs +0 -0
  95. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/json.rs +0 -0
  96. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/kotlin.rs +0 -0
  97. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/lua.rs +0 -0
  98. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/php.rs +0 -0
  99. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/python.rs +0 -0
  100. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/ruby.rs +0 -0
  101. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/rust.rs +0 -0
  102. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/scala.rs +0 -0
  103. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/language/src/swift.rs +0 -0
  104. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/lsp/src/lib.rs +0 -0
  105. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/lsp/src/utils.rs +0 -0
  106. {ast_grep_cli-0.26.2 → ast_grep_cli-0.27.0}/crates/lsp/tests/basic.rs +0 -0
@@ -114,7 +114,7 @@ dependencies = [
114
114
 
115
115
  [[package]]
116
116
  name = "ast-grep"
117
- version = "0.26.2"
117
+ version = "0.27.0"
118
118
  dependencies = [
119
119
  "ansi_term",
120
120
  "anyhow",
@@ -145,7 +145,7 @@ dependencies = [
145
145
 
146
146
  [[package]]
147
147
  name = "ast-grep-config"
148
- version = "0.26.2"
148
+ version = "0.27.0"
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.26.2"
164
+ version = "0.27.0"
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.26.2"
175
+ version = "0.27.0"
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.26.2"
187
+ version = "0.27.0"
188
188
  dependencies = [
189
189
  "ast-grep-core",
190
190
  "ignore",
@@ -212,16 +212,17 @@ dependencies = [
212
212
  "tree-sitter-sequel",
213
213
  "tree-sitter-swift",
214
214
  "tree-sitter-typescript",
215
+ "tree-sitter-yaml",
215
216
  ]
216
217
 
217
218
  [[package]]
218
219
  name = "ast-grep-lsp"
219
- version = "0.26.2"
220
+ version = "0.27.0"
220
221
  dependencies = [
221
222
  "ast-grep-config",
222
223
  "ast-grep-core",
223
224
  "ast-grep-language",
224
- "dashmap",
225
+ "dashmap 6.0.1",
225
226
  "serde",
226
227
  "serde_json",
227
228
  "tokio",
@@ -230,7 +231,7 @@ dependencies = [
230
231
 
231
232
  [[package]]
232
233
  name = "ast-grep-napi"
233
- version = "0.26.2"
234
+ version = "0.27.0"
234
235
  dependencies = [
235
236
  "ast-grep-config",
236
237
  "ast-grep-core",
@@ -249,7 +250,7 @@ dependencies = [
249
250
 
250
251
  [[package]]
251
252
  name = "ast-grep-py"
252
- version = "0.26.2"
253
+ version = "0.27.0"
253
254
  dependencies = [
254
255
  "anyhow",
255
256
  "ast-grep-config",
@@ -317,7 +318,7 @@ dependencies = [
317
318
 
318
319
  [[package]]
319
320
  name = "benches"
320
- version = "0.26.2"
321
+ version = "0.27.0"
321
322
  dependencies = [
322
323
  "ast-grep-config",
323
324
  "ast-grep-core",
@@ -450,9 +451,9 @@ dependencies = [
450
451
 
451
452
  [[package]]
452
453
  name = "clap_complete"
453
- version = "4.5.18"
454
+ version = "4.5.23"
454
455
  source = "registry+https://github.com/rust-lang/crates.io-index"
455
- checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03"
456
+ checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff"
456
457
  dependencies = [
457
458
  "clap",
458
459
  ]
@@ -631,6 +632,20 @@ dependencies = [
631
632
  "parking_lot_core",
632
633
  ]
633
634
 
635
+ [[package]]
636
+ name = "dashmap"
637
+ version = "6.0.1"
638
+ source = "registry+https://github.com/rust-lang/crates.io-index"
639
+ checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28"
640
+ dependencies = [
641
+ "cfg-if",
642
+ "crossbeam-utils",
643
+ "hashbrown",
644
+ "lock_api",
645
+ "once_cell",
646
+ "parking_lot_core",
647
+ ]
648
+
634
649
  [[package]]
635
650
  name = "difflib"
636
651
  version = "0.4.0"
@@ -965,7 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
965
980
  checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
966
981
  dependencies = [
967
982
  "cfg-if",
968
- "windows-targets 0.48.5",
983
+ "windows-targets 0.52.6",
969
984
  ]
970
985
 
971
986
  [[package]]
@@ -1514,18 +1529,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
1514
1529
 
1515
1530
  [[package]]
1516
1531
  name = "serde"
1517
- version = "1.0.208"
1532
+ version = "1.0.209"
1518
1533
  source = "registry+https://github.com/rust-lang/crates.io-index"
1519
- checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
1534
+ checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
1520
1535
  dependencies = [
1521
1536
  "serde_derive",
1522
1537
  ]
1523
1538
 
1524
1539
  [[package]]
1525
1540
  name = "serde_derive"
1526
- version = "1.0.208"
1541
+ version = "1.0.209"
1527
1542
  source = "registry+https://github.com/rust-lang/crates.io-index"
1528
- checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
1543
+ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
1529
1544
  dependencies = [
1530
1545
  "proc-macro2",
1531
1546
  "quote",
@@ -1545,9 +1560,9 @@ dependencies = [
1545
1560
 
1546
1561
  [[package]]
1547
1562
  name = "serde_json"
1548
- version = "1.0.125"
1563
+ version = "1.0.127"
1549
1564
  source = "registry+https://github.com/rust-lang/crates.io-index"
1550
- checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
1565
+ checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad"
1551
1566
  dependencies = [
1552
1567
  "indexmap",
1553
1568
  "itoa",
@@ -1808,7 +1823,7 @@ dependencies = [
1808
1823
  "async-trait",
1809
1824
  "auto_impl",
1810
1825
  "bytes",
1811
- "dashmap",
1826
+ "dashmap 5.5.3",
1812
1827
  "futures",
1813
1828
  "httparse",
1814
1829
  "lsp-types",
@@ -2055,9 +2070,9 @@ dependencies = [
2055
2070
 
2056
2071
  [[package]]
2057
2072
  name = "tree-sitter-php"
2058
- version = "0.22.8"
2073
+ version = "0.23.0"
2059
2074
  source = "registry+https://github.com/rust-lang/crates.io-index"
2060
- checksum = "1be890bd043986cc26b69968698e508dbd40060805e482f226dc873a63a88d60"
2075
+ checksum = "701096cc0c7c8e5c33ec0be7ea4d7aed971ee07043af5c35581c029805527ac5"
2061
2076
  dependencies = [
2062
2077
  "cc",
2063
2078
  "tree-sitter",
@@ -2133,6 +2148,16 @@ dependencies = [
2133
2148
  "tree-sitter",
2134
2149
  ]
2135
2150
 
2151
+ [[package]]
2152
+ name = "tree-sitter-yaml"
2153
+ version = "0.6.1"
2154
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2155
+ checksum = "aad27ec46ad343d8b514f64dd3fdffb478c592ece561b6c935d90ef55589c6b6"
2156
+ dependencies = [
2157
+ "cc",
2158
+ "tree-sitter",
2159
+ ]
2160
+
2136
2161
  [[package]]
2137
2162
  name = "unicode-bidi"
2138
2163
  version = "0.3.15"
@@ -7,7 +7,7 @@ resolver = "2"
7
7
  lto = true
8
8
 
9
9
  [workspace.package]
10
- version = "0.26.2"
10
+ version = "0.27.0"
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.67"
18
18
  readme = "README.md"
19
19
 
20
20
  [workspace.dependencies]
21
- ast-grep-core = { path = "crates/core", version = "0.26.2" }
22
- ast-grep-config = { path = "crates/config", version = "0.26.2" }
23
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.26.2" }
24
- ast-grep-language = { path = "crates/language", version = "0.26.2" }
25
- ast-grep-lsp = { path = "crates/lsp", version = "0.26.2" }
21
+ ast-grep-core = { path = "crates/core", version = "0.27.0" }
22
+ ast-grep-config = { path = "crates/config", version = "0.27.0" }
23
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.27.0" }
24
+ ast-grep-language = { path = "crates/language", version = "0.27.0" }
25
+ ast-grep-lsp = { path = "crates/lsp", version = "0.27.0" }
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.3
2
2
  Name: ast-grep-cli
3
- Version: 0.26.2
3
+ Version: 0.27.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -224,12 +224,12 @@ rule:
224
224
  }
225
225
  fn always_report_rule() -> RuleCollection<SgLang> {
226
226
  // empty all should mean always
227
- let rule = get_rule_config("all: []");
227
+ let rule = get_rule_config("all: [kind: number]");
228
228
  RuleCollection::try_new(vec![rule]).expect("RuleCollection must be valid")
229
229
  }
230
230
  fn never_report_rule() -> RuleCollection<SgLang> {
231
231
  // empty any should mean never
232
- let rule = get_rule_config("any: []");
232
+ let rule = get_rule_config("any: [kind: string]");
233
233
  RuleCollection::try_new(vec![rule]).expect("RuleCollection must be valid")
234
234
  }
235
235
 
@@ -26,4 +26,4 @@ thiserror.workspace = true
26
26
  schemars.workspace = true
27
27
 
28
28
  [dev-dependencies]
29
- tree-sitter-typescript = "0.21.1"
29
+ tree-sitter-typescript = "0.21.1"
@@ -97,11 +97,11 @@ impl<'r, L: Language> CombinedScan<'r, L> {
97
97
  rules.sort_unstable_by_key(|r| (r.fix.is_some(), &r.id));
98
98
  let mut mapping = Vec::new();
99
99
  for (idx, rule) in rules.iter().enumerate() {
100
- for kind in &rule
101
- .matcher
102
- .potential_kinds()
103
- .unwrap_or_else(|| panic!("rule `{}` must have kind", &rule.id))
104
- {
100
+ let Some(kinds) = rule.matcher.potential_kinds() else {
101
+ eprintln!("rule `{}` must have kind", &rule.id);
102
+ continue;
103
+ };
104
+ for kind in &kinds {
105
105
  // NOTE: common languages usually have about several hundred kinds
106
106
  // from 200+ ~ 500+, it is okay to waste about 500 * 24 Byte vec size = 12kB
107
107
  // see https://github.com/Wilfred/difftastic/tree/master/vendored_parsers
@@ -178,7 +178,7 @@ message: test rule
178
178
  severity: info
179
179
  language: Tsx
180
180
  rule:
181
- all: []
181
+ all: [kind: number]
182
182
  {files}"
183
183
  ),
184
184
  &globals,
@@ -7,7 +7,7 @@ use crate::rule_core::{RuleCore, RuleCoreError, SerializableRuleCore};
7
7
 
8
8
  use ast_grep_core::language::Language;
9
9
  use ast_grep_core::replacer::Replacer;
10
- use ast_grep_core::{NodeMatch, StrDoc};
10
+ use ast_grep_core::{Matcher, NodeMatch, StrDoc};
11
11
 
12
12
  use schemars::JsonSchema;
13
13
  use serde::{Deserialize, Serialize};
@@ -46,6 +46,8 @@ pub enum RuleConfigError {
46
46
  UndefinedRewriter(String),
47
47
  #[error("Rewriter rule `{0}` should have `fix`.")]
48
48
  NoFixInRewriter(String),
49
+ #[error("Rule must specify a set of AST kinds to match. Try adding `kind` rule.")]
50
+ MissingPotentialKinds,
49
51
  }
50
52
 
51
53
  #[derive(Serialize, Deserialize, Clone, JsonSchema)]
@@ -166,6 +168,9 @@ impl<L: Language> RuleConfig<L> {
166
168
  globals: &GlobalRules<L>,
167
169
  ) -> Result<Self, RuleConfigError> {
168
170
  let matcher = inner.get_matcher(globals)?;
171
+ if matcher.potential_kinds().is_none() {
172
+ return Err(RuleConfigError::MissingPotentialKinds);
173
+ }
169
174
  Ok(Self { inner, matcher })
170
175
  }
171
176
 
@@ -118,4 +118,30 @@ mod test {
118
118
  let ret = Transform::deserialize(&trans, &env);
119
119
  assert!(ret.is_ok());
120
120
  }
121
+
122
+ #[test]
123
+ fn test_transform_indentation() {
124
+ let src = "
125
+ if (true) {
126
+ let a = {
127
+ b: 123
128
+ }
129
+ }
130
+ ";
131
+ let expected = "{
132
+ b: 123
133
+ }";
134
+ let mut trans = HashMap::new();
135
+ let tr = from_str("{ substring: { source: $A } }").expect("should work");
136
+ trans.insert("TR".into(), tr);
137
+ let grep = TypeScript::Tsx.ast_grep(src);
138
+ let root = grep.root();
139
+ let mut nm = root.find("let a = $A").expect("should find");
140
+ let env = DeserializeEnv::new(TypeScript::Tsx);
141
+ let trans = Transform::deserialize(&trans, &env).expect("should deserialize");
142
+ trans.apply_transform(nm.get_env_mut(), &Default::default(), &Default::default());
143
+ let actual = nm.get_env().get_transformed("TR").expect("should have TR");
144
+ let actual = std::str::from_utf8(actual).expect("should work");
145
+ assert_eq!(actual, expected);
146
+ }
121
147
  }
@@ -109,6 +109,18 @@ pub enum Transformation<T> {
109
109
  Rewrite(Rewrite<T>),
110
110
  }
111
111
 
112
+ impl<T> Transformation<T> {
113
+ fn source(&self) -> &T {
114
+ use Transformation as T;
115
+ match self {
116
+ T::Replace(r) => &r.source,
117
+ T::Substring(s) => &s.source,
118
+ T::Convert(c) => &c.source,
119
+ T::Rewrite(r) => &r.source,
120
+ }
121
+ }
122
+ }
123
+
112
124
  pub(crate) fn parse_meta_var<L: Language>(
113
125
  src: &str,
114
126
  lang: &L,
@@ -148,38 +160,25 @@ impl Transformation<String> {
148
160
  }
149
161
 
150
162
  pub fn used_vars(&self) -> &str {
151
- fn strip(s: &str) -> &str {
152
- s.strip_prefix("$$$").unwrap_or_else(|| &s[1..])
153
- // match s {
154
- // MetaVariable::Capture(s, _) => s,
155
- // MetaVariable::Dropped(_) => "",
156
- // MetaVariable::MultiCapture(s) => s,
157
- // MetaVariable::Multiple => "",
158
- // }
159
- }
160
- use Transformation as T;
161
163
  // NOTE: meta_var in transform always starts with `$`, for now
162
- match self {
163
- T::Replace(r) => strip(&r.source),
164
- T::Substring(s) => strip(&s.source),
165
- T::Convert(c) => strip(&c.source),
166
- T::Rewrite(r) => strip(&r.source),
167
- }
164
+ let s = self.source();
165
+ s.strip_prefix("$$$").unwrap_or_else(|| &s[1..])
168
166
  }
169
167
  }
170
168
  impl Transformation<MetaVariable> {
171
169
  pub(super) fn insert<D: Doc>(&self, key: &str, ctx: &mut Ctx<D>) {
170
+ let src = self.source();
172
171
  // TODO: add this debug assertion back
173
172
  // debug_assert!(ctx.env.get_transformed(key).is_none());
174
173
  // avoid cyclic
175
- ctx.env.insert_transformation(key, vec![]);
174
+ ctx.env.insert_transformation(src, key, vec![]);
176
175
  let opt = self.compute(ctx);
177
176
  let bytes = if let Some(s) = opt {
178
177
  <D::Source as Content>::decode_str(&s).to_vec()
179
178
  } else {
180
179
  vec![]
181
180
  };
182
- ctx.env.insert_transformation(key, bytes);
181
+ ctx.env.insert_transformation(src, key, bytes);
183
182
  }
184
183
  fn compute<D: Doc>(&self, ctx: &mut Ctx<D>) -> Option<String> {
185
184
  use Transformation as T;
@@ -436,5 +435,25 @@ mod test {
436
435
  assert_eq!(actual, "camelcase_not");
437
436
  Ok(())
438
437
  }
438
+
439
+ #[test]
440
+ fn test_transform_indentation_with_insertion() -> R {
441
+ let src = "
442
+ if (true) {
443
+ let a = {
444
+ b: 123
445
+ }
446
+ }
447
+ ";
448
+ // note the indentation
449
+ let expected = "{
450
+ b: 123
451
+ }";
452
+ let tr = parse("{ substring: { source: $A } }")?;
453
+ let actual = get_transformed(src, "let a = $A", &tr).ok_or(())?;
454
+ assert_eq!(actual, expected);
455
+ Ok(())
456
+ }
457
+
439
458
  // TODO: add a symbolic test for Rewrite
440
459
  }
@@ -23,4 +23,4 @@ tree-sitter.workspace = true
23
23
  default = ["regex"]
24
24
 
25
25
  [dev-dependencies]
26
- tree-sitter-typescript = "0.21.1"
26
+ tree-sitter-typescript = "0.21.1"
@@ -39,7 +39,10 @@ impl MatchStrictness {
39
39
  ) -> MatchOneNode {
40
40
  use MatchStrictness as M;
41
41
  let k = candidate.kind_id();
42
- if k == kind && text == candidate.text() {
42
+ // work around ast-grep/ast-grep#1419 and tree-sitter/tree-sitter-typescript#306
43
+ // tree-sitter-typescript has wrong span of unnamed node so text would not match
44
+ // just compare kind for unnamed node
45
+ if k == kind && (!is_named || text == candidate.text()) {
43
46
  return MatchOneNode::MatchedBoth;
44
47
  }
45
48
  let (skip_goal, skip_candidate) = match self {
@@ -5,6 +5,8 @@ use crate::{Doc, Language, Node, StrDoc};
5
5
  use std::borrow::Cow;
6
6
  use std::collections::HashMap;
7
7
 
8
+ use crate::replacer::formatted_slice;
9
+
8
10
  pub type MetaVariableID = String;
9
11
 
10
12
  type Underlying<D> = Vec<<<D as Doc>::Source as Content>::Underlying>;
@@ -44,8 +46,18 @@ impl<'tree, D: Doc> MetaVarEnv<'tree, D> {
44
46
  }
45
47
  }
46
48
 
47
- pub fn insert_transformation(&mut self, name: &str, src: Underlying<D>) {
48
- self.transformed_var.insert(name.to_string(), src);
49
+ pub fn insert_transformation(&mut self, var: &MetaVariable, name: &str, slice: Underlying<D>) {
50
+ let node = match var {
51
+ MetaVariable::Capture(v, _) => self.single_matched.get(v),
52
+ MetaVariable::MultiCapture(vs) => self.multi_matched.get(vs).and_then(|vs| vs.first()),
53
+ _ => None,
54
+ };
55
+ let deindented = if let Some(v) = node {
56
+ formatted_slice(&slice, v.root.doc.get_source(), v.range().start).to_vec()
57
+ } else {
58
+ slice
59
+ };
60
+ self.transformed_var.insert(name.to_string(), deindented);
49
61
  }
50
62
 
51
63
  pub fn get_match(&self, var: &str) -> Option<&'_ Node<'tree, D>> {
@@ -146,6 +146,27 @@ pub fn extract_with_deindent<C: Content>(content: &C, range: Range<usize>) -> De
146
146
  DeindentedExtract::MultiLine(extract_slice, indent)
147
147
  }
148
148
 
149
+ fn deindent_slice<'a, C: Content>(
150
+ slice: &'a [C::Underlying],
151
+ content: &'a C,
152
+ start: usize,
153
+ ) -> DeindentedExtract<'a, C> {
154
+ if !slice.contains(&get_new_line::<C>()) {
155
+ return DeindentedExtract::SingleLine(slice);
156
+ }
157
+ let indent = get_indent_at_offset::<C>(content.get_range(0..start));
158
+ DeindentedExtract::MultiLine(slice, indent)
159
+ }
160
+
161
+ pub fn formatted_slice<'a, C: Content>(
162
+ slice: &'a [C::Underlying],
163
+ content: &'a C,
164
+ start: usize,
165
+ ) -> Cow<'a, [C::Underlying]> {
166
+ let deindent = deindent_slice(slice, content, start);
167
+ indent_lines(0, deindent)
168
+ }
169
+
149
170
  pub fn indent_lines<C: Content>(
150
171
  indent: usize,
151
172
  extract: DeindentedExtract<C>,
@@ -4,6 +4,8 @@ use crate::source::Edit as E;
4
4
  use crate::{Doc, Node, Root};
5
5
  use std::ops::Range;
6
6
 
7
+ pub(crate) use indent::formatted_slice;
8
+
7
9
  type Edit<D> = E<<D as Doc>::Source>;
8
10
  type Underlying<S> = Vec<<S as Content>::Underlying>;
9
11
 
@@ -17,4 +17,4 @@ ignore.workspace = true
17
17
  libloading = "0.8.3"
18
18
  serde.workspace = true
19
19
  thiserror.workspace = true
20
- tree-sitter-native = { version = "0.22.6", package = "tree-sitter" }
20
+ tree-sitter-native = { version = "0.22.6", package = "tree-sitter" }
@@ -31,7 +31,7 @@ tree-sitter-javascript = { version = "0.21.3", optional = true }
31
31
  tree-sitter-json = { version = "0.21.0", optional = true }
32
32
  tree-sitter-kotlin = { version = "0.3.6", optional = true }
33
33
  tree-sitter-lua = { version = "0.1.0", optional = true }
34
- tree-sitter-php = { version = "0.22.4", optional = true }
34
+ tree-sitter-php = { version = "0.23.0", optional = true }
35
35
  tree-sitter-python = { version = "0.21.0", optional = true }
36
36
  tree-sitter-ruby = { version = "0.21.0", optional = true }
37
37
  tree-sitter-rust = { version = "0.21.2", optional = true }
@@ -39,6 +39,7 @@ tree-sitter-scala = { version = "0.22.0", optional = true }
39
39
  tree-sitter-sequel = { version = "0.3.3", optional = true }
40
40
  tree-sitter-swift = { version = "=0.5.0", optional = true }
41
41
  tree-sitter-typescript= { version = "0.21.1", optional = true }
42
+ tree-sitter-yaml = { version = "0.6.1", optional = true }
42
43
 
43
44
  [features]
44
45
  builtin-parser = [
@@ -65,5 +66,6 @@ builtin-parser = [
65
66
  "tree-sitter-sequel",
66
67
  "tree-sitter-swift",
67
68
  "tree-sitter-typescript",
69
+ "tree-sitter-yaml",
68
70
  ]
69
- default = ["builtin-parser"]
71
+ default = ["builtin-parser"]
@@ -25,6 +25,7 @@ mod ruby;
25
25
  mod rust;
26
26
  mod scala;
27
27
  mod swift;
28
+ mod yaml;
28
29
 
29
30
  pub use html::Html;
30
31
 
@@ -193,6 +194,7 @@ impl_lang!(Php, language_php);
193
194
  impl_lang!(Scala, language_scala);
194
195
  impl_lang!(Tsx, language_tsx);
195
196
  impl_lang!(TypeScript, language_typescript);
197
+ impl_lang!(Yaml, language_yaml);
196
198
  // See ripgrep for extensions
197
199
  // https://github.com/BurntSushi/ripgrep/blob/master/crates/ignore/src/default_types.rs
198
200
 
@@ -223,6 +225,7 @@ pub enum SupportLang {
223
225
  Swift,
224
226
  Tsx,
225
227
  TypeScript,
228
+ Yaml,
226
229
  }
227
230
 
228
231
  impl SupportLang {
@@ -230,7 +233,7 @@ impl SupportLang {
230
233
  use SupportLang::*;
231
234
  &[
232
235
  Bash, C, Cpp, CSharp, Css, Dart, Elixir, Go, Haskell, Html, Java, JavaScript, Json, Kotlin,
233
- Lua, Php, Python, Ruby, Rust, Scala, Sql, Swift, Tsx, TypeScript,
236
+ Lua, Php, Python, Ruby, Rust, Scala, Sql, Swift, Tsx, TypeScript, Yaml,
234
237
  ]
235
238
  }
236
239
 
@@ -335,6 +338,7 @@ impl_aliases! {
335
338
  Swift => &["swift"],
336
339
  TypeScript => &["ts", "typescript"],
337
340
  Tsx => &["tsx"],
341
+ Yaml => &["yaml", "yml"],
338
342
  }
339
343
 
340
344
  /// Implements the language names and aliases.
@@ -380,6 +384,7 @@ macro_rules! execute_lang_method {
380
384
  S::Swift => Swift.$method($($pname,)*),
381
385
  S::Tsx => Tsx.$method($($pname,)*),
382
386
  S::TypeScript => TypeScript.$method($($pname,)*),
387
+ S::Yaml => Yaml.$method($($pname,)*),
383
388
  }
384
389
  }
385
390
  }
@@ -445,6 +450,7 @@ fn extensions(lang: SupportLang) -> &'static [&'static str] {
445
450
  Swift => &["swift"],
446
451
  TypeScript => &["ts", "cts", "mts"],
447
452
  Tsx => &["tsx"],
453
+ Yaml => &["yaml", "yml"],
448
454
  }
449
455
  }
450
456
 
@@ -80,6 +80,9 @@ mod parser_implementation {
80
80
  pub fn language_typescript() -> TSLanguage {
81
81
  tree_sitter_typescript::language_typescript().into()
82
82
  }
83
+ pub fn language_yaml() -> TSLanguage {
84
+ tree_sitter_yaml::language().into()
85
+ }
83
86
  }
84
87
 
85
88
  #[cfg(not(feature = "builtin-parser"))]
@@ -126,6 +129,7 @@ mod parser_implementation {
126
129
  language_swift,
127
130
  language_tsx,
128
131
  language_typescript,
132
+ language_yaml,
129
133
  );
130
134
  }
131
135
 
@@ -0,0 +1,60 @@
1
+ #![cfg(test)]
2
+ use ast_grep_core::source::TSParseError;
3
+
4
+ use super::*;
5
+
6
+ fn test_match(query: &str, source: &str) {
7
+ use crate::test::test_match_lang;
8
+ test_match_lang(query, source, Yaml);
9
+ }
10
+
11
+ fn test_non_match(query: &str, source: &str) {
12
+ use crate::test::test_non_match_lang;
13
+ test_non_match_lang(query, source, Yaml);
14
+ }
15
+
16
+ #[test]
17
+ fn test_yaml_str() {
18
+ test_match("123", "123");
19
+ test_non_match("123", "'123'");
20
+ // the pattern below should not match but match now
21
+ // test_non_match("\"123\"", "\"456\"");
22
+ }
23
+
24
+ #[test]
25
+ fn test_yaml_pattern() {
26
+ test_match("foo: $BAR", "foo: 123");
27
+ test_match("foo: $$$", "foo: [1, 2, 3]");
28
+ test_match(
29
+ "foo: $BAR",
30
+ "foo:
31
+ - a
32
+ ",
33
+ );
34
+ test_non_match("foo: $BAR", "bar: bar");
35
+ }
36
+
37
+ fn test_replace(src: &str, pattern: &str, replacer: &str) -> Result<String, TSParseError> {
38
+ use crate::test::test_replace_lang;
39
+ test_replace_lang(src, pattern, replacer, Yaml)
40
+ }
41
+
42
+ const SOURCE: &str = r#"
43
+ key: value
44
+ list:
45
+ - item1
46
+ - item2
47
+ "#;
48
+ const EXPECTED: &str = r#"
49
+ value: key
50
+ list:
51
+ - item1
52
+ - item2
53
+ "#;
54
+
55
+ #[test]
56
+ fn test_yaml_replace() -> Result<(), TSParseError> {
57
+ let ret = test_replace(SOURCE, "$KEY: value", "value: $KEY")?;
58
+ assert_eq!(ret, EXPECTED);
59
+ Ok(())
60
+ }
@@ -22,7 +22,7 @@ ast-grep-config.workspace = true
22
22
  serde.workspace = true
23
23
 
24
24
  serde_json = "1.0.116"
25
- dashmap = "5.5.3"
25
+ dashmap = "6.0.0"
26
26
  tower-lsp = "0.20.0"
27
27
 
28
28
  [dev-dependencies]
@@ -31,4 +31,4 @@ tokio = { version = "1.37.0", features = [
31
31
  "rt-multi-thread",
32
32
  "io-std",
33
33
  "io-util",
34
- ] }
34
+ ] }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "ast-grep-cli"
7
- version = "0.26.2"
7
+ version = "0.27.0"
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