ast-grep-cli 0.13.0__tar.gz → 0.13.2__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 (87) hide show
  1. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/Cargo.lock +30 -40
  2. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/Cargo.toml +7 -7
  3. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/PKG-INFO +1 -1
  4. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/Cargo.toml +1 -1
  5. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/completions.rs +1 -1
  6. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/config.rs +4 -2
  7. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/new.rs +1 -1
  8. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/colored_print/test.rs +12 -6
  9. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/colored_print.rs +13 -54
  10. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/interactive_print.rs +1 -1
  11. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/case_result.rs +1 -1
  12. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/mod.rs +2 -2
  13. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/snapshot.rs +4 -1
  14. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/meta_var.rs +2 -2
  15. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/traversal.rs +5 -1
  16. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/lib.rs +1 -0
  17. ast_grep_cli-0.13.2/crates/language/src/ruby.rs +34 -0
  18. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/pyproject.toml +1 -1
  19. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/LICENSE +0 -0
  20. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/README.md +0 -0
  21. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/bin/ast-grep.rs +0 -0
  22. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/error.rs +0 -0
  23. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/lang.rs +0 -0
  24. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/lib.rs +0 -0
  25. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/lsp.rs +0 -0
  26. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/main.rs +0 -0
  27. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/cloud_print.rs +0 -0
  28. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/json_print.rs +0 -0
  29. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/print/mod.rs +0 -0
  30. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/run.rs +0 -0
  31. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/scan.rs +0 -0
  32. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/utils.rs +0 -0
  33. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/find_file.rs +0 -0
  34. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/reporter.rs +0 -0
  35. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/src/verify/test_case.rs +0 -0
  36. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/tests/common/mod.rs +0 -0
  37. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/tests/run_test.rs +0 -0
  38. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/tests/scan_test.rs +0 -0
  39. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/cli/tests/verify_test.rs +0 -0
  40. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/Cargo.toml +0 -0
  41. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/combined.rs +0 -0
  42. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/constraints.rs +0 -0
  43. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/deserialize_env.rs +0 -0
  44. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/lib.rs +0 -0
  45. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/maybe.rs +0 -0
  46. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/referent_rule.rs +0 -0
  47. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/relational_rule/mod.rs +0 -0
  48. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/relational_rule/stop_by.rs +0 -0
  49. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/rule.rs +0 -0
  50. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/rule_collection.rs +0 -0
  51. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/rule_config.rs +0 -0
  52. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/string_case.rs +0 -0
  53. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/config/src/transform.rs +0 -0
  54. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/Cargo.toml +0 -0
  55. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/language.rs +0 -0
  56. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/lib.rs +0 -0
  57. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/match_tree.rs +0 -0
  58. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/matcher/kind.rs +0 -0
  59. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/matcher/node_match.rs +0 -0
  60. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/matcher/pattern.rs +0 -0
  61. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/matcher/text.rs +0 -0
  62. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/matcher.rs +0 -0
  63. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/node.rs +0 -0
  64. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/ops.rs +0 -0
  65. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/pinned.rs +0 -0
  66. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/replacer/indent.rs +0 -0
  67. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/replacer/structural.rs +0 -0
  68. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/replacer/template.rs +0 -0
  69. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/replacer.rs +0 -0
  70. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/core/src/source.rs +0 -0
  71. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/dynamic/Cargo.toml +0 -0
  72. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/dynamic/src/lib.rs +0 -0
  73. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/Cargo.toml +0 -0
  74. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/cpp.rs +0 -0
  75. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/csharp.rs +0 -0
  76. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/css.rs +0 -0
  77. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/go.rs +0 -0
  78. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/json.rs +0 -0
  79. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/kotlin.rs +0 -0
  80. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/lua.rs +0 -0
  81. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/parsers.rs +0 -0
  82. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/python.rs +0 -0
  83. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/rust.rs +0 -0
  84. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/scala.rs +0 -0
  85. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/language/src/swift.rs +0 -0
  86. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/lsp/Cargo.toml +0 -0
  87. {ast_grep_cli-0.13.0 → ast_grep_cli-0.13.2}/crates/lsp/src/lib.rs +0 -0
