ast-grep-cli 0.32.2__tar.gz → 0.32.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 (112) hide show
  1. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/Cargo.lock +23 -23
  2. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/Cargo.toml +6 -6
  3. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/PKG-INFO +1 -1
  4. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/cloud_print.rs +18 -21
  5. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/colored_print/test.rs +9 -9
  6. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/colored_print.rs +22 -21
  7. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/interactive_print.rs +28 -18
  8. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/json_print.rs +49 -50
  9. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/print/mod.rs +7 -7
  10. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/run.rs +34 -31
  11. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/scan.rs +36 -92
  12. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/debug_query.rs +17 -10
  13. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/worker.rs +11 -7
  14. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/tests/run_test.rs +21 -0
  15. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/tests/scan_test.rs +15 -0
  16. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/combined.rs +95 -21
  17. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/match_tree/match_node.rs +5 -1
  18. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/cpp.rs +1 -0
  19. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/lsp/src/lib.rs +13 -10
  20. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/pyproject.toml +1 -1
  21. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/LICENSE +0 -0
  22. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/README.md +0 -0
  23. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/Cargo.toml +0 -0
  24. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/README.md +0 -0
  25. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/bin/ast-grep.rs +0 -0
  26. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/completions.rs +0 -0
  27. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/config.rs +0 -0
  28. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lang/custom_lang.rs +0 -0
  29. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lang/injection.rs +0 -0
  30. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lang/lang_globs.rs +0 -0
  31. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lang/mod.rs +0 -0
  32. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lib.rs +0 -0
  33. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/lsp.rs +0 -0
  34. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/main.rs +0 -0
  35. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/new.rs +0 -0
  36. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/args.rs +0 -0
  37. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/error_context.rs +0 -0
  38. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/inspect.rs +0 -0
  39. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/mod.rs +0 -0
  40. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/utils/rule_overwrite.rs +0 -0
  41. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify/case_result.rs +0 -0
  42. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify/find_file.rs +0 -0
  43. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify/reporter.rs +0 -0
  44. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify/snapshot.rs +0 -0
  45. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify/test_case.rs +0 -0
  46. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/src/verify.rs +0 -0
  47. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/tests/common/mod.rs +0 -0
  48. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/cli/tests/verify_test.rs +0 -0
  49. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/Cargo.toml +0 -0
  50. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/check_var.rs +0 -0
  51. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/fixer.rs +0 -0
  52. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/lib.rs +0 -0
  53. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/maybe.rs +0 -0
  54. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/deserialize_env.rs +0 -0
  55. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/mod.rs +0 -0
  56. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/nth_child.rs +0 -0
  57. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/range.rs +0 -0
  58. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/referent_rule.rs +0 -0
  59. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/relational_rule.rs +0 -0
  60. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule/stop_by.rs +0 -0
  61. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule_collection.rs +0 -0
  62. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule_config.rs +0 -0
  63. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/rule_core.rs +0 -0
  64. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/transform/mod.rs +0 -0
  65. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/transform/rewrite.rs +0 -0
  66. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/transform/string_case.rs +0 -0
  67. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/config/src/transform/transformation.rs +0 -0
  68. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/Cargo.toml +0 -0
  69. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/language.rs +0 -0
  70. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/lib.rs +0 -0
  71. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/match_tree/mod.rs +0 -0
  72. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/match_tree/strictness.rs +0 -0
  73. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/matcher/kind.rs +0 -0
  74. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/matcher/node_match.rs +0 -0
  75. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/matcher/pattern.rs +0 -0
  76. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/matcher/text.rs +0 -0
  77. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/matcher.rs +0 -0
  78. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/meta_var.rs +0 -0
  79. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/node.rs +0 -0
  80. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/ops.rs +0 -0
  81. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/pinned.rs +0 -0
  82. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/replacer/indent.rs +0 -0
  83. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/replacer/structural.rs +0 -0
  84. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/replacer/template.rs +0 -0
  85. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/replacer.rs +0 -0
  86. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/source.rs +0 -0
  87. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/core/src/traversal.rs +0 -0
  88. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/dynamic/Cargo.toml +0 -0
  89. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/dynamic/src/lib.rs +0 -0
  90. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/Cargo.toml +0 -0
  91. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/bash.rs +0 -0
  92. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/csharp.rs +0 -0
  93. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/css.rs +0 -0
  94. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/elixir.rs +0 -0
  95. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/go.rs +0 -0
  96. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/haskell.rs +0 -0
  97. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/html.rs +0 -0
  98. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/json.rs +0 -0
  99. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/kotlin.rs +0 -0
  100. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/lib.rs +0 -0
  101. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/lua.rs +0 -0
  102. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/parsers.rs +0 -0
  103. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/php.rs +0 -0
  104. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/python.rs +0 -0
  105. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/ruby.rs +0 -0
  106. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/rust.rs +0 -0
  107. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/scala.rs +0 -0
  108. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/swift.rs +0 -0
  109. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/language/src/yaml.rs +0 -0
  110. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/lsp/Cargo.toml +0 -0
  111. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/lsp/src/utils.rs +0 -0
  112. {ast_grep_cli-0.32.2 → ast_grep_cli-0.32.3}/crates/lsp/tests/basic.rs +0 -0
