polyglot-piranha 0.3.29__tar.gz → 0.3.32__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 (77) hide show
  1. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/Cargo.lock +106 -94
  2. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/Cargo.toml +4 -2
  3. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/PKG-INFO +1 -1
  4. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/default_configs.rs +4 -0
  5. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/matches.rs +24 -5
  6. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/rule.rs +17 -2
  7. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/rule_test.rs +64 -0
  8. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/LICENSE +0 -0
  9. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/NOTICE +0 -0
  10. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/README.md +0 -0
  11. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/plugins/pyproject.toml +0 -0
  12. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/pyproject.toml +0 -0
  13. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/go/edges.toml +0 -0
  14. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/go/rules.toml +0 -0
  15. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/go/scope_config.toml +0 -0
  16. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java/edges.toml +0 -0
  17. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java/rules.toml +0 -0
  18. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java/scope_config.toml +0 -0
  19. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java_cs/edges.toml +0 -0
  20. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java_cs/rules.toml +0 -0
  21. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/java_cs/scope_config.toml +0 -0
  22. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/kt/edges.toml +0 -0
  23. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/kt/rules.toml +0 -0
  24. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/kt/scope_config.toml +0 -0
  25. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/ruby/edges.toml +0 -0
  26. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/ruby/rules.toml +0 -0
  27. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/ruby/scope_config.toml +0 -0
  28. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/scala/scope_config.toml +0 -0
  29. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/swift/edges.toml +0 -0
  30. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/swift/rules.toml +0 -0
  31. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/cleanup_rules/swift/scope_config.toml +0 -0
  32. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/README.md +0 -0
  33. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/analysis.rs +0 -0
  34. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/mod.rs +0 -0
  35. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/tag_analysis.rs +0 -0
  36. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/unit_tests/tag_analysis_test.rs +0 -0
  37. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/df/utils.rs +0 -0
  38. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/lib.rs +0 -0
  39. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/main.rs +0 -0
  40. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/capture_group_patterns.rs +0 -0
  41. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/concrete_syntax.rs +0 -0
  42. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/edit.rs +0 -0
  43. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/filter.rs +0 -0
  44. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/language.rs +0 -0
  45. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/mod.rs +0 -0
  46. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/outgoing_edges.rs +0 -0
  47. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/piranha_arguments.rs +0 -0
  48. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/piranha_output.rs +0 -0
  49. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/rule_graph.rs +0 -0
  50. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/rule_store.rs +0 -0
  51. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/scopes.rs +0 -0
  52. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/source_code_unit.rs +0 -0
  53. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/concrete_syntax_test.rs +0 -0
  54. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/piranha_arguments_test.rs +0 -0
  55. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/rule_graph_validation_test.rs +0 -0
  56. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/scopes_test.rs +0 -0
  57. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/source_code_unit_test.rs +0 -0
  58. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/testdata/custom_builtin/edges.toml +0 -0
  59. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/models/unit_tests/testdata/custom_builtin/rules.toml +0 -0
  60. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/mod.rs +0 -0
  61. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_go.rs +0 -0
  62. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_java.rs +0 -0
  63. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_kt.rs +0 -0
  64. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_python.rs +0 -0
  65. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_scala.rs +0 -0
  66. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_scm.rs +0 -0
  67. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_strings.rs +0 -0
  68. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_swift.rs +0 -0
  69. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_thrift.rs +0 -0
  70. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_ts.rs +0 -0
  71. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_tsx.rs +0 -0
  72. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/tests/test_piranha_yaml.rs +0 -0
  73. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/utilities/mod.rs +0 -0
  74. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/utilities/regex_utilities.rs +0 -0
  75. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/utilities/tree_sitter_utilities.rs +0 -0
  76. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/utilities/unit_tests/tree_sitter_utilities_test.rs +0 -0
  77. {polyglot_piranha-0.3.29 → polyglot_piranha-0.3.32}/src/utilities/unit_tests/utilities_test.rs +0 -0
