polyglot-piranha 0.3.35__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/Cargo.lock +164 -21
  2. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/Cargo.toml +3 -1
  3. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/PKG-INFO +12 -1
  4. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/README.md +9 -0
  5. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/pyproject.toml +7 -1
  6. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/utils.rs +5 -3
  7. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/lib.rs +0 -1
  8. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/main.rs +1 -1
  9. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/capture_group_patterns.rs +11 -10
  10. polyglot_piranha-0.4.0/src/models/concrete_syntax/concrete_syntax.pest +22 -0
  11. polyglot_piranha-0.4.0/src/models/concrete_syntax/constraint_checker.rs +29 -0
  12. polyglot_piranha-0.4.0/src/models/concrete_syntax/cursor_utils.rs +66 -0
  13. polyglot_piranha-0.4.0/src/models/concrete_syntax/interpreter.rs +448 -0
  14. polyglot_piranha-0.4.0/src/models/concrete_syntax/mod.rs +19 -0
  15. polyglot_piranha-0.4.0/src/models/concrete_syntax/parser.rs +236 -0
  16. polyglot_piranha-0.4.0/src/models/concrete_syntax/resolver.rs +92 -0
  17. polyglot_piranha-0.4.0/src/models/concrete_syntax/types.rs +103 -0
  18. polyglot_piranha-0.3.35/src/models/unit_tests/concrete_syntax_test.rs → polyglot_piranha-0.4.0/src/models/concrete_syntax/unit_tests/interpreter_test.rs +61 -6
  19. polyglot_piranha-0.4.0/src/models/concrete_syntax/unit_tests/parser_test.rs +346 -0
  20. polyglot_piranha-0.4.0/src/models/concrete_syntax/unit_tests/resolver_test.rs +117 -0
  21. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/edit.rs +2 -2
  22. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/filter.rs +2 -2
  23. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/matches.rs +4 -4
  24. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/mod.rs +2 -1
  25. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/outgoing_edges.rs +1 -1
  26. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/piranha_arguments.rs +1 -1
  27. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/piranha_output.rs +1 -1
  28. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/rule.rs +1 -1
  29. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/rule_graph.rs +4 -4
  30. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/rule_store.rs +1 -1
  31. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/utilities/tree_sitter_utilities.rs +1 -1
  32. polyglot_piranha-0.3.35/src/models/concrete_syntax.rs +0 -367
  33. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/LICENSE +0 -0
  34. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/NOTICE +0 -0
  35. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/plugins/pyproject.toml +0 -0
  36. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/polyglot_piranha.pyi +0 -0
  37. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/go/edges.toml +0 -0
  38. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/go/rules.toml +0 -0
  39. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/go/scope_config.toml +0 -0
  40. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java/edges.toml +0 -0
  41. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java/rules.toml +0 -0
  42. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java/scope_config.toml +0 -0
  43. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java_cs/edges.toml +0 -0
  44. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java_cs/rules.toml +0 -0
  45. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/java_cs/scope_config.toml +0 -0
  46. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/kt/edges.toml +0 -0
  47. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/kt/rules.toml +0 -0
  48. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/kt/scope_config.toml +0 -0
  49. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/ruby/edges.toml +0 -0
  50. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/ruby/rules.toml +0 -0
  51. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/ruby/scope_config.toml +0 -0
  52. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/scala/scope_config.toml +0 -0
  53. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/swift/edges.toml +0 -0
  54. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/swift/rules.toml +0 -0
  55. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/cleanup_rules/swift/scope_config.toml +0 -0
  56. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/README.md +0 -0
  57. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/analysis.rs +0 -0
  58. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/mod.rs +0 -0
  59. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/tag_analysis.rs +0 -0
  60. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/df/unit_tests/tag_analysis_test.rs +0 -0
  61. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/default_configs.rs +0 -0
  62. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/language.rs +0 -0
  63. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/scopes.rs +0 -0
  64. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/source_code_unit.rs +0 -0
  65. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/piranha_arguments_test.rs +0 -0
  66. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/rule_graph_validation_test.rs +0 -0
  67. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/rule_test.rs +0 -0
  68. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/scopes_test.rs +0 -0
  69. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/source_code_unit_test.rs +0 -0
  70. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/testdata/custom_builtin/edges.toml +0 -0
  71. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/models/unit_tests/testdata/custom_builtin/rules.toml +0 -0
  72. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/mod.rs +0 -0
  73. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_go.rs +0 -0
  74. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_java.rs +0 -0
  75. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_kt.rs +0 -0
  76. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_python.rs +0 -0
  77. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_scala.rs +0 -0
  78. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_scm.rs +0 -0
  79. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_strings.rs +0 -0
  80. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_swift.rs +0 -0
  81. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_thrift.rs +0 -0
  82. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_ts.rs +0 -0
  83. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_tsx.rs +0 -0
  84. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/tests/test_piranha_yaml.rs +0 -0
  85. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/utilities/mod.rs +0 -0
  86. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/utilities/regex_utilities.rs +0 -0
  87. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/utilities/unit_tests/tree_sitter_utilities_test.rs +0 -0
  88. {polyglot_piranha-0.3.35 → polyglot_piranha-0.4.0}/src/utilities/unit_tests/utilities_test.rs +0 -0