@@ -92,9 +92,9 @@ dependencies = [
92
92
 
93
93
  [[package]]
94
94
  name = "anyhow"
95
- version = "1.0.94"
95
+ version = "1.0.95"
96
96
  source = "registry+https://github.com/rust-lang/crates.io-index"
97
- checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
97
+ checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
98
98
 
99
99
  [[package]]
100
100
  name = "assert_cmd"
@@ -114,7 +114,7 @@ dependencies = [
114
114
 
115
115
  [[package]]
116
116
  name = "ast-grep"
117
- version = "0.32.2"
117
+ version = "0.32.3"
118
118
  dependencies = [
119
119
  "ansi_term",
120
120
  "anyhow",
@@ -144,7 +144,7 @@ dependencies = [
144
144
 
145
145
  [[package]]
146
146
  name = "ast-grep-config"
147
- version = "0.32.2"
147
+ version = "0.32.3"
148
148
  dependencies = [
149
149
  "anyhow",
150
150
  "ast-grep-core",
@@ -160,7 +160,7 @@ dependencies = [
160
160
 
161
161
  [[package]]
162
162
  name = "ast-grep-core"
163
- version = "0.32.2"
163
+ version = "0.32.3"
164
164
  dependencies = [
165
165
  "bit-set",
166
166
  "regex",
@@ -171,7 +171,7 @@ dependencies = [
171
171
 
172
172
  [[package]]
173
173
  name = "ast-grep-dynamic"
174
- version = "0.32.2"
174
+ version = "0.32.3"
175
175
  dependencies = [
176
176
  "ast-grep-core",
177
177
  "ignore",
@@ -183,7 +183,7 @@ dependencies = [
183
183
 
184
184
  [[package]]
185
185
  name = "ast-grep-language"
186
- version = "0.32.2"
186
+ version = "0.32.3"
187
187
  dependencies = [
188
188
  "ast-grep-core",
189
189
  "ignore",
@@ -215,7 +215,7 @@ dependencies = [
215
215
 
216
216
  [[package]]
217
217
  name = "ast-grep-lsp"
218
- version = "0.32.2"
218
+ version = "0.32.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.32.2"
232
+ version = "0.32.3"
233
233
  dependencies = [
234
234
  "ast-grep-config",
235
235
  "ast-grep-core",
@@ -244,7 +244,7 @@ dependencies = [
244
244
 
245
245
  [[package]]
246
246
  name = "ast-grep-py"
247
- version = "0.32.2"
247
+ version = "0.32.3"
248
248
  dependencies = [
249
249
  "anyhow",
250
250
  "ast-grep-config",
@@ -312,7 +312,7 @@ dependencies = [
312
312
 
313
313
  [[package]]
314
314
  name = "benches"
315
- version = "0.32.2"
315
+ version = "0.32.3"
316
316
  dependencies = [
317
317
  "ast-grep-config",
318
318
  "ast-grep-core",
@@ -448,9 +448,9 @@ dependencies = [
448
448
 
449
449
  [[package]]
450
450
  name = "clap_complete"
451
- version = "4.5.39"
451
+ version = "4.5.40"
452
452
  source = "registry+https://github.com/rust-lang/crates.io-index"
453
- checksum = "fd4db298d517d5fa00b2b84bbe044efd3fde43874a41db0d46f91994646a2da4"
453
+ checksum = "ac2e663e3e3bed2d32d065a8404024dad306e699a04263ec59919529f803aee9"
454
454
  dependencies = [
455
455
  "clap",
456
456
  ]
@@ -691,9 +691,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
691
691
 
692
692
  [[package]]
693
693
  name = "float-cmp"
694
- version = "0.9.0"
694
+ version = "0.10.0"
695
695
  source = "registry+https://github.com/rust-lang/crates.io-index"
696
- checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
696
+ checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
697
697
  dependencies = [
698
698
  "num-traits",
699
699
  ]
@@ -1266,9 +1266,9 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
1266
1266
 
1267
1267
  [[package]]
1268
1268
  name = "predicates"
1269
- version = "3.1.2"
1269
+ version = "3.1.3"
1270
1270
  source = "registry+https://github.com/rust-lang/crates.io-index"
1271
- checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97"
1271
+ checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573"
1272
1272
  dependencies = [
1273
1273
  "anstyle",
1274
1274
  "difflib",
@@ -1547,9 +1547,9 @@ dependencies = [
1547
1547
 
1548
1548
  [[package]]
1549
1549
  name = "serde_json"
1550
- version = "1.0.133"
1550
+ version = "1.0.134"
1551
1551
  source = "registry+https://github.com/rust-lang/crates.io-index"
1552
- checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
1552
+ checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
1553
1553
  dependencies = [
1554
1554
  "indexmap",
1555
1555
  "itoa",
@@ -1699,18 +1699,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
1699
1699
 
1700
1700
  [[package]]
1701
1701
  name = "thiserror"
1702
- version = "2.0.6"
1702
+ version = "2.0.9"
1703
1703
  source = "registry+https://github.com/rust-lang/crates.io-index"
1704
- checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47"
1704
+ checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
1705
1705
  dependencies = [
1706
1706
  "thiserror-impl",
1707
1707
  ]
1708
1708
 
1709
1709
  [[package]]
1710
1710
  name = "thiserror-impl"
1711
- version = "2.0.6"
1711
+ version = "2.0.9"
1712
1712
  source = "registry+https://github.com/rust-lang/crates.io-index"
1713
- checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312"
1713
+ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
1714
1714
  dependencies = [
1715
1715
  "proc-macro2",
1716
1716
  "quote",
@@ -7,7 +7,7 @@ resolver = "2"
7
7
  lto = true
8
8
 
9
9
  [workspace.package]
10
- version = "0.32.2"
10
+ version = "0.32.3"
11
11
  authors = ["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"]
12
12
  edition = "2021"
13
13
  license = "MIT"
@@ -18,11 +18,11 @@ rust-version = "1.67"
18
18
  readme = "README.md"
19
19
 
20
20
  [workspace.dependencies]
21
- ast-grep-core = { path = "crates/core", version = "0.32.2" }
22
- ast-grep-config = { path = "crates/config", version = "0.32.2" }
23
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.32.2" }
24
- ast-grep-language = { path = "crates/language", version = "0.32.2" }
25
- ast-grep-lsp = { path = "crates/lsp", version = "0.32.2" }
21
+ ast-grep-core = { path = "crates/core", version = "0.32.3" }
22
+ ast-grep-config = { path = "crates/config", version = "0.32.3" }
23
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.32.3" }
24
+ ast-grep-language = { path = "crates/language", version = "0.32.3" }
25
+ ast-grep-lsp = { path = "crates/lsp", version = "0.32.3" }
26
26
 
27
27
  bit-set = { version = "0.8.0" }
28
28
  ignore = { version = "0.4.22" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ast-grep-cli
3
- Version: 0.32.2
3
+ Version: 0.32.3
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -7,7 +7,6 @@ use anyhow::Result;
7
7
  use ast_grep_core::{NodeMatch as SgNodeMatch, StrDoc};
8
8
  use codespan_reporting::files::SimpleFile;
9
9
  use std::io::{Stdout, Write};
10
- use std::sync::Mutex;
11
10
 
12
11
  type NodeMatch<'a, L> = SgNodeMatch<'a, StrDoc<L>>;
13
12
 
@@ -28,15 +27,13 @@ pub enum Platform {
28
27
  GitHub,
29
28
  }
30
29
 
31
- pub struct CloudPrinter<W: Write + Send + Sync> {
32
- writer: Mutex<W>,
30
+ pub struct CloudPrinter<W: Write> {
31
+ writer: W,
33
32
  }
34
33
 
35
- impl<W: Write + Send + Sync> CloudPrinter<W> {
36
- pub fn new(w: W) -> Self {
37
- Self {
38
- writer: Mutex::new(w),
39
- }
34
+ impl<W: Write> CloudPrinter<W> {
35
+ pub fn new(writer: W) -> Self {
36
+ Self { writer }
40
37
  }
41
38
  }
42
39
 
@@ -46,9 +43,9 @@ impl CloudPrinter<Stdout> {
46
43
  }
47
44
  }
48
45
 
49
- impl<W: Write + Send + Sync> Printer for CloudPrinter<W> {
46
+ impl<W: Write> Printer for CloudPrinter<W> {
50
47
  fn print_rule<'a>(
51
- &self,
48
+ &mut self,
52
49
  matches: Matches!('a),
53
50
  file: SimpleFile<Cow<str>, &String>,
54
51
  rule: &RuleConfig<SgLang>,
@@ -57,16 +54,16 @@ impl<W: Write + Send + Sync> Printer for CloudPrinter<W> {
57
54
  print_rule(self, matches, &path, rule)
58
55
  }
59
56
 
60
- fn print_matches<'a>(&self, _m: Matches!('a), _p: &Path) -> Result<()> {
57
+ fn print_matches<'a>(&mut self, _m: Matches!('a), _p: &Path) -> Result<()> {
61
58
  unreachable!()
62
59
  }
63
60
 
64
- fn print_diffs<'a>(&self, _d: Diffs!('a), _p: &Path) -> Result<()> {
61
+ fn print_diffs<'a>(&mut self, _d: Diffs!('a), _p: &Path) -> Result<()> {
65
62
  unreachable!()
66
63
  }
67
64
 
68
65
  fn print_rule_diffs(
69
- &self,
66
+ &mut self,
70
67
  diffs: Vec<(Diff<'_>, &RuleConfig<SgLang>)>,
71
68
  path: &Path,
72
69
  ) -> Result<()> {
@@ -77,13 +74,13 @@ impl<W: Write + Send + Sync> Printer for CloudPrinter<W> {
77
74
  }
78
75
  }
79
76
 
80
- fn print_rule<'a, W: Write + Send + Sync>(
81
- p: &CloudPrinter<W>,
77
+ fn print_rule<'a, W: Write>(
78
+ p: &mut CloudPrinter<W>,
82
79
  matches: Matches!('a),
83
80
  path: &Path,
84
81
  rule: &RuleConfig<SgLang>,
85
82
  ) -> Result<()> {
86
- let mut writer = p.writer.lock().expect("should work");
83
+ let writer = &mut p.writer;
87
84
  let level = match rule.severity {
88
85
  Severity::Error => "error",
89
86
  Severity::Warning => "warning",
@@ -98,7 +95,7 @@ fn print_rule<'a, W: Write + Send + Sync>(
98
95
  let end_line = m.end_pos().line() + 1;
99
96
  let message = rule.get_message(&m);
100
97
  writeln!(
101
- &mut writer,
98
+ writer,
102
99
  "::{level} file={name},line={line},endLine={end_line},title={title}::{message}"
103
100
  )?;
104
101
  }
@@ -115,8 +112,8 @@ mod test {
115
112
  fn make_test_printer() -> CloudPrinter<Buffer> {
116
113
  CloudPrinter::new(Buffer::no_color())
117
114
  }
118
- fn get_text(printer: &CloudPrinter<Buffer>) -> String {
119
- let buffer = printer.writer.lock().expect("should work");
115
+ fn get_text(printer: &mut CloudPrinter<Buffer>) -> String {
116
+ let buffer = &mut printer.writer;
120
117
  let bytes = buffer.as_slice();
121
118
  std::str::from_utf8(bytes)
122
119
  .expect("buffer should be valid utf8")
@@ -142,13 +139,13 @@ language: TypeScript
142
139
 
143
140
  fn test_output(src: &str, rule_str: &str, expect: &str) {
144
141
  let src = src.to_owned();
145
- let printer = make_test_printer();
142
+ let mut printer = make_test_printer();
146
143
  let grep = SgLang::from(SupportLang::Tsx).ast_grep(&src);
147
144
  let rule = make_rule(rule_str);
148
145
  let matches = grep.root().find_all(&rule.matcher);
149
146
  let file = SimpleFile::new(Cow::Borrowed("test.tsx"), &src);
150
147
  printer.print_rule(matches, file, &rule).unwrap();
151
- let actual = get_text(&printer);
148
+ let actual = get_text(&mut printer);
152
149
  assert_eq!(actual, expect);
153
150
  }
154
151
 
@@ -11,7 +11,7 @@ fn make_test_printer() -> ColoredPrinter<Buffer> {
11
11
  ColoredPrinter::new(Buffer::no_color()).color(ColorChoice::Never)
12
12
  }
13
13
  fn get_text(printer: &ColoredPrinter<Buffer>) -> String {
14
- let buffer = printer.writer.lock().expect("should work");
14
+ let buffer = &printer.writer;
15
15
  let bytes = buffer.as_slice();
16
16
  std::str::from_utf8(bytes)
17
17
  .expect("buffer should be valid utf8")
@@ -46,7 +46,7 @@ const MATCHES_CASES: &[Case] = &[
46
46
  fn test_print_matches() {
47
47
  for &(source, pattern, note) in MATCHES_CASES {
48
48
  // heading is required for CI
49
- let printer = make_test_printer().heading(Heading::Always);
49
+ let mut printer = make_test_printer().heading(Heading::Always);
50
50
  let grep = SgLang::from(SupportLang::Tsx).ast_grep(source);
51
51
  let matches = grep.root().find_all(pattern);
52
52
  printer.print_matches(matches, "test.tsx".as_ref()).unwrap();
@@ -66,7 +66,7 @@ fn test_print_matches() {
66
66
  #[test]
67
67
  fn test_print_matches_without_heading() {
68
68
  for &(source, pattern, note) in MATCHES_CASES {
69
- let printer = make_test_printer().heading(Heading::Never);
69
+ let mut printer = make_test_printer().heading(Heading::Never);
70
70
  let grep = SgLang::from(SupportLang::Tsx).ast_grep(source);
71
71
  let matches = grep.root().find_all(pattern);
72
72
  printer.print_matches(matches, "test.tsx".as_ref()).unwrap();
@@ -86,7 +86,7 @@ fn test_print_matches_without_heading() {
86
86
  fn test_print_rules() {
87
87
  let globals = GlobalRules::default();
88
88
  for &(source, pattern, note) in MATCHES_CASES {
89
- let printer = make_test_printer()
89
+ let mut printer = make_test_printer()
90
90
  .heading(Heading::Never)
91
91
  .style(ReportStyle::Short);
92
92
  let grep = SgLang::from(SupportLang::TypeScript).ast_grep(source);
@@ -153,7 +153,7 @@ const DIFF_CASES: &[DiffCase] = &[
153
153
  fn test_print_diffs() {
154
154
  for &(source, pattern, rewrite, note) in DIFF_CASES {
155
155
  // heading is required for CI
156
- let printer = make_test_printer().heading(Heading::Always);
156
+ let mut printer = make_test_printer().heading(Heading::Always);
157
157
  let lang = SgLang::from(SupportLang::Tsx);
158
158
  let fixer = Fixer::from_str(rewrite, &lang).expect("should work");
159
159
  let grep = lang.ast_grep(source);
@@ -170,7 +170,7 @@ fn test_overlap_print_impl(heading: Heading) {
170
170
  // empty
171
171
  Some(2)
172
172
  ";
173
- let printer = make_test_printer().heading(heading).context((1, 1));
173
+ let mut printer = make_test_printer().heading(heading).context((1, 1));
174
174
  let lang = SgLang::from(SupportLang::Tsx);
175
175
  let grep = lang.ast_grep(src);
176
176
  let matches = grep.root().find_all("Some($A)");
@@ -195,7 +195,7 @@ fn test_non_overlap_print_impl(heading: Heading) {
195
195
  // empty
196
196
  Some(2)
197
197
  ";
198
- let printer = make_test_printer().heading(heading);
198
+ let mut printer = make_test_printer().heading(heading);
199
199
  let lang = SgLang::from(SupportLang::Tsx);
200
200
  let grep = lang.ast_grep(src);
201
201
  let matches = grep.root().find_all("Some($A)");
@@ -217,7 +217,7 @@ fn test_non_overlap_print() {
217
217
  fn test_print_rule_diffs() {
218
218
  let globals = GlobalRules::default();
219
219
  for &(source, pattern, rewrite, note) in DIFF_CASES {
220
- let printer = make_test_printer()
220
+ let mut printer = make_test_printer()
221
221
  .heading(Heading::Never)
222
222
  .style(ReportStyle::Short);
223
223
  let grep = SgLang::from(SupportLang::TypeScript).ast_grep(source);
@@ -264,7 +264,7 @@ fn test_before_after() {
264
264
  ";
265
265
  for b in 0..3 {
266
266
  for a in 0..3 {
267
- let printer = make_test_printer().context((b, a));
267
+ let mut printer = make_test_printer().context((b, a));
268
268
  let lang = SgLang::from(SupportLang::Tsx);
269
269
  let grep = lang.ast_grep(src);
270
270
  let matches = grep.root().find_all("Some($A)");
@@ -16,7 +16,6 @@ use std::borrow::Cow;
16
16
  use std::fmt::Display;
17
17
  use std::io::Write;
18
18
  use std::path::Path;
19
- use std::sync::Mutex;
20
19
 
21
20
  mod test;
22
21
 
@@ -62,8 +61,8 @@ impl Heading {
62
61
  }
63
62
  }
64
63
 
65
- pub struct ColoredPrinter<W: WriteColor + Send + Sync> {
66
- writer: Mutex<W>,
64
+ pub struct ColoredPrinter<W: WriteColor> {
65
+ writer: W,
67
66
  config: term::Config,
68
67
  styles: PrintStyles,
69
68
  heading: Heading,
@@ -76,10 +75,10 @@ impl ColoredPrinter<StandardStream> {
76
75
  }
77
76
  }
78
77
 
79
- impl<W: WriteColor + Send + Sync> ColoredPrinter<W> {
78
+ impl<W: WriteColor> ColoredPrinter<W> {
80
79
  pub fn new(writer: W) -> Self {
81
80
  Self {
82
- writer: Mutex::new(writer),
81
+ writer,
83
82
  styles: PrintStyles::from(ColorChoice::Auto),
84
83
  config: term::Config::default(),
85
84
  heading: Heading::Auto,
@@ -128,15 +127,15 @@ impl<W: WriteColor + Send + Sync> ColoredPrinter<W> {
128
127
  }
129
128
  }
130
129
 
131
- impl<W: WriteColor + Send + Sync> Printer for ColoredPrinter<W> {
130
+ impl<W: WriteColor> Printer for ColoredPrinter<W> {
132
131
  fn print_rule<'a>(
133
- &self,
132
+ &mut self,
134
133
  matches: Matches!('a),
135
134
  file: SimpleFile<Cow<str>, &String>,
136
135
  rule: &RuleConfig<SgLang>,
137
136
  ) -> Result<()> {
138
137
  let config = &self.config;
139
- let mut writer = self.writer.lock().expect("should not fail");
138
+ let writer = &mut self.writer;
140
139
  let severity = match rule.severity {
141
140
  Severity::Error => diagnostic::Severity::Error,
142
141
  Severity::Warning => diagnostic::Severity::Warning,
@@ -163,7 +162,7 @@ impl<W: WriteColor + Send + Sync> Printer for ColoredPrinter<W> {
163
162
  Ok(())
164
163
  }
165
164
 
166
- fn print_matches<'a>(&self, matches: Matches!('a), path: &Path) -> Result<()> {
165
+ fn print_matches<'a>(&mut self, matches: Matches!('a), path: &Path) -> Result<()> {
167
166
  if self.heading.should_print() {
168
167
  print_matches_with_heading(matches, path, self)
169
168
  } else {
@@ -171,18 +170,18 @@ impl<W: WriteColor + Send + Sync> Printer for ColoredPrinter<W> {
171
170
  }
172
171
  }
173
172
 
174
- fn print_diffs<'a>(&self, diffs: Diffs!('a), path: &Path) -> Result<()> {
175
- let writer = &mut *self.writer.lock().expect("should success");
173
+ fn print_diffs<'a>(&mut self, diffs: Diffs!('a), path: &Path) -> Result<()> {
176
174
  let context = self.diff_context();
175
+ let writer = &mut self.writer;
177
176
  print_diffs(diffs, path, &self.styles, writer, context)
178
177
  }
179
178
  fn print_rule_diffs(
180
- &self,
179
+ &mut self,
181
180
  diffs: Vec<(Diff<'_>, &RuleConfig<SgLang>)>,
182
181
  path: &Path,
183
182
  ) -> Result<()> {
184
- let writer = &mut *self.writer.lock().expect("should success");
185
183
  let context = self.diff_context();
184
+ let writer = &mut self.writer;
186
185
  let mut start = 0;
187
186
  print_prelude(path, &self.styles, writer)?;
188
187
  for (diff, rule) in diffs {
@@ -322,13 +321,14 @@ impl<'a> MatchMerger<'a> {
322
321
  }
323
322
  }
324
323
 
325
- fn print_matches_with_heading<'a, W: WriteColor + Send + Sync>(
324
+ fn print_matches_with_heading<'a, W: WriteColor>(
326
325
  mut matches: Matches!('a),
327
326
  path: &Path,
328
- printer: &ColoredPrinter<W>,
327
+ printer: &mut ColoredPrinter<W>,
329
328
  ) -> Result<()> {
330
329
  let styles = &printer.styles;
331
- let writer = &mut *printer.writer.lock().expect("cannot get printer lock");
330
+ let context_span = printer.context_span();
331
+ let writer = &mut printer.writer;
332
332
  print_prelude(path, styles, writer)?;
333
333
  let Some(first_match) = matches.next() else {
334
334
  return Ok(());
@@ -360,7 +360,7 @@ fn print_matches_with_heading<'a, W: WriteColor + Send + Sync>(
360
360
  write!(writer, "{line_num:>width$}│")?; // initial line num
361
361
  print_highlight(ret.lines(), width, &mut num, writer, styles)?;
362
362
  writeln!(writer)?; // end match new line
363
- if printer.context_span() > 0 {
363
+ if context_span > 0 {
364
364
  writeln!(writer, "{:╴>width$}┤", "")?; // make separation
365
365
  }
366
366
  merger.conclude_match(&nm);
@@ -379,13 +379,14 @@ fn print_matches_with_heading<'a, W: WriteColor + Send + Sync>(
379
379
  Ok(())
380
380
  }
381
381
 
382
- fn print_matches_with_prefix<'a, W: WriteColor + Send + Sync>(
382
+ fn print_matches_with_prefix<'a, W: WriteColor>(
383
383
  mut matches: Matches!('a),
384
384
  path: &Path,
385
- printer: &ColoredPrinter<W>,
385
+ printer: &mut ColoredPrinter<W>,
386
386
  ) -> Result<()> {
387
387
  let styles = &printer.styles;
388
- let writer = &mut *printer.writer.lock().expect("cannot get printer lock");
388
+ let context_span = printer.context_span();
389
+ let writer = &mut printer.writer;
389
390
  let path = path.display();
390
391
  let Some(first_match) = matches.next() else {
391
392
  return Ok(());
@@ -412,7 +413,7 @@ fn print_matches_with_prefix<'a, W: WriteColor + Send + Sync>(
412
413
  let num = merger.last_start_line + n;
413
414
  writeln!(writer, "{path}:{num}:{line}")?;
414
415
  }
415
- if printer.context_span() > 0 {
416
+ if context_span > 0 {
416
417
  writeln!(writer, "--")?; // make separation
417
418
  }
418
419
  merger.conclude_match(&nm);
@@ -8,8 +8,6 @@ use ast_grep_config::RuleConfig;
8
8
  use ast_grep_core::{NodeMatch as SgNodeMatch, StrDoc};
9
9
  use codespan_reporting::files::SimpleFile;
10
10
 
11
- use std::sync::atomic::{AtomicBool, Ordering};
12
-
13
11
  type NodeMatch<'a, L> = SgNodeMatch<'a, StrDoc<L>>;
14
12
 
15
13
  use std::borrow::Cow;
@@ -24,8 +22,9 @@ macro_rules! Diffs {
24
22
  }
25
23
 
26
24
  pub struct InteractivePrinter<P: Printer> {
27
- accept_all: AtomicBool,
25
+ accept_all: bool,
28
26
  from_stdin: bool,
27
+ committed_cnt: usize,
29
28
  inner: P,
30
29
  }
31
30
 
@@ -35,15 +34,16 @@ impl<P: Printer> InteractivePrinter<P> {
35
34
  Err(anyhow::anyhow!(EC::StdInIsNotInteractive))
36
35
  } else {
37
36
  Ok(Self {
38
- accept_all: AtomicBool::new(accept_all),
37
+ accept_all,
39
38
  from_stdin,
40
39
  inner,
40
+ committed_cnt: 0,
41
41
  })
42
42
  }
43
43
  }
44
44
 
45
45
  fn prompt_edit(&self) -> char {
46
- if self.accept_all.load(Ordering::SeqCst) {
46
+ if self.accept_all {
47
47
  return 'a';
48
48
  }
49
49
  const EDIT_PROMPT: &str = "Accept change? (Yes[y], No[n], Accept All[a], Quit[q], Edit[e])";
@@ -51,7 +51,7 @@ impl<P: Printer> InteractivePrinter<P> {
51
51
  }
52
52
 
53
53
  fn prompt_view(&self) -> char {
54
- if self.accept_all.load(Ordering::SeqCst) {
54
+ if self.accept_all {
55
55
  return '\n';
56
56
  }
57
57
  const VIEW_PROMPT: &str = "Next[enter], Quit[q], Edit[e]";
@@ -74,7 +74,7 @@ impl<P: Printer> InteractivePrinter<P> {
74
74
 
75
75
  impl<P: Printer> Printer for InteractivePrinter<P> {
76
76
  fn print_rule<'a>(
77
- &self,
77
+ &mut self,
78
78
  matches: Matches!('a),
79
79
  file: SimpleFile<Cow<str>, &String>,
80
80
  rule: &RuleConfig<SgLang>,
@@ -99,22 +99,23 @@ impl<P: Printer> Printer for InteractivePrinter<P> {
99
99
  })
100
100
  }
101
101
 
102
- fn print_matches<'a>(&self, matches: Matches!('a), path: &Path) -> Result<()> {
102
+ fn print_matches<'a>(&mut self, matches: Matches!('a), path: &Path) -> Result<()> {
103
103
  utils::run_in_alternate_screen(|| print_matches_and_confirm_next(self, matches, path))
104
104
  }
105
105
 
106
- fn print_diffs<'a>(&self, diffs: Diffs!('a), path: &Path) -> Result<()> {
106
+ fn print_diffs<'a>(&mut self, diffs: Diffs!('a), path: &Path) -> Result<()> {
107
107
  let path = path.to_path_buf();
108
108
  let (confirmed, all) =
109
109
  print_diffs_interactive(self, &path, diffs.map(|d| (d, None)).collect())?;
110
110
  self.rewrite_action(confirmed, &path)?;
111
111
  if all {
112
- self.accept_all.store(true, Ordering::SeqCst);
112
+ self.accept_all = true;
113
+ // self.accept_all.store(true, Ordering::SeqCst);
113
114
  }
114
115
  Ok(())
115
116
  }
116
117
  fn print_rule_diffs(
117
- &self,
118
+ &mut self,
118
119
  diffs: Vec<(Diff<'_>, &RuleConfig<SgLang>)>,
119
120
  path: &Path,
120
121
  ) -> Result<()> {
@@ -126,19 +127,27 @@ impl<P: Printer> Printer for InteractivePrinter<P> {
126
127
  )?;
127
128
  self.rewrite_action(confirmed, &path)?;
128
129
  if all {
129
- self.accept_all.store(true, Ordering::SeqCst);
130
+ self.accept_all = true;
131
+ // self.accept_all.store(true, Ordering::SeqCst);
130
132
  }
131
133
  Ok(())
132
134
  }
135
+
136
+ fn after_print(&mut self) -> Result<()> {
137
+ if self.committed_cnt > 0 {
138
+ println!("Applied {} changes", self.committed_cnt);
139
+ }
140
+ self.inner.after_print()
141
+ }
133
142
  }
134
143
 
135
144
  fn print_diffs_interactive<'a>(
136
- interactive: &InteractivePrinter<impl Printer>,
145
+ interactive: &mut InteractivePrinter<impl Printer>,
137
146
  path: &Path,
138
147
  diffs: Vec<(Diff<'a>, Option<&RuleConfig<SgLang>>)>,
139
148
  ) -> Result<(Vec<Diff<'a>>, bool)> {
140
149
  let mut confirmed = vec![];
141
- let mut all = interactive.accept_all.load(Ordering::SeqCst);
150
+ let mut all = interactive.accept_all;
142
151
  let mut end = 0;
143
152
  for (diff, rule) in diffs {
144
153
  if diff.range.start < end {
@@ -153,18 +162,19 @@ fn print_diffs_interactive<'a>(
153
162
  if confirm {
154
163
  end = diff.range.end;
155
164
  confirmed.push(diff);
165
+ interactive.committed_cnt = interactive.committed_cnt.saturating_add(1);
156
166
  }
157
167
  }
158
168
  Ok((confirmed, all))
159
169
  }
160
170
  /// returns if accept_current and accept_all
161
171
  fn print_diff_and_prompt_action(
162
- interactive: &InteractivePrinter<impl Printer>,
172
+ interactive: &mut InteractivePrinter<impl Printer>,
163
173
  path: &Path,
164
174
  (diff, rule): (Diff, Option<&RuleConfig<SgLang>>),
165
175
  ) -> Result<(bool, bool)> {
166
- let printer = &interactive.inner;
167
176
  utils::run_in_alternate_screen(|| {
177
+ let printer = &mut interactive.inner;
168
178
  if let Some(rule) = rule {
169
179
  printer.print_rule_diffs(vec![(diff.clone(), rule)], path)?;
170
180
  } else {
@@ -186,11 +196,11 @@ fn print_diff_and_prompt_action(
186
196
  }
187
197
 
188
198
  fn print_matches_and_confirm_next<'a>(
189
- interactive: &InteractivePrinter<impl Printer>,
199
+ interactive: &mut InteractivePrinter<impl Printer>,
190
200
  matches: Matches!('a),
191
201
  path: &Path,
192
202
  ) -> Result<()> {
193
- let printer = &interactive.inner;
203
+ let printer = &mut interactive.inner;
194
204
  let matches: Vec<_> = matches.collect();
195
205
  let first_match = match matches.first() {
196
206
  Some(n) => n.start_pos().line(),