@@ -52,12 +52,12 @@ dependencies = [
52
52
 
53
53
  [[package]]
54
54
  name = "anstyle-wincon"
55
- version = "3.0.7"
55
+ version = "3.0.8"
56
56
  source = "registry+https://github.com/rust-lang/crates.io-index"
57
- checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
57
+ checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
58
58
  dependencies = [
59
59
  "anstyle",
60
- "once_cell",
60
+ "once_cell_polyfill",
61
61
  "windows-sys",
62
62
  ]
63
63
 
@@ -69,9 +69,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
69
69
 
70
70
  [[package]]
71
71
  name = "assert_cmd"
72
- version = "2.0.16"
72
+ version = "2.0.17"
73
73
  source = "registry+https://github.com/rust-lang/crates.io-index"
74
- checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d"
74
+ checksum = "2bd389a4b2970a01282ee455294913c0a43724daedcd1a24c3eb0ec1c1320b66"
75
75
  dependencies = [
76
76
  "anstyle",
77
77
  "bstr",
@@ -91,15 +91,15 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
91
91
 
92
92
  [[package]]
93
93
  name = "bitflags"
94
- version = "2.8.0"
94
+ version = "2.9.1"
95
95
  source = "registry+https://github.com/rust-lang/crates.io-index"
96
- checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
96
+ checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
97
97
 
98
98
  [[package]]
99
99
  name = "bstr"
100
- version = "1.11.3"
100
+ version = "1.12.0"
101
101
  source = "registry+https://github.com/rust-lang/crates.io-index"
102
- checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0"
102
+ checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
103
103
  dependencies = [
104
104
  "memchr",
105
105
  "regex-automata",
@@ -126,9 +126,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
126
126
 
127
127
  [[package]]
128
128
  name = "clap"
129
- version = "4.5.28"
129
+ version = "4.5.39"
130
130
  source = "registry+https://github.com/rust-lang/crates.io-index"
131
- checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff"
131
+ checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f"
132
132
  dependencies = [
133
133
  "clap_builder",
134
134
  "clap_derive",
@@ -136,9 +136,9 @@ dependencies = [
136
136
 
137
137
  [[package]]
138
138
  name = "clap_builder"
139
- version = "4.5.27"
139
+ version = "4.5.39"
140
140
  source = "registry+https://github.com/rust-lang/crates.io-index"
141
- checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7"
141
+ checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51"
142
142
  dependencies = [
143
143
  "anstream",
144
144
  "anstyle",
@@ -148,14 +148,14 @@ dependencies = [
148
148
 
149
149
  [[package]]
150
150
  name = "clap_derive"
151
- version = "4.5.28"
151
+ version = "4.5.32"
152
152
  source = "registry+https://github.com/rust-lang/crates.io-index"
153
- checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed"
153
+ checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
154
154
  dependencies = [
155
155
  "heck 0.5.0",
156
156
  "proc-macro2",
157
157
  "quote",
158
- "syn 2.0.98",
158
+ "syn 2.0.101",
159
159
  ]
160
160
 
161
161
  [[package]]
@@ -195,9 +195,9 @@ dependencies = [
195
195
 
196
196
  [[package]]
197
197
  name = "crossbeam-channel"
198
- version = "0.5.14"
198
+ version = "0.5.15"
199
199
  source = "registry+https://github.com/rust-lang/crates.io-index"
200
- checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471"
200
+ checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
201
201
  dependencies = [
202
202
  "crossbeam-utils",
203
203
  ]
@@ -238,9 +238,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
238
238
 
239
239
  [[package]]
240
240
  name = "ctrlc"
241
- version = "3.4.5"
241
+ version = "3.4.7"
242
242
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3"
243
+ checksum = "46f93780a459b7d656ef7f071fe699c4d3d2cb201c4b24d085b6ddc505276e73"
244
244
  dependencies = [
245
245
  "nix",
246
246
  "windows-sys",
@@ -326,9 +326,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
326
326
 
327
327
  [[package]]
328
328
  name = "either"
329
- version = "1.13.0"
329
+ version = "1.15.0"
330
330
  source = "registry+https://github.com/rust-lang/crates.io-index"
331
- checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
331
+ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
332
332
 
333
333
  [[package]]
334
334
  name = "env_logger"
@@ -345,9 +345,9 @@ dependencies = [
345
345
 
346
346
  [[package]]
347
347
  name = "equivalent"
348
- version = "1.0.1"
348
+ version = "1.0.2"
349
349
  source = "registry+https://github.com/rust-lang/crates.io-index"
350
- checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
350
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
351
351
 
352
352
  [[package]]
353
353
  name = "float-cmp"
@@ -372,14 +372,14 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
372
372
 
373
373
  [[package]]
374
374
  name = "getset"
375
- version = "0.1.4"
375
+ version = "0.1.5"
376
376
  source = "registry+https://github.com/rust-lang/crates.io-index"
377
- checksum = "eded738faa0e88d3abc9d1a13cb11adc2073c400969eeb8793cf7132589959fc"
377
+ checksum = "f3586f256131df87204eb733da72e3d3eb4f343c639f4b7be279ac7c48baeafe"
378
378
  dependencies = [
379
379
  "proc-macro-error2",
380
380
  "proc-macro2",
381
381
  "quote",
382
- "syn 2.0.98",
382
+ "syn 2.0.101",
383
383
  ]
384
384
 
385
385
  [[package]]
@@ -390,9 +390,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
390
390
 
391
391
  [[package]]
392
392
  name = "hashbrown"
393
- version = "0.15.2"
393
+ version = "0.15.3"
394
394
  source = "registry+https://github.com/rust-lang/crates.io-index"
395
- checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
395
+ checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
396
396
 
397
397
  [[package]]
398
398
  name = "heck"
@@ -408,15 +408,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
408
408
 
409
409
  [[package]]
410
410
  name = "hermit-abi"
411
- version = "0.4.0"
411
+ version = "0.5.1"
412
412
  source = "registry+https://github.com/rust-lang/crates.io-index"
413
- checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
413
+ checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
414
414
 
415
415
  [[package]]
416
416
  name = "humantime"
417
- version = "2.1.0"
417
+ version = "2.2.0"
418
418
  source = "registry+https://github.com/rust-lang/crates.io-index"
419
- checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
419
+ checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f"
420
420
 
421
421
  [[package]]
422
422
  name = "ident_case"
@@ -426,9 +426,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
426
426
 
427
427
  [[package]]
428
428
  name = "indexmap"
429
- version = "2.7.1"
429
+ version = "2.9.0"
430
430
  source = "registry+https://github.com/rust-lang/crates.io-index"
431
- checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
431
+ checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
432
432
  dependencies = [
433
433
  "equivalent",
434
434
  "hashbrown",
@@ -436,15 +436,15 @@ dependencies = [
436
436
 
437
437
  [[package]]
438
438
  name = "indoc"
439
- version = "2.0.5"
439
+ version = "2.0.6"
440
440
  source = "registry+https://github.com/rust-lang/crates.io-index"
441
- checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
441
+ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
442
442
 
443
443
  [[package]]
444
444
  name = "is-terminal"
445
- version = "0.4.15"
445
+ version = "0.4.16"
446
446
  source = "registry+https://github.com/rust-lang/crates.io-index"
447
- checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
447
+ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
448
448
  dependencies = [
449
449
  "hermit-abi",
450
450
  "libc",
@@ -468,9 +468,9 @@ dependencies = [
468
468
 
469
469
  [[package]]
470
470
  name = "itoa"
471
- version = "1.0.14"
471
+ version = "1.0.15"
472
472
  source = "registry+https://github.com/rust-lang/crates.io-index"
473
- checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
473
+ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
474
474
 
475
475
  [[package]]
476
476
  name = "json"
@@ -496,15 +496,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
496
496
 
497
497
  [[package]]
498
498
  name = "libc"
499
- version = "0.2.169"
499
+ version = "0.2.172"
500
500
  source = "registry+https://github.com/rust-lang/crates.io-index"
501
- checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
501
+ checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
502
502
 
503
503
  [[package]]
504
504
  name = "lock_api"
505
- version = "0.4.12"
505
+ version = "0.4.13"
506
506
  source = "registry+https://github.com/rust-lang/crates.io-index"
507
- checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
507
+ checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
508
508
  dependencies = [
509
509
  "autocfg",
510
510
  "scopeguard",
@@ -512,9 +512,9 @@ dependencies = [
512
512
 
513
513
  [[package]]
514
514
  name = "log"
515
- version = "0.4.25"
515
+ version = "0.4.27"
516
516
  source = "registry+https://github.com/rust-lang/crates.io-index"
517
- checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
517
+ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
518
518
 
519
519
  [[package]]
520
520
  name = "memchr"
@@ -533,9 +533,9 @@ dependencies = [
533
533
 
534
534
  [[package]]
535
535
  name = "nix"
536
- version = "0.29.0"
536
+ version = "0.30.1"
537
537
  source = "registry+https://github.com/rust-lang/crates.io-index"
538
- checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
538
+ checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
539
539
  dependencies = [
540
540
  "bitflags",
541
541
  "cfg-if",
@@ -560,15 +560,21 @@ dependencies = [
560
560
 
561
561
  [[package]]
562
562
  name = "once_cell"
563
- version = "1.20.2"
563
+ version = "1.21.3"
564
+ source = "registry+https://github.com/rust-lang/crates.io-index"
565
+ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
566
+
567
+ [[package]]
568
+ name = "once_cell_polyfill"
569
+ version = "1.70.1"
564
570
  source = "registry+https://github.com/rust-lang/crates.io-index"
565
- checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
571
+ checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
566
572
 
567
573
  [[package]]
568
574
  name = "parking_lot"
569
- version = "0.12.3"
575
+ version = "0.12.4"
570
576
  source = "registry+https://github.com/rust-lang/crates.io-index"
571
- checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
577
+ checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
572
578
  dependencies = [
573
579
  "lock_api",
574
580
  "parking_lot_core",
@@ -576,9 +582,9 @@ dependencies = [
576
582
 
577
583
  [[package]]
578
584
  name = "parking_lot_core"
579
- version = "0.9.10"
585
+ version = "0.9.11"
580
586
  source = "registry+https://github.com/rust-lang/crates.io-index"
581
- checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
587
+ checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
582
588
  dependencies = [
583
589
  "cfg-if",
584
590
  "libc",
@@ -589,7 +595,7 @@ dependencies = [
589
595
 
590
596
  [[package]]
591
597
  name = "piranha"
592
- version = "0.3.29"
598
+ version = "0.3.32"
593
599
  dependencies = [
594
600
  "assert_cmd",
595
601
  "cc",
@@ -632,9 +638,9 @@ dependencies = [
632
638
 
633
639
  [[package]]
634
640
  name = "portable-atomic"
635
- version = "1.10.0"
641
+ version = "1.11.0"
636
642
  source = "registry+https://github.com/rust-lang/crates.io-index"
637
- checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
643
+ checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
638
644
 
639
645
  [[package]]
640
646
  name = "predicates"
@@ -685,14 +691,14 @@ dependencies = [
685
691
  "proc-macro-error-attr2",
686
692
  "proc-macro2",
687
693
  "quote",
688
- "syn 2.0.98",
694
+ "syn 2.0.101",
689
695
  ]
690
696
 
691
697
  [[package]]
692
698
  name = "proc-macro2"
693
- version = "1.0.93"
699
+ version = "1.0.95"
694
700
  source = "registry+https://github.com/rust-lang/crates.io-index"
695
- checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
701
+ checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
696
702
  dependencies = [
697
703
  "unicode-ident",
698
704
  ]
@@ -755,7 +761,7 @@ dependencies = [
755
761
  "proc-macro2",
756
762
  "pyo3-macros-backend",
757
763
  "quote",
758
- "syn 2.0.98",
764
+ "syn 2.0.101",
759
765
  ]
760
766
 
761
767
  [[package]]
@@ -768,14 +774,14 @@ dependencies = [
768
774
  "proc-macro2",
769
775
  "pyo3-build-config",
770
776
  "quote",
771
- "syn 2.0.98",
777
+ "syn 2.0.101",
772
778
  ]
773
779
 
774
780
  [[package]]
775
781
  name = "quote"
776
- version = "1.0.38"
782
+ version = "1.0.40"
777
783
  source = "registry+https://github.com/rust-lang/crates.io-index"
778
- checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
784
+ checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
779
785
  dependencies = [
780
786
  "proc-macro2",
781
787
  ]
@@ -839,9 +845,9 @@ dependencies = [
839
845
 
840
846
  [[package]]
841
847
  name = "redox_syscall"
842
- version = "0.5.8"
848
+ version = "0.5.12"
843
849
  source = "registry+https://github.com/rust-lang/crates.io-index"
844
- checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
850
+ checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af"
845
851
  dependencies = [
846
852
  "bitflags",
847
853
  ]
@@ -886,9 +892,9 @@ dependencies = [
886
892
 
887
893
  [[package]]
888
894
  name = "ryu"
889
- version = "1.0.19"
895
+ version = "1.0.20"
890
896
  source = "registry+https://github.com/rust-lang/crates.io-index"
891
- checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
897
+ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
892
898
 
893
899
  [[package]]
894
900
  name = "scopeguard"
@@ -898,29 +904,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
898
904
 
899
905
  [[package]]
900
906
  name = "serde"
901
- version = "1.0.217"
907
+ version = "1.0.219"
902
908
  source = "registry+https://github.com/rust-lang/crates.io-index"
903
- checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
909
+ checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
904
910
  dependencies = [
905
911
  "serde_derive",
906
912
  ]
907
913
 
908
914
  [[package]]
909
915
  name = "serde_derive"
910
- version = "1.0.217"
916
+ version = "1.0.219"
911
917
  source = "registry+https://github.com/rust-lang/crates.io-index"
912
- checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
918
+ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
913
919
  dependencies = [
914
920
  "proc-macro2",
915
921
  "quote",
916
- "syn 2.0.98",
922
+ "syn 2.0.101",
917
923
  ]
918
924
 
919
925
  [[package]]
920
926
  name = "serde_json"
921
- version = "1.0.138"
927
+ version = "1.0.140"
922
928
  source = "registry+https://github.com/rust-lang/crates.io-index"
923
- checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
929
+ checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
924
930
  dependencies = [
925
931
  "itoa",
926
932
  "memchr",
@@ -939,9 +945,9 @@ dependencies = [
939
945
 
940
946
  [[package]]
941
947
  name = "smallvec"
942
- version = "1.13.2"
948
+ version = "1.15.0"
943
949
  source = "registry+https://github.com/rust-lang/crates.io-index"
944
- checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
950
+ checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
945
951
 
946
952
  [[package]]
947
953
  name = "strsim"
@@ -968,9 +974,9 @@ dependencies = [
968
974
 
969
975
  [[package]]
970
976
  name = "syn"
971
- version = "2.0.98"
977
+ version = "2.0.101"
972
978
  source = "registry+https://github.com/rust-lang/crates.io-index"
973
- checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
979
+ checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
974
980
  dependencies = [
975
981
  "proc-macro2",
976
982
  "quote",
@@ -1010,9 +1016,9 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
1010
1016
 
1011
1017
  [[package]]
1012
1018
  name = "toml"
1013
- version = "0.8.19"
1019
+ version = "0.8.22"
1014
1020
  source = "registry+https://github.com/rust-lang/crates.io-index"
1015
- checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
1021
+ checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
1016
1022
  dependencies = [
1017
1023
  "serde",
1018
1024
  "serde_spanned",
@@ -1022,26 +1028,33 @@ dependencies = [
1022
1028
 
1023
1029
  [[package]]
1024
1030
  name = "toml_datetime"
1025
- version = "0.6.8"
1031
+ version = "0.6.9"
1026
1032
  source = "registry+https://github.com/rust-lang/crates.io-index"
1027
- checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
1033
+ checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
1028
1034
  dependencies = [
1029
1035
  "serde",
1030
1036
  ]
1031
1037
 
1032
1038
  [[package]]
1033
1039
  name = "toml_edit"
1034
- version = "0.22.23"
1040
+ version = "0.22.26"
1035
1041
  source = "registry+https://github.com/rust-lang/crates.io-index"
1036
- checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee"
1042
+ checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
1037
1043
  dependencies = [
1038
1044
  "indexmap",
1039
1045
  "serde",
1040
1046
  "serde_spanned",
1041
1047
  "toml_datetime",
1048
+ "toml_write",
1042
1049
  "winnow",
1043
1050
  ]
1044
1051
 
1052
+ [[package]]
1053
+ name = "toml_write"
1054
+ version = "0.1.1"
1055
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1056
+ checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
1057
+
1045
1058
  [[package]]
1046
1059
  name = "tree-sitter"
1047
1060
  version = "0.20.10"
@@ -1074,8 +1087,7 @@ dependencies = [
1074
1087
  [[package]]
1075
1088
  name = "tree-sitter-kotlin"
1076
1089
  version = "0.3.5"
1077
- source = "registry+https://github.com/rust-lang/crates.io-index"
1078
- checksum = "8df217a0e1fec649f3e13157de932439f3d37ea4e265038dd0873971ef56e726"
1090
+ source = "git+https://github.com/danieltrt/tree-sitter-kotlin?rev=8eb82b294900b66965ecfe39cdcbb8b16c99ff71#8eb82b294900b66965ecfe39cdcbb8b16c99ff71"
1079
1091
  dependencies = [
1080
1092
  "cc",
1081
1093
  "tree-sitter",
@@ -1180,15 +1192,15 @@ dependencies = [
1180
1192
 
1181
1193
  [[package]]
1182
1194
  name = "unicode-ident"
1183
- version = "1.0.16"
1195
+ version = "1.0.18"
1184
1196
  source = "registry+https://github.com/rust-lang/crates.io-index"
1185
- checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
1197
+ checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
1186
1198
 
1187
1199
  [[package]]
1188
1200
  name = "unindent"
1189
- version = "0.2.3"
1201
+ version = "0.2.4"
1190
1202
  source = "registry+https://github.com/rust-lang/crates.io-index"
1191
- checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
1203
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
1192
1204
 
1193
1205
  [[package]]
1194
1206
  name = "utf8parse"
@@ -1311,9 +1323,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1311
1323
 
1312
1324
  [[package]]
1313
1325
  name = "winnow"
1314
- version = "0.7.1"
1326
+ version = "0.7.10"
1315
1327
  source = "registry+https://github.com/rust-lang/crates.io-index"
1316
- checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f"
1328
+ checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec"
1317
1329
  dependencies = [
1318
1330
  "memchr",
1319
1331
  ]
@@ -2,7 +2,7 @@
2
2
  authors = ["Uber Technologies Inc."]
3
3
  name = "piranha"
4
4
  description = "Polyglot Piranha is a library for performing structural find and replace with deep cleanup."
5
- version = "0.3.29"
5
+ version = "0.3.32"
6
6
  edition = "2021"
7
7
  include = ["pyproject.toml", "src/"]
8
8
  exclude = ["legacy"]
@@ -47,7 +47,9 @@ serde_json = "1.0.82"
47
47
  ctrlc = "3.4"
48
48
 
49
49
  # TODO: Update if we upgrade tree-sitter to >=0.21
50
- tree-sitter-kotlin = "=0.3.5"
50
+ # Kotlin's grammar needs to fix the way it parses unary expressions (currently -a + b gets parsed as - (a +b)).
51
+ # Once we upstream the fix, we can point to the official version.
52
+ tree-sitter-kotlin = { git = "https://github.com/danieltrt/tree-sitter-kotlin", rev = "8eb82b294900b66965ecfe39cdcbb8b16c99ff71" }
51
53
  tree-sitter-java = "0.20.2"
52
54
  # TODO: Update after: https://github.com/alex-pinkus/tree-sitter-swift/issues/278 resolves
53
55
  tree-sitter-swift = { git = "https://github.com/satyam1749/tree-sitter-swift.git", rev = "08a28993599f1968bc81631a89690503e1db7704" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyglot_piranha
3
- Version: 0.3.29
3
+ Version: 0.3.32
4
4
  License-File: LICENSE
5
5
  License-File: NOTICE
6
6
  Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
@@ -192,6 +192,10 @@ pub(crate) fn default_is_seed_rule() -> bool {
192
192
  true
193
193
  }
194
194
 
195
+ pub(crate) fn default_keep_comment_regexes() -> HashSet<String> {
196
+ HashSet::new()
197
+ }
198
+
195
199
  pub(crate) fn default_allow_dirty_ast() -> bool {
196
200
  false
197
201
  }
@@ -18,6 +18,7 @@ use getset::{Getters, MutGetters};
18
18
  use itertools::Itertools;
19
19
  use log::trace;
20
20
  use pyo3::prelude::{pyclass, pymethods};
21
+ use regex::Regex;
21
22
  use serde_derive::{Deserialize, Serialize};
22
23
  use tree_sitter::Node;
23
24
 
@@ -120,9 +121,10 @@ impl Match {
120
121
  // Populates the leading and trailing comma and comment ranges for the match.
121
122
  fn populate_associated_elements(
122
123
  &mut self, node: &Node, code: &String, piranha_arguments: &PiranhaArguments,
124
+ compiled_regexes: Vec<Regex>,
123
125
  ) {
124
- self.get_associated_elements(node, code, piranha_arguments, true);
125
- self.get_associated_elements(node, code, piranha_arguments, false);
126
+ self.get_associated_elements(node, code, piranha_arguments, true, &compiled_regexes);
127
+ self.get_associated_elements(node, code, piranha_arguments, false, &compiled_regexes);
126
128
  self.get_associated_leading_empty_lines(node, code);
127
129
  }
128
130
 
@@ -182,6 +184,7 @@ impl Match {
182
184
  /// We currently capture leading and trailing comments and commas.
183
185
  fn get_associated_elements(
184
186
  &mut self, node: &Node, code: &String, piranha_arguments: &PiranhaArguments, trailing: bool,
187
+ keep_comment_regexes: &[Regex],
185
188
  ) {
186
189
  let mut current_node = *node;
187
190
  let mut buf = *piranha_arguments.cleanup_comments_buffer();
@@ -200,8 +203,13 @@ impl Match {
200
203
  current_node = sibling;
201
204
  continue; // Continue the inner loop (i.e. evaluate next sibling)
202
205
  } else if self._is_comment_safe_to_delete(&sibling, node, piranha_arguments, trailing) {
203
- // Add the comment to the associated matches
204
- self.associated_comments.push(sibling.range().into());
206
+ let comment_text = sibling.utf8_text(code.as_bytes()).unwrap();
207
+ if !keep_comment_regexes
208
+ .iter()
209
+ .any(|re| re.is_match(comment_text))
210
+ {
211
+ self.associated_comments.push(sibling.range().into());
212
+ }
205
213
  current_node = sibling;
206
214
  continue; // Continue the inner loop (i.e. evaluate next sibling)
207
215
  }
@@ -490,7 +498,18 @@ impl SourceCodeUnit {
490
498
  p_match.range().end_byte,
491
499
  );
492
500
  if self.is_satisfied(matched_node, rule, p_match.matches(), rule_store) {
493
- p_match.populate_associated_elements(&matched_node, self.code(), self.piranha_arguments());
501
+ let compiled_regexes: Vec<Regex> = rule
502
+ .rule()
503
+ .keep_comment_regexes()
504
+ .iter()
505
+ .filter_map(|pattern| Regex::new(pattern).ok())
506
+ .collect();
507
+ p_match.populate_associated_elements(
508
+ &matched_node,
509
+ self.code(),
510
+ self.piranha_arguments(),
511
+ compiled_regexes,
512
+ );
494
513
  trace!("Found match {:#?}", p_match);
495
514
  output.push(p_match.clone());
496
515
  }
@@ -25,8 +25,9 @@ use crate::utilities::Instantiate;
25
25
  use super::{
26
26
  capture_group_patterns::CGPattern,
27
27
  default_configs::{
28
- default_filters, default_groups, default_holes, default_is_seed_rule, default_query,
29
- default_replace, default_replace_idx, default_replace_node, default_rule_name,
28
+ default_filters, default_groups, default_holes, default_is_seed_rule,
29
+ default_keep_comment_regexes, default_query, default_replace, default_replace_idx,
30
+ default_replace_node, default_rule_name,
30
31
  },
31
32
  filter::Filter,
32
33
  Validator,
@@ -95,6 +96,13 @@ pub struct Rule {
95
96
  #[get = "pub"]
96
97
  #[pyo3(get)]
97
98
  is_seed_rule: bool,
99
+
100
+ /// Marks comments as deletable
101
+ #[builder(default = "default_keep_comment_regexes()")]
102
+ #[serde(default = "default_keep_comment_regexes")]
103
+ #[get = "pub"]
104
+ #[pyo3(get)]
105
+ keep_comment_regexes: HashSet<String>,
98
106
  }
99
107
 
100
108
  impl Rule {
@@ -141,6 +149,7 @@ macro_rules! piranha_rule {
141
149
  $(, is_seed_rule = $is_seed_rule:expr)?
142
150
  $(, groups = [$($group_name: expr)*])?
143
151
  $(, filters = [$($filter:tt)*])?
152
+ $(, keep_comment_regexes = [$($rgex: expr)*])?
144
153
  ) => {
145
154
  $crate::models::rule::RuleBuilder::default()
146
155
  .name($name.to_string())
@@ -152,6 +161,7 @@ macro_rules! piranha_rule {
152
161
  $(.holes(std::collections::HashSet::from([$($hole.to_string(),)*])))?
153
162
  $(.groups(std::collections::HashSet::from([$($group_name.to_string(),)*])))?
154
163
  $(.filters(std::collections::HashSet::from([$($filter)*])))?
164
+ $(.keep_comment_regexes(std::collections::HashSet::from([$($rgex.to_string(),)*])))?
155
165
  .build().unwrap()
156
166
  };
157
167
  }
@@ -163,6 +173,7 @@ impl Rule {
163
173
  name: String, query: Option<String>, replace: Option<String>, replace_idx: Option<u8>,
164
174
  replace_node: Option<String>, holes: Option<HashSet<String>>, groups: Option<HashSet<String>>,
165
175
  filters: Option<HashSet<Filter>>, is_seed_rule: Option<bool>,
176
+ keep_comment_regexes: Option<HashSet<String>>,
166
177
  ) -> Self {
167
178
  let mut rule_builder = RuleBuilder::default();
168
179
 
@@ -199,6 +210,10 @@ impl Rule {
199
210
  rule_builder.is_seed_rule(is_seed_rule);
200
211
  }
201
212
 
213
+ if let Some(keep_comment_regexes) = keep_comment_regexes {
214
+ rule_builder.keep_comment_regexes(keep_comment_regexes);
215
+ }
216
+
202
217
  rule_builder.build().unwrap()
203
218
  }
204
219
 
@@ -235,6 +235,7 @@ fn test_get_edit_for_context_positive() {
235
235
  let mut rule_store = RuleStore::default();
236
236
  let args = PiranhaArgumentsBuilder::default()
237
237
  .paths_to_codebase(vec![UNUSED_CODE_PATH.to_string()])
238
+ .language(PiranhaLanguage::from(JAVA))
238
239
  .build();
239
240
  let mut parser = args.language().parser();
240
241
 
@@ -284,6 +285,7 @@ fn test_get_edit_for_context_negative() {
284
285
 
285
286
  let args = PiranhaArgumentsBuilder::default()
286
287
  .paths_to_codebase(vec![UNUSED_CODE_PATH.to_string()])
288
+ .language(PiranhaLanguage::from(JAVA))
287
289
  .build();
288
290
  let mut parser = args.language().parser();
289
291
 
@@ -381,3 +383,65 @@ fn test_satisfies_filter_not_enclosing_node_negative() {
381
383
  |result| result,
382
384
  );
383
385
  }
386
+
387
+ /// Tests whether comments are preserved when delete_comments is set to false
388
+ #[test]
389
+ fn test_rule_delete_comments() {
390
+ println!("Starting test...");
391
+ let _rule = piranha_rule! {
392
+ name= "delete_invoc",
393
+ query= "((method_invocation) @m (#eq? @m \"variable.set_value(true)\"))",
394
+ replace_node = "m",
395
+ replace = "",
396
+ keep_comment_regexes = ["// Given .*"]
397
+ };
398
+
399
+ let rule = InstantiatedRule::new(&_rule, &HashMap::new());
400
+ let source_code = "class Test {
401
+ public void foobar(){
402
+ // Given something
403
+ // This is an explanatory comment
404
+ // This is another explanatory comment
405
+ variable.set_value(true);
406
+ other_variable.set_value(false);
407
+
408
+ // When
409
+ var result = data.Something();
410
+
411
+ // Then
412
+ assertTrue(\"This is a test\", result);
413
+ }
414
+ }";
415
+
416
+ let mut rule_store = RuleStore::default();
417
+
418
+ let args = PiranhaArgumentsBuilder::default()
419
+ .paths_to_codebase(vec![UNUSED_CODE_PATH.to_string()])
420
+ .language(PiranhaLanguage::from(JAVA))
421
+ .cleanup_comments(true)
422
+ .build();
423
+ let mut parser = args.language().parser();
424
+
425
+ let mut source_code_unit = SourceCodeUnit::new(
426
+ &mut parser,
427
+ source_code.to_string(),
428
+ &HashMap::new(),
429
+ PathBuf::new().as_path(),
430
+ &args,
431
+ );
432
+ let node = source_code_unit.root_node();
433
+ let matches = source_code_unit.get_matches(&rule, &mut rule_store, node, true);
434
+ assert!(!matches.is_empty());
435
+
436
+ let edit = source_code_unit.get_edit(&rule, &mut rule_store, node, true);
437
+ assert!(edit.is_some());
438
+ let edit = edit.unwrap();
439
+ // Apply the edit to the source code unit
440
+ source_code_unit.apply_edit(&edit, &mut parser);
441
+
442
+ let edited_code = source_code_unit.code();
443
+ assert!(edited_code.contains("// Given something"));
444
+ assert!(!edited_code.contains("// This is another explanatory comment"));
445
+ assert!(!edited_code.contains("// This is an explanatory comment"));
446
+ assert!(!edited_code.contains("variable.set_value(true);"));
447
+ }