@@ -85,9 +85,9 @@ dependencies = [
85
85
 
86
86
  [[package]]
87
87
  name = "autocfg"
88
- version = "1.4.0"
88
+ version = "1.5.0"
89
89
  source = "registry+https://github.com/rust-lang/crates.io-index"
90
- checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
90
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
91
91
 
92
92
  [[package]]
93
93
  name = "bitflags"
@@ -95,6 +95,15 @@ version = "2.9.1"
95
95
  source = "registry+https://github.com/rust-lang/crates.io-index"
96
96
  checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
97
97
 
98
+ [[package]]
99
+ name = "block-buffer"
100
+ version = "0.10.4"
101
+ source = "registry+https://github.com/rust-lang/crates.io-index"
102
+ checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
103
+ dependencies = [
104
+ "generic-array",
105
+ ]
106
+
98
107
  [[package]]
99
108
  name = "bstr"
100
109
  version = "1.12.0"
@@ -155,7 +164,7 @@ dependencies = [
155
164
  "heck 0.5.0",
156
165
  "proc-macro2",
157
166
  "quote",
158
- "syn 2.0.102",
167
+ "syn 2.0.104",
159
168
  ]
160
169
 
161
170
  [[package]]
@@ -180,6 +189,15 @@ dependencies = [
180
189
  "windows-sys",
181
190
  ]
182
191
 
192
+ [[package]]
193
+ name = "cpufeatures"
194
+ version = "0.2.17"
195
+ source = "registry+https://github.com/rust-lang/crates.io-index"
196
+ checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
197
+ dependencies = [
198
+ "libc",
199
+ ]
200
+
183
201
  [[package]]
184
202
  name = "crossbeam"
185
203
  version = "0.8.4"
@@ -236,6 +254,16 @@ version = "0.8.21"
236
254
  source = "registry+https://github.com/rust-lang/crates.io-index"
237
255
  checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
238
256
 
257
+ [[package]]
258
+ name = "crypto-common"
259
+ version = "0.1.6"
260
+ source = "registry+https://github.com/rust-lang/crates.io-index"
261
+ checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
262
+ dependencies = [
263
+ "generic-array",
264
+ "typenum",
265
+ ]
266
+
239
267
  [[package]]
240
268
  name = "ctrlc"
241
269
  version = "3.4.7"
@@ -318,6 +346,16 @@ version = "0.4.0"
318
346
  source = "registry+https://github.com/rust-lang/crates.io-index"
319
347
  checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
320
348
 
349
+ [[package]]
350
+ name = "digest"
351
+ version = "0.10.7"
352
+ source = "registry+https://github.com/rust-lang/crates.io-index"
353
+ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
354
+ dependencies = [
355
+ "block-buffer",
356
+ "crypto-common",
357
+ ]
358
+
321
359
  [[package]]
322
360
  name = "doc-comment"
323
361
  version = "0.3.3"
@@ -370,16 +408,26 @@ version = "0.1.1"
370
408
  source = "registry+https://github.com/rust-lang/crates.io-index"
371
409
  checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
372
410
 
411
+ [[package]]
412
+ name = "generic-array"
413
+ version = "0.14.7"
414
+ source = "registry+https://github.com/rust-lang/crates.io-index"
415
+ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
416
+ dependencies = [
417
+ "typenum",
418
+ "version_check",
419
+ ]
420
+
373
421
  [[package]]
374
422
  name = "getset"
375
- version = "0.1.5"
423
+ version = "0.1.6"
376
424
  source = "registry+https://github.com/rust-lang/crates.io-index"
377
- checksum = "f3586f256131df87204eb733da72e3d3eb4f343c639f4b7be279ac7c48baeafe"
425
+ checksum = "9cf0fc11e47561d47397154977bc219f4cf809b2974facc3ccb3b89e2436f912"
378
426
  dependencies = [
379
427
  "proc-macro-error2",
380
428
  "proc-macro2",
381
429
  "quote",
382
- "syn 2.0.102",
430
+ "syn 2.0.104",
383
431
  ]
384
432
 
385
433
  [[package]]
@@ -408,9 +456,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
408
456
 
409
457
  [[package]]
410
458
  name = "hermit-abi"
411
- version = "0.5.1"
459
+ version = "0.5.2"
412
460
  source = "registry+https://github.com/rust-lang/crates.io-index"
413
- checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
461
+ checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
414
462
 
415
463
  [[package]]
416
464
  name = "humantime"
@@ -426,9 +474,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
426
474
 
427
475
  [[package]]
428
476
  name = "indexmap"
429
- version = "2.9.0"
477
+ version = "2.10.0"
430
478
  source = "registry+https://github.com/rust-lang/crates.io-index"
431
- checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
479
+ checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
432
480
  dependencies = [
433
481
  "equivalent",
434
482
  "hashbrown",
@@ -496,9 +544,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
496
544
 
497
545
  [[package]]
498
546
  name = "libc"
499
- version = "0.2.172"
547
+ version = "0.2.174"
500
548
  source = "registry+https://github.com/rust-lang/crates.io-index"
501
- checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
549
+ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
502
550
 
503
551
  [[package]]
504
552
  name = "lock_api"
@@ -593,9 +641,53 @@ dependencies = [
593
641
  "windows-targets",
594
642
  ]
595
643
 
644
+ [[package]]
645
+ name = "pest"
646
+ version = "2.8.1"
647
+ source = "registry+https://github.com/rust-lang/crates.io-index"
648
+ checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
649
+ dependencies = [
650
+ "memchr",
651
+ "thiserror",
652
+ "ucd-trie",
653
+ ]
654
+
655
+ [[package]]
656
+ name = "pest_derive"
657
+ version = "2.8.1"
658
+ source = "registry+https://github.com/rust-lang/crates.io-index"
659
+ checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc"
660
+ dependencies = [
661
+ "pest",
662
+ "pest_generator",
663
+ ]
664
+
665
+ [[package]]
666
+ name = "pest_generator"
667
+ version = "2.8.1"
668
+ source = "registry+https://github.com/rust-lang/crates.io-index"
669
+ checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966"
670
+ dependencies = [
671
+ "pest",
672
+ "pest_meta",
673
+ "proc-macro2",
674
+ "quote",
675
+ "syn 2.0.104",
676
+ ]
677
+
678
+ [[package]]
679
+ name = "pest_meta"
680
+ version = "2.8.1"
681
+ source = "registry+https://github.com/rust-lang/crates.io-index"
682
+ checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5"
683
+ dependencies = [
684
+ "pest",
685
+ "sha2",
686
+ ]
687
+
596
688
  [[package]]
597
689
  name = "piranha"
598
- version = "0.3.35"
690
+ version = "0.4.0"
599
691
  dependencies = [
600
692
  "assert_cmd",
601
693
  "cc",
@@ -611,6 +703,8 @@ dependencies = [
611
703
  "jwalk",
612
704
  "lazy_static",
613
705
  "log",
706
+ "pest",
707
+ "pest_derive",
614
708
  "predicates",
615
709
  "pyo3",
616
710
  "pyo3-log",
@@ -691,7 +785,7 @@ dependencies = [
691
785
  "proc-macro-error-attr2",
692
786
  "proc-macro2",
693
787
  "quote",
694
- "syn 2.0.102",
788
+ "syn 2.0.104",
695
789
  ]
696
790
 
697
791
  [[package]]
@@ -761,7 +855,7 @@ dependencies = [
761
855
  "proc-macro2",
762
856
  "pyo3-macros-backend",
763
857
  "quote",
764
- "syn 2.0.102",
858
+ "syn 2.0.104",
765
859
  ]
766
860
 
767
861
  [[package]]
@@ -774,7 +868,7 @@ dependencies = [
774
868
  "proc-macro2",
775
869
  "pyo3-build-config",
776
870
  "quote",
777
- "syn 2.0.102",
871
+ "syn 2.0.104",
778
872
  ]
779
873
 
780
874
  [[package]]
@@ -845,9 +939,9 @@ dependencies = [
845
939
 
846
940
  [[package]]
847
941
  name = "redox_syscall"
848
- version = "0.5.12"
942
+ version = "0.5.13"
849
943
  source = "registry+https://github.com/rust-lang/crates.io-index"
850
- checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af"
944
+ checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
851
945
  dependencies = [
852
946
  "bitflags",
853
947
  ]
@@ -919,7 +1013,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
919
1013
  dependencies = [
920
1014
  "proc-macro2",
921
1015
  "quote",
922
- "syn 2.0.102",
1016
+ "syn 2.0.104",
923
1017
  ]
924
1018
 
925
1019
  [[package]]
@@ -943,6 +1037,17 @@ dependencies = [
943
1037
  "serde",
944
1038
  ]
945
1039
 
1040
+ [[package]]
1041
+ name = "sha2"
1042
+ version = "0.10.9"
1043
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1044
+ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
1045
+ dependencies = [
1046
+ "cfg-if",
1047
+ "cpufeatures",
1048
+ "digest",
1049
+ ]
1050
+
946
1051
  [[package]]
947
1052
  name = "smallvec"
948
1053
  version = "1.15.1"
@@ -974,9 +1079,9 @@ dependencies = [
974
1079
 
975
1080
  [[package]]
976
1081
  name = "syn"
977
- version = "2.0.102"
1082
+ version = "2.0.104"
978
1083
  source = "registry+https://github.com/rust-lang/crates.io-index"
979
- checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462"
1084
+ checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
980
1085
  dependencies = [
981
1086
  "proc-macro2",
982
1087
  "quote",
@@ -1014,6 +1119,26 @@ version = "0.5.1"
1014
1119
  source = "registry+https://github.com/rust-lang/crates.io-index"
1015
1120
  checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
1016
1121
 
1122
+ [[package]]
1123
+ name = "thiserror"
1124
+ version = "2.0.12"
1125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1126
+ checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
1127
+ dependencies = [
1128
+ "thiserror-impl",
1129
+ ]
1130
+
1131
+ [[package]]
1132
+ name = "thiserror-impl"
1133
+ version = "2.0.12"
1134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1135
+ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
1136
+ dependencies = [
1137
+ "proc-macro2",
1138
+ "quote",
1139
+ "syn 2.0.104",
1140
+ ]
1141
+
1017
1142
  [[package]]
1018
1143
  name = "toml"
1019
1144
  version = "0.8.23"
@@ -1190,6 +1315,18 @@ dependencies = [
1190
1315
  "tree-sitter",
1191
1316
  ]
1192
1317
 
1318
+ [[package]]
1319
+ name = "typenum"
1320
+ version = "1.18.0"
1321
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1322
+ checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
1323
+
1324
+ [[package]]
1325
+ name = "ucd-trie"
1326
+ version = "0.1.7"
1327
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1328
+ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
1329
+
1193
1330
  [[package]]
1194
1331
  name = "unicode-ident"
1195
1332
  version = "1.0.18"
@@ -1208,6 +1345,12 @@ version = "0.2.2"
1208
1345
  source = "registry+https://github.com/rust-lang/crates.io-index"
1209
1346
  checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
1210
1347
 
1348
+ [[package]]
1349
+ name = "version_check"
1350
+ version = "0.9.5"
1351
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1352
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
1353
+
1211
1354
  [[package]]
1212
1355
  name = "wait-timeout"
1213
1356
  version = "0.2.1"
@@ -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.35"
5
+ version = "0.4.0"
6
6
  edition = "2021"
7
7
  include = ["pyproject.toml", "src/"]
8
8
  exclude = ["legacy"]
@@ -70,6 +70,8 @@ pyo3 = "0.20.0"
70
70
  pyo3-log = "0.9.0"
71
71
  glob = "0.3.1"
72
72
  lazy_static = "1.4.0"
73
+ pest = "2.8.1"
74
+ pest_derive = "2.8.1"
73
75
 
74
76
  [features]
75
77
  extension-module = ["pyo3/extension-module"]
@@ -1,6 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyglot_piranha
3
- Version: 0.3.35
3
+ Version: 0.4.0
4
+ Requires-Dist: pytest>=8.0 ; extra == 'dev'
5
+ Provides-Extra: dev
4
6
  License-File: LICENSE
5
7
  License-File: NOTICE
6
8
  Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
@@ -114,6 +116,15 @@ A few additional links on Piranha:
114
116
 
115
117
  If you have any questions on how to use Piranha or find any bugs, please [open a GitHub issue](https://github.com/uber/piranha/issues).
116
118
 
119
+ ## Piranha Development
120
+
121
+ Piranha uses several grammar repositories with custom patches to support the transformations. While
122
+ these patches are being upstreamed, there may be discrepancies between the grammars in this
123
+ repository and the upstream grammars. Therefore, we have built a custom tree-sitter playground
124
+ that can be used to test the grammars and queries for easier development:
125
+
126
+ https://uber.github.io/piranha/tree-sitter-playground/
127
+
117
128
  ## License
118
129
  Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
119
130
 
@@ -99,6 +99,15 @@ A few additional links on Piranha:
99
99
 
100
100
  If you have any questions on how to use Piranha or find any bugs, please [open a GitHub issue](https://github.com/uber/piranha/issues).
101
101
 
102
+ ## Piranha Development
103
+
104
+ Piranha uses several grammar repositories with custom patches to support the transformations. While
105
+ these patches are being upstreamed, there may be discrepancies between the grammars in this
106
+ repository and the upstream grammars. Therefore, we have built a custom tree-sitter playground
107
+ that can be used to test the grammars and queries for easier development:
108
+
109
+ https://uber.github.io/piranha/tree-sitter-playground/
110
+
102
111
  ## License
103
112
  Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
104
113
 
@@ -20,9 +20,15 @@ documentation = "https://github.com/uber/piranha"
20
20
  repository = "https://github.com/uber/piranha"
21
21
 
22
22
  [build-system]
23
- requires = ["maturin>=1.4.0,<2.0"]
23
+ # There is a bug with maturin 1.9.0 that incorrectly packages LICENSE file causing a problem.
24
+ # For now we have to pin it to 1.8.7 (last stable version).
25
+ # TODO: remove this check once maturin is fixed.
26
+ requires = ["maturin>=1.4.0,<=1.8.7"]
24
27
  build-backend = "maturin"
25
28
 
29
+ [project.optional-dependencies]
30
+ dev = ["pytest>=8.0"]
31
+
26
32
  [tool.maturin]
27
33
  bindings = "pyo3"
28
34
  include = ["LICENSE", "NOTICE", "polyglot_piranha.pyi"]
@@ -34,6 +34,7 @@ pub fn get_capture_groups_from_matcher(node: &Rule) -> Vec<String> {
34
34
  match &node.query().pattern_type() {
35
35
  PatternType::Tsq => get_capture_groups_from_tsq(node.query().pattern()),
36
36
  PatternType::Regex => get_capture_groups_from_regex(node.query().extract_regex().unwrap()),
37
+ PatternType::Cs => vec![],
37
38
  PatternType::Unknown => vec![],
38
39
  }
39
40
  }
@@ -47,6 +48,7 @@ pub fn get_capture_group_usage_from_matcher(node: &Rule) -> Vec<String> {
47
48
  match &node.query().pattern_type() {
48
49
  PatternType::Tsq => get_capture_group_usage_from_tsq(node.query().pattern()),
49
50
  PatternType::Regex => get_capture_group_usage_from_regex(node.query().pattern()),
51
+ PatternType::Cs => vec![],
50
52
  PatternType::Unknown => vec![],
51
53
  }
52
54
  }
@@ -57,7 +59,7 @@ pub fn get_capture_groups_from_regex(re: Regex) -> Vec<String> {
57
59
 
58
60
  // Check all capture names (i.e., named groups) in the pattern
59
61
  for capture_name in re.capture_names().flatten() {
60
- let tag = format!("@{}", capture_name);
62
+ let tag = format!("@{capture_name}");
61
63
  tags.push(tag);
62
64
  }
63
65
  tags
@@ -110,7 +112,7 @@ pub fn get_capture_groups_from_tsq(pattern: String) -> Vec<String> {
110
112
  })
111
113
  .unwrap_or_default();
112
114
 
113
- log::debug!("capture_groups: {:?}", capture_groups);
115
+ log::debug!("capture_groups: {capture_groups:?}");
114
116
 
115
117
  capture_groups
116
118
  }
@@ -164,6 +166,6 @@ pub fn get_capture_group_usage_from_tsq(pattern: String) -> Vec<String> {
164
166
  .map(|mat| mat.as_str().to_owned())
165
167
  .collect();
166
168
 
167
- log::debug!("capture_groups: {:?}", capture_groups);
169
+ log::debug!("capture_groups: {capture_groups:?}");
168
170
  capture_groups
169
171
  }
@@ -21,7 +21,6 @@ use models::{
21
21
  extern crate lazy_static;
22
22
  pub mod df;
23
23
  pub mod models;
24
-
25
24
  #[cfg(test)]
26
25
  mod tests;
27
26
  pub mod utilities;
@@ -35,7 +35,7 @@ fn main() {
35
35
 
36
36
  let args = PiranhaArguments::from_cli();
37
37
 
38
- debug!("Piranha Arguments are \n{:#?}", args);
38
+ debug!("Piranha Arguments are \n{args:#?}");
39
39
  let piranha_output_summaries = execute_piranha(&args);
40
40
 
41
41
  if let Some(path) = args.path_to_output_summary() {
@@ -11,7 +11,8 @@ Copyright (c) 2023 Uber Technologies, Inc.
11
11
  limitations under the License.
12
12
  */
13
13
 
14
- use crate::models::concrete_syntax::get_all_matches_for_concrete_syntax;
14
+ use crate::models::concrete_syntax::interpreter::get_all_matches_for_concrete_syntax;
15
+ use crate::models::concrete_syntax::parser::ConcreteSyntax;
15
16
  use crate::{
16
17
  models::Validator,
17
18
  utilities::{
@@ -26,8 +27,6 @@ use serde_derive::Deserialize;
26
27
  use std::collections::HashMap;
27
28
  use tree_sitter::{Node, Query};
28
29
 
29
- #[derive(Debug)]
30
- pub struct ConcreteSyntax(pub String);
31
30
  use super::{
32
31
  default_configs::{CONCRETE_SYNTAX_QUERY_PREFIX, REGEX_QUERY_PREFIX},
33
32
  matches::Match,
@@ -36,6 +35,7 @@ use super::{
36
35
  pub enum PatternType {
37
36
  Tsq,
38
37
  Regex,
38
+ Cs,
39
39
  Unknown,
40
40
  }
41
41
 
@@ -59,13 +59,14 @@ impl CGPattern {
59
59
 
60
60
  pub(crate) fn extract_concrete_syntax(&self) -> ConcreteSyntax {
61
61
  let mut _val = &self.pattern()[CONCRETE_SYNTAX_QUERY_PREFIX.len()..];
62
- ConcreteSyntax(_val.to_string())
62
+ ConcreteSyntax::parse(_val).unwrap()
63
63
  }
64
64
 
65
65
  pub(crate) fn pattern_type(&self) -> PatternType {
66
66
  match self.0.as_str() {
67
67
  pattern if pattern.starts_with("rgx") => PatternType::Regex,
68
68
  pattern if pattern.trim().starts_with('(') => PatternType::Tsq,
69
+ pattern if pattern.trim().starts_with("cs") => PatternType::Cs,
69
70
  _ => PatternType::Unknown,
70
71
  }
71
72
  }
@@ -132,7 +133,6 @@ impl CompiledCGPattern {
132
133
  &self, node: &Node, source_code: String, recursive: bool, replace_node: Option<String>,
133
134
  replace_node_idx: Option<u8>,
134
135
  ) -> Vec<Match> {
135
- let code_str = source_code.as_bytes();
136
136
  match self {
137
137
  CompiledCGPattern::Q(query) => get_all_matches_for_query(
138
138
  node,
@@ -146,14 +146,15 @@ impl CompiledCGPattern {
146
146
  get_all_matches_for_regex(node, source_code, regex, recursive, replace_node)
147
147
  }
148
148
  CompiledCGPattern::M(concrete_syntax) => {
149
- let matches = get_all_matches_for_concrete_syntax(
149
+ let source_code_ref = source_code.as_bytes();
150
+ let resolved_syntax = concrete_syntax.clone().resolve().unwrap();
151
+ get_all_matches_for_concrete_syntax(
150
152
  node,
151
- code_str,
152
- concrete_syntax,
153
+ source_code_ref,
154
+ &resolved_syntax,
153
155
  recursive,
154
156
  replace_node,
155
- );
156
- matches.0
157
+ )
157
158
  }
158
159
  }
159
160
  }
@@ -0,0 +1,22 @@
1
+ // Concrete Syntax Grammar for Piranha
2
+ concrete_syntax = { SOI ~ pattern ~ EOI }
3
+ pattern = { (element)+ ~ ("|>" ~ constraints)? }
4
+
5
+ // An element is either a capture or literal text
6
+ element = _{ capture | literal_text }
7
+
8
+ // Captures: :[name], :[name+], :[name*], @name
9
+ capture = { (":[" ~ identifier ~ capture_mode? ~ "]") | "@"~identifier } // FIXME: Should remove @ from the grammar, because literals may be parsed incorrectly
10
+ capture_mode = { "+" | "*" }
11
+ identifier = { (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
12
+
13
+ // Literal text - single word/token without whitespace
14
+ literal_text = { (!( ":[" | "|>" | "@" ) ~ ANY)+ }
15
+ WHITESPACE = _{ (" " | "\t" | "\r" | "\n")+ }
16
+
17
+ // Where constraints (extensible for future constraint types)
18
+ constraints = { constraint ~ ("," ~ constraint)* }
19
+ constraint = { in_constraint }
20
+ in_constraint = { capture ~ "in" ~ "[" ~ list_items? ~ "]" }
21
+ list_items = { quoted_string ~ ("," ~ quoted_string)* }
22
+ quoted_string = { "\"" ~ ( "\\\\" | "\\\"" | (!"\"" ~ ANY) )* ~ "\"" }
@@ -0,0 +1,29 @@
1
+ /*
2
+ Copyright (c) 2023 Uber Technologies, Inc.
3
+
4
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5
+ except in compliance with the License. You may obtain a copy of the License at
6
+ <p>http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
9
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
10
+ express or implied. See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+
14
+ use crate::models::concrete_syntax::parser::CsConstraint;
15
+ use crate::models::concrete_syntax::types::CapturedNode;
16
+
17
+ /// Check if a captured node satisfies a single constraint
18
+ pub(crate) fn check_constraint(node: &CapturedNode, ctr: &CsConstraint) -> bool {
19
+ match ctr {
20
+ CsConstraint::In { items, .. } => items.contains(&node.text.to_string()),
21
+ }
22
+ }
23
+
24
+ /// Check if a captured node satisfies all constraints
25
+ pub(crate) fn satisfies_constraints(node: &CapturedNode, constraints: &[CsConstraint]) -> bool {
26
+ constraints
27
+ .iter()
28
+ .all(|constraint| check_constraint(node, constraint))
29
+ }
@@ -0,0 +1,66 @@
1
+ /*
2
+ Copyright (c) 2023 Uber Technologies, Inc.
3
+
4
+ <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5
+ except in compliance with the License. You may obtain a copy of the License at
6
+ <p>http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ <p>Unless required by applicable law or agreed to in writing, software distributed under the
9
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
10
+ express or implied. See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+
14
+ use crate::models::matches::Range;
15
+ use tree_sitter::{Node, TreeCursor};
16
+
17
+ /// Cursor navigation utilities for tree traversal during pattern matching.
18
+ pub struct CursorNavigator;
19
+
20
+ impl CursorNavigator {
21
+ /// Advances the cursor to the next sibling, or if no sibling exists,
22
+ /// moves up to the parent and tries to find the next sibling at that level.
23
+ pub fn find_next_sibling_or_ancestor_sibling(cursor: &mut TreeCursor) -> bool {
24
+ while !cursor.goto_next_sibling() {
25
+ if !cursor.goto_parent() {
26
+ return false;
27
+ }
28
+ }
29
+ true
30
+ }
31
+
32
+ /// Skips over comment nodes by advancing the cursor to the next non-comment sibling.
33
+ /// If the current node is not a comment, the cursor position remains unchanged.
34
+ pub fn skip_comment_nodes(cursor: &mut TreeCursor) {
35
+ let mut node = cursor.node();
36
+ while node.kind().contains("comment") && cursor.goto_next_sibling() {
37
+ node = cursor.node();
38
+ }
39
+ }
40
+
41
+ /// Finds the index of a target node among its parent's children.
42
+ pub fn find_child_index(target_node: &Node, parent_node: &Node) -> Option<usize> {
43
+ parent_node
44
+ .children(&mut parent_node.walk())
45
+ .enumerate()
46
+ .find(|&(_i, child)| child == *target_node)
47
+ .map(|(i, _child)| i)
48
+ }
49
+
50
+ /// Creates a range that spans from the start of the first node to the end of the second node.
51
+ pub fn span_node_ranges(first_node: &Node, last_node: &Node) -> Range {
52
+ Range::span_ranges(first_node.range(), last_node.range())
53
+ }
54
+
55
+ /// Extracts text from source code within the specified byte range.
56
+ pub fn get_text_from_range(start_byte: usize, end_byte: usize, source_code: &[u8]) -> String {
57
+ let text_slice = &source_code[start_byte..end_byte];
58
+ String::from_utf8_lossy(text_slice).to_string()
59
+ }
60
+ }
61
+
62
+ #[cfg(test)]
63
+ mod tests {
64
+
65
+ // Tests will be added as we migrate functionality
66
+ }