@@ -97,7 +97,7 @@ dependencies = [
97
97
 
98
98
  [[package]]
99
99
  name = "ast-grep"
100
- version = "0.13.0"
100
+ version = "0.13.2"
101
101
  dependencies = [
102
102
  "ansi_term",
103
103
  "anyhow",
@@ -128,7 +128,7 @@ dependencies = [
128
128
 
129
129
  [[package]]
130
130
  name = "ast-grep-config"
131
- version = "0.13.0"
131
+ version = "0.13.2"
132
132
  dependencies = [
133
133
  "anyhow",
134
134
  "ast-grep-core",
@@ -145,7 +145,7 @@ dependencies = [
145
145
 
146
146
  [[package]]
147
147
  name = "ast-grep-core"
148
- version = "0.13.0"
148
+ version = "0.13.2"
149
149
  dependencies = [
150
150
  "bit-set",
151
151
  "regex",
@@ -156,11 +156,11 @@ dependencies = [
156
156
 
157
157
  [[package]]
158
158
  name = "ast-grep-dynamic"
159
- version = "0.13.0"
159
+ version = "0.13.2"
160
160
  dependencies = [
161
161
  "ast-grep-core",
162
162
  "ignore",
163
- "libloading 0.8.0",
163
+ "libloading",
164
164
  "serde",
165
165
  "thiserror",
166
166
  "tree-sitter",
@@ -168,7 +168,7 @@ dependencies = [
168
168
 
169
169
  [[package]]
170
170
  name = "ast-grep-language"
171
- version = "0.13.0"
171
+ version = "0.13.2"
172
172
  dependencies = [
173
173
  "ast-grep-core",
174
174
  "ast-grep-tree-sitter-c-sharp",
@@ -196,7 +196,7 @@ dependencies = [
196
196
 
197
197
  [[package]]
198
198
  name = "ast-grep-lsp"
199
- version = "0.13.0"
199
+ version = "0.13.2"
200
200
  dependencies = [
201
201
  "ast-grep-config",
202
202
  "ast-grep-core",
@@ -211,7 +211,7 @@ dependencies = [
211
211
 
212
212
  [[package]]
213
213
  name = "ast-grep-napi"
214
- version = "0.13.0"
214
+ version = "0.13.2"
215
215
  dependencies = [
216
216
  "ast-grep-config",
217
217
  "ast-grep-core",
@@ -229,8 +229,8 @@ dependencies = [
229
229
  ]
230
230
 
231
231
  [[package]]
232
- name = "ast-grep-pyo3"
233
- version = "0.13.0"
232
+ name = "ast-grep-py"
233
+ version = "0.13.2"
234
234
  dependencies = [
235
235
  "anyhow",
236
236
  "ast-grep-config",
@@ -293,7 +293,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
293
293
 
294
294
  [[package]]
295
295
  name = "benches"
296
- version = "0.13.0"
296
+ version = "0.13.2"
297
297
  dependencies = [
298
298
  "ast-grep-config",
299
299
  "ast-grep-core",
@@ -401,9 +401,9 @@ dependencies = [
401
401
 
402
402
  [[package]]
403
403
  name = "clap"
404
- version = "4.4.7"
404
+ version = "4.4.8"
405
405
  source = "registry+https://github.com/rust-lang/crates.io-index"
406
- checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b"
406
+ checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64"
407
407
  dependencies = [
408
408
  "clap_builder",
409
409
  "clap_derive",
@@ -411,9 +411,9 @@ dependencies = [
411
411
 
412
412
  [[package]]
413
413
  name = "clap_builder"
414
- version = "4.4.7"
414
+ version = "4.4.8"
415
415
  source = "registry+https://github.com/rust-lang/crates.io-index"
416
- checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663"
416
+ checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
417
417
  dependencies = [
418
418
  "anstream",
419
419
  "anstyle",
@@ -954,16 +954,6 @@ version = "0.2.140"
954
954
  source = "registry+https://github.com/rust-lang/crates.io-index"
955
955
  checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
956
956
 
957
- [[package]]
958
- name = "libloading"
959
- version = "0.7.3"
960
- source = "registry+https://github.com/rust-lang/crates.io-index"
961
- checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
962
- dependencies = [
963
- "cfg-if",
964
- "winapi",
965
- ]
966
-
967
957
  [[package]]
968
958
  name = "libloading"
969
959
  version = "0.8.0"
@@ -1056,9 +1046,9 @@ dependencies = [
1056
1046
 
1057
1047
  [[package]]
1058
1048
  name = "napi"
1059
- version = "2.13.3"
1049
+ version = "2.14.0"
1060
1050
  source = "registry+https://github.com/rust-lang/crates.io-index"
1061
- checksum = "fd063c93b900149304e3ba96ce5bf210cd4f81ef5eb80ded0d100df3e85a3ac0"
1051
+ checksum = "f9d90182620f32fe34b6ac9b52cba898af26e94c7f5abc01eb4094c417ae2e6c"
1062
1052
  dependencies = [
1063
1053
  "anyhow",
1064
1054
  "bitflags 2.3.3",
@@ -1078,9 +1068,9 @@ checksum = "882a73d9ef23e8dc2ebbffb6a6ae2ef467c0f18ac10711e4cc59c5485d41df0e"
1078
1068
 
1079
1069
  [[package]]
1080
1070
  name = "napi-derive"
1081
- version = "2.13.0"
1071
+ version = "2.14.1"
1082
1072
  source = "registry+https://github.com/rust-lang/crates.io-index"
1083
- checksum = "da1c6a8fa84d549aa8708fcd062372bf8ec6e849de39016ab921067d21bde367"
1073
+ checksum = "3619fa472d23cd5af94d63a2bae454a77a8863251f40230fbf59ce20eafa8a86"
1084
1074
  dependencies = [
1085
1075
  "cfg-if",
1086
1076
  "convert_case",
@@ -1092,9 +1082,9 @@ dependencies = [
1092
1082
 
1093
1083
  [[package]]
1094
1084
  name = "napi-derive-backend"
1095
- version = "1.0.52"
1085
+ version = "1.0.54"
1096
1086
  source = "registry+https://github.com/rust-lang/crates.io-index"
1097
- checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17"
1087
+ checksum = "ecd3ea4b54020c73d591a49cd192f6334c5f37f71a63ead54dbc851fa991ef00"
1098
1088
  dependencies = [
1099
1089
  "convert_case",
1100
1090
  "once_cell",
@@ -1107,11 +1097,11 @@ dependencies = [
1107
1097
 
1108
1098
  [[package]]
1109
1099
  name = "napi-sys"
1110
- version = "2.2.3"
1100
+ version = "2.3.0"
1111
1101
  source = "registry+https://github.com/rust-lang/crates.io-index"
1112
- checksum = "166b5ef52a3ab5575047a9fe8d4a030cdd0f63c96f071cd6907674453b07bae3"
1102
+ checksum = "2503fa6af34dc83fb74888df8b22afe933b58d37daf7d80424b1c60c68196b8b"
1113
1103
  dependencies = [
1114
- "libloading 0.7.3",
1104
+ "libloading",
1115
1105
  ]
1116
1106
 
1117
1107
  [[package]]
@@ -1537,9 +1527,9 @@ dependencies = [
1537
1527
 
1538
1528
  [[package]]
1539
1529
  name = "schemars"
1540
- version = "0.8.15"
1530
+ version = "0.8.16"
1541
1531
  source = "registry+https://github.com/rust-lang/crates.io-index"
1542
- checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c"
1532
+ checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29"
1543
1533
  dependencies = [
1544
1534
  "dyn-clone",
1545
1535
  "schemars_derive",
@@ -1549,9 +1539,9 @@ dependencies = [
1549
1539
 
1550
1540
  [[package]]
1551
1541
  name = "schemars_derive"
1552
- version = "0.8.15"
1542
+ version = "0.8.16"
1553
1543
  source = "registry+https://github.com/rust-lang/crates.io-index"
1554
- checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c"
1544
+ checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967"
1555
1545
  dependencies = [
1556
1546
  "proc-macro2",
1557
1547
  "quote",
@@ -1838,9 +1828,9 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
1838
1828
 
1839
1829
  [[package]]
1840
1830
  name = "toml_edit"
1841
- version = "0.20.7"
1831
+ version = "0.21.0"
1842
1832
  source = "registry+https://github.com/rust-lang/crates.io-index"
1843
- checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
1833
+ checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
1844
1834
  dependencies = [
1845
1835
  "indexmap",
1846
1836
  "toml_datetime",
@@ -6,7 +6,7 @@ default-members = ["crates/*"]
6
6
  lto = true
7
7
 
8
8
  [workspace.package]
9
- version = "0.13.0"
9
+ version = "0.13.2"
10
10
  authors = ["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"]
11
11
  edition = "2021"
12
12
  license = "MIT"
@@ -17,11 +17,11 @@ rust-version = "1.63"
17
17
  readme = "README.md"
18
18
 
19
19
  [workspace.dependencies]
20
- ast-grep-core = { path = "crates/core", version = "0.13.0" }
21
- ast-grep-config = { path = "crates/config", version = "0.13.0" }
22
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.13.0" }
23
- ast-grep-language = { path = "crates/language", version = "0.13.0" }
24
- ast-grep-lsp = { path = "crates/lsp", version = "0.13.0" }
20
+ ast-grep-core = { path = "crates/core", version = "0.13.2" }
21
+ ast-grep-config = { path = "crates/config", version = "0.13.2" }
22
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.13.2" }
23
+ ast-grep-language = { path = "crates/language", version = "0.13.2" }
24
+ ast-grep-lsp = { path = "crates/lsp", version = "0.13.2" }
25
25
 
26
26
  bit-set = { version = "0.5.3" }
27
27
  ignore = { version = "0.4.20" }
@@ -29,5 +29,5 @@ regex = { version = "1.10.2" }
29
29
  serde = { version = "1.0", features = ["derive"] }
30
30
  tree-sitter = { version = "0.9.2", package = "tree-sitter-facade-sg" }
31
31
  thiserror = "1.0.50"
32
- schemars = "0.8.15"
32
+ schemars = "0.8.16"
33
33
  anyhow = "1.0.75"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ast-grep-cli
3
- Version: 0.13.0
3
+ Version: 0.13.2
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -35,7 +35,7 @@ ast-grep-lsp.workspace = true
35
35
  ansi_term = "0.12"
36
36
  anyhow.workspace = true
37
37
  atty = "0.2.14"
38
- clap = { version = "4.4.7", features = ["derive"] }
38
+ clap = { version = "4.4.8", features = ["derive"] }
39
39
  codespan-reporting = "0.11.1"
40
40
  crossterm = "0.27.0"
41
41
  ignore.workspace = true
@@ -49,7 +49,7 @@ fn run_shell_completion_impl<C: CommandFactory, W: io::Write>(
49
49
  output: &mut W,
50
50
  ) -> Result<()> {
51
51
  let Some(shell) = arg.shell.or_else(Shell::from_env) else {
52
- return Err(anyhow::anyhow!(EC::CannotInferShell))
52
+ return Err(anyhow::anyhow!(EC::CannotInferShell));
53
53
  };
54
54
  let mut cmd = C::command();
55
55
  let cmd_name = match get_bin_name() {
@@ -68,7 +68,9 @@ pub fn register_custom_language(config_path: Option<PathBuf>) {
68
68
  let Ok(mut path) = find_config_path_with_default(config_path, None) else {
69
69
  return;
70
70
  };
71
- let Ok(config_str) = read_to_string(&path) else { return };
71
+ let Ok(config_str) = read_to_string(&path) else {
72
+ return;
73
+ };
72
74
  let sg_config: AstGrepConfig = from_str(&config_str).unwrap();
73
75
  path.pop();
74
76
  if let Some(custom_langs) = sg_config.custom_languages {
@@ -81,7 +83,7 @@ fn find_util_rules(
81
83
  util_dirs: Option<Vec<PathBuf>>,
82
84
  ) -> Result<GlobalRules<SgLang>> {
83
85
  let Some(util_dirs) = util_dirs else {
84
- return Ok(GlobalRules::default())
86
+ return Ok(GlobalRules::default());
85
87
  };
86
88
  let mut utils = vec![];
87
89
  // TODO: use WalkBuilder::add to avoid loop
@@ -268,7 +268,7 @@ invalid:
268
268
 
269
269
  fn create_new_test(test_configs: Option<Vec<TestConfig>>, name: Option<String>) -> Result<()> {
270
270
  let Some(tests) = test_configs else {
271
- return Err(anyhow::anyhow!(EC::NoTestDirConfigured))
271
+ return Err(anyhow::anyhow!(EC::NoTestDirConfigured));
272
272
  };
273
273
  if tests.is_empty() {
274
274
  return Err(anyhow::anyhow!(EC::NoTestDirConfigured));
@@ -6,6 +6,8 @@ use ast_grep_core::replacer::Fixer;
6
6
  use ast_grep_language::{Language, SupportLang};
7
7
  use codespan_reporting::term::termcolor::Buffer;
8
8
 
9
+ use std::fmt::Write;
10
+
9
11
  fn make_test_printer() -> ColoredPrinter<Buffer> {
10
12
  ColoredPrinter::new(Buffer::no_color()).color(ColorChoice::Never)
11
13
  }
@@ -49,11 +51,13 @@ fn test_print_matches() {
49
51
  let grep = SgLang::from(SupportLang::Tsx).ast_grep(source);
50
52
  let matches = grep.root().find_all(pattern);
51
53
  printer.print_matches(matches, "test.tsx".as_ref()).unwrap();
52
- let expected: String = source
54
+ let expected = source
53
55
  .lines()
54
56
  .enumerate()
55
- .map(|(i, l)| format!("{}│{l}\n", i + 1))
56
- .collect();
57
+ .fold(String::new(), |mut b, (i, l)| {
58
+ _ = writeln!(b, "{}│{l}", i + 1);
59
+ b
60
+ });
57
61
  // append heading to expected
58
62
  let output = format!("test.tsx\n{expected}\n");
59
63
  assert_eq!(get_text(&printer), output, "{note}");
@@ -68,11 +72,13 @@ fn test_print_matches_without_heading() {
68
72
  let matches = grep.root().find_all(pattern);
69
73
  printer.print_matches(matches, "test.tsx".as_ref()).unwrap();
70
74
  // append heading to expected
71
- let output: String = source
75
+ let output = source
72
76
  .lines()
73
77
  .enumerate()
74
- .map(|(i, e)| format!("test.tsx:{}:{e}\n", i + 1))
75
- .collect();
78
+ .fold(String::new(), |mut b, (i, e)| {
79
+ _ = writeln!(b, "test.tsx:{}:{e}", i + 1);
80
+ b
81
+ });
76
82
  assert_eq!(get_text(&printer), output, "{note}");
77
83
  }
78
84
  }
@@ -329,7 +329,7 @@ fn print_matches_with_heading<'a, W: WriteColor>(
329
329
  let writer = &mut *printer.writer.lock().expect("cannot get printer lock");
330
330
  print_prelude(path, styles, writer)?;
331
331
  let Some(first_match) = matches.next() else {
332
- return Ok(())
332
+ return Ok(());
333
333
  };
334
334
  let source = first_match.root().get_text();
335
335
 
@@ -386,7 +386,7 @@ fn print_matches_with_prefix<'a, W: WriteColor>(
386
386
  let writer = &mut *printer.writer.lock().expect("cannot get printer lock");
387
387
  let path = path.display();
388
388
  let Some(first_match) = matches.next() else {
389
- return Ok(())
389
+ return Ok(());
390
390
  };
391
391
  let source = first_match.root().get_text();
392
392
 
@@ -634,20 +634,24 @@ mod choose_color {
634
634
  /// Returns true if we should attempt to write colored output.
635
635
  pub fn should_use_color(color: &ColorChoice) -> bool {
636
636
  match *color {
637
- ColorChoice::Always => env_allow_ansi(color),
637
+ // TODO: we should check if ansi is supported on windows console
638
+ ColorChoice::Always => true,
638
639
  ColorChoice::AlwaysAnsi => true,
639
640
  ColorChoice::Never => false,
640
641
  // NOTE tty check is added
641
- ColorChoice::Auto => atty::is(atty::Stream::Stdout) && env_allows_color(color),
642
+ ColorChoice::Auto => atty::is(atty::Stream::Stdout) && env_allows_color(),
642
643
  }
643
644
  }
644
645
 
645
- #[cfg(not(windows))]
646
- fn env_allows_color(color: &ColorChoice) -> bool {
646
+ fn env_allows_color() -> bool {
647
647
  match env::var_os("TERM") {
648
- // If TERM isn't set, then we are in a weird environment that
649
- // probably doesn't support colors.
650
- None => return false,
648
+ // On Windows, if TERM isn't set, then we should not automatically
649
+ // assume that colors aren't allowed. This is unlike Unix environments
650
+ None => {
651
+ if !cfg!(windows) {
652
+ return false;
653
+ }
654
+ }
651
655
  Some(k) => {
652
656
  if k == "dumb" {
653
657
  return false;
@@ -659,51 +663,6 @@ mod choose_color {
659
663
  if env::var_os("NO_COLOR").is_some() {
660
664
  return false;
661
665
  }
662
- env_allow_ansi(color)
663
- }
664
-
665
- #[cfg(windows)]
666
- fn env_allows_color(color: &ColorChoice) -> bool {
667
- // On Windows, if TERM isn't set, then we should not automatically
668
- // assume that colors aren't allowed. This is unlike Unix environments
669
- // where TERM is more rigorously set.
670
- if let Some(k) = env::var_os("TERM") {
671
- if k == "dumb" {
672
- return false;
673
- }
674
- }
675
- // If TERM != dumb, then the only way we don't allow colors at this
676
- // point is if NO_COLOR is set.
677
- if env::var_os("NO_COLOR").is_some() {
678
- return false;
679
- }
680
- env_allow_ansi(color)
681
- }
682
-
683
- #[cfg(not(windows))]
684
- fn env_allow_ansi(_color: &ColorChoice) -> bool {
685
666
  true
686
667
  }
687
-
688
- /// Returns true if this choice should forcefully use ANSI color codes.
689
- ///
690
- /// It's possible that ANSI is still the correct choice even if this
691
- /// returns false.
692
- #[cfg(windows)]
693
- fn env_allow_ansi(color: &ColorChoice) -> bool {
694
- match *color {
695
- ColorChoice::Always => false,
696
- ColorChoice::AlwaysAnsi => true,
697
- ColorChoice::Never => false,
698
- ColorChoice::Auto => {
699
- match env::var("TERM") {
700
- Err(_) => false,
701
- // cygwin doesn't seem to support ANSI escape sequences
702
- // and instead has its own variety. However, the Windows
703
- // console API may be available.
704
- Ok(k) => k != "dumb" && k != "cygwin",
705
- }
706
- }
707
- }
708
- }
709
668
  }
@@ -205,7 +205,7 @@ fn print_matches_and_confirm_next<'a>(
205
205
  fn apply_rewrite(diffs: Vec<Diff>) -> String {
206
206
  let mut new_content = String::new();
207
207
  let Some(first) = diffs.first() else {
208
- return new_content
208
+ return new_content;
209
209
  };
210
210
  let old_content = first.node_match.root().get_text();
211
211
  let mut start = 0;
@@ -120,7 +120,7 @@ mod test {
120
120
  let ret = CaseStatus::verify_snapshot(&rule, "function () { let a = 1 }", None);
121
121
  assert!(matches!(&ret, CaseStatus::Wrong { expected: None, .. }));
122
122
  let CaseStatus::Wrong { actual, source, .. } = ret else {
123
- panic!("wrong");
123
+ panic!("wrong");
124
124
  };
125
125
  assert_eq!(source, "function () { let a = 1 }");
126
126
  let primary = &actual.labels[0];
@@ -113,10 +113,10 @@ fn apply_snapshot_action(
113
113
  path_map: HashMap<String, PathBuf>,
114
114
  ) -> Result<()> {
115
115
  let Some(snapshots) = snapshots else {
116
- return Ok(())
116
+ return Ok(());
117
117
  };
118
118
  let Some(merged) = action.update_snapshot_collection(snapshots, results) else {
119
- return Ok(())
119
+ return Ok(());
120
120
  };
121
121
  write_merged_to_disk(merged, path_map)
122
122
  }
@@ -92,7 +92,10 @@ impl TestSnapshot {
92
92
  };
93
93
  let labels = Label::from_matched(matched);
94
94
  let Some(fix) = &rule_config.fixer else {
95
- return Ok(Some(Self { fixed: None, labels }));
95
+ return Ok(Some(Self {
96
+ fixed: None,
97
+ labels,
98
+ }));
96
99
  };
97
100
  let changed = sg.replace(rule, fix)?;
98
101
  debug_assert!(changed);
@@ -74,7 +74,7 @@ impl<'tree, D: Doc> MetaVarEnv<'tree, D> {
74
74
  self
75
75
  .multi_matched
76
76
  .entry(label.into())
77
- .or_insert_with(Vec::new)
77
+ .or_default()
78
78
  .push(node);
79
79
  }
80
80
 
@@ -131,7 +131,7 @@ impl<'tree, D: Doc> MetaVarEnv<'tree, D> {
131
131
  if let Some(node) = named_nodes.next() {
132
132
  let Some(cand) = named_cands.next() else {
133
133
  // cand is done but node is not
134
- break false
134
+ break false;
135
135
  };
136
136
  if !does_node_match_exactly(node, cand) {
137
137
  break false;
@@ -202,7 +202,11 @@ impl<'tree, D: Doc> Pre<'tree, D> {
202
202
  }
203
203
  self.current_depth -= 1;
204
204
  // go back to parent node
205
- cursor.goto_parent();
205
+ if !cursor.goto_parent() {
206
+ // it should never fail here. However, tree-sitter has bad parsing bugs
207
+ // stop to avoid panic. https://github.com/ast-grep/ast-grep/issues/713
208
+ break;
209
+ }
206
210
  }
207
211
  // terminate traversal here
208
212
  self.start_id = None;
@@ -16,6 +16,7 @@ mod kotlin;
16
16
  mod lua;
17
17
  mod parsers;
18
18
  mod python;
19
+ mod ruby;
19
20
  mod rust;
20
21
  mod scala;
21
22
  mod swift;
@@ -0,0 +1,34 @@
1
+ #![cfg(test)]
2
+ use ast_grep_core::source::TSParseError;
3
+
4
+ use super::*;
5
+ use ast_grep_core::Pattern;
6
+
7
+ fn test_match(query: &str, source: &str) {
8
+ use crate::test::test_match_lang;
9
+ test_match_lang(query, source, Ruby);
10
+ }
11
+
12
+ #[test]
13
+ fn test_ruby_pattern() {
14
+ test_match("Foo::bar", "Foo::bar");
15
+ }
16
+
17
+ // https://github.com/ast-grep/ast-grep/issues/713
18
+ #[test]
19
+ fn test_ruby_tree_sitter_panic() {
20
+ let pattern = Pattern::str("Foo::barbaz", Ruby);
21
+ assert_eq!(pattern.fixed_string(), "barbaz");
22
+ }
23
+
24
+ fn test_replace(src: &str, pattern: &str, replacer: &str) -> Result<String, TSParseError> {
25
+ use crate::test::test_replace_lang;
26
+ test_replace_lang(src, pattern, replacer, Ruby)
27
+ }
28
+
29
+ #[test]
30
+ fn test_ruby_replace() -> Result<(), TSParseError> {
31
+ let ret = test_replace("Foo::bar()", "Foo::$METHOD()", "$METHOD()")?;
32
+ assert_eq!(ret, "bar()");
33
+ Ok(())
34
+ }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "ast-grep-cli"
7
- version = "0.13.0"
7
+ version = "0.13.2"
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