ast-merge 7.1.22 → 8.0.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.md +3 -6
- data/README.md +28 -12
- data/lib/ast/merge/ast_node.rb +9 -9
- data/lib/ast/merge/comment/README.md +4 -4
- data/lib/ast/merge/comment/attachment.rb +14 -14
- data/lib/ast/merge/comment/augmenter.rb +18 -18
- data/lib/ast/merge/comment/block.rb +7 -7
- data/lib/ast/merge/comment/c_style_tracker_base.rb +11 -11
- data/lib/ast/merge/comment/capability.rb +1 -1
- data/lib/ast/merge/comment/empty.rb +3 -3
- data/lib/ast/merge/comment/hash_tracker_base.rb +14 -14
- data/lib/ast/merge/comment/line.rb +5 -5
- data/lib/ast/merge/comment/parser.rb +3 -3
- data/lib/ast/merge/comment/quoted_hash_line_parser.rb +7 -7
- data/lib/ast/merge/comment/region.rb +1 -1
- data/lib/ast/merge/comment/style.rb +14 -14
- data/lib/ast/merge/comment/support_style.rb +1 -1
- data/lib/ast/merge/comment/tracked_hash_adapter.rb +8 -8
- data/lib/ast/merge/comment.rb +15 -15
- data/lib/ast/merge/comment_layout_emission_support.rb +26 -26
- data/lib/ast/merge/conflict_resolver_base.rb +17 -17
- data/lib/ast/merge/content_match_refiner.rb +3 -3
- data/lib/ast/merge/debug_logger.rb +14 -14
- data/lib/ast/merge/detector/README.md +4 -4
- data/lib/ast/merge/detector/base.rb +11 -11
- data/lib/ast/merge/detector/fenced_code_block.rb +23 -23
- data/lib/ast/merge/detector/mergeable.rb +6 -6
- data/lib/ast/merge/detector/toml_frontmatter.rb +1 -1
- data/lib/ast/merge/detector/yaml_frontmatter.rb +1 -1
- data/lib/ast/merge/diff_mapper_base.rb +7 -7
- data/lib/ast/merge/emitter_base.rb +24 -24
- data/lib/ast/merge/file_aligner_base.rb +7 -5
- data/lib/ast/merge/file_analyzable.rb +68 -68
- data/lib/ast/merge/freeze_node_base.rb +5 -5
- data/lib/ast/merge/healer.rb +1 -1
- data/lib/ast/merge/jaccard_similarity.rb +4 -4
- data/lib/ast/merge/key_path_partial_template_merger_base.rb +10 -10
- data/lib/ast/merge/layout/README.md +1 -1
- data/lib/ast/merge/layout/augmenter.rb +27 -27
- data/lib/ast/merge/layout/gap.rb +14 -14
- data/lib/ast/merge/layout.rb +4 -4
- data/lib/ast/merge/match_refiner_base.rb +2 -2
- data/lib/ast/merge/match_score_base.rb +1 -1
- data/lib/ast/merge/merge_result_base.rb +19 -19
- data/lib/ast/merge/merger_config.rb +9 -9
- data/lib/ast/merge/navigable/injection_point.rb +3 -3
- data/lib/ast/merge/navigable/injection_point_finder.rb +2 -2
- data/lib/ast/merge/navigable/statement.rb +1 -1
- data/lib/ast/merge/navigable.rb +3 -3
- data/lib/ast/merge/node_typing/frozen_wrapper.rb +1 -1
- data/lib/ast/merge/node_typing.rb +8 -8
- data/lib/ast/merge/node_wrapper_base.rb +2 -2
- data/lib/ast/merge/owner_selection.rb +1 -1
- data/lib/ast/merge/partial_template_merger_base.rb +13 -13
- data/lib/ast/merge/portable_benchmark_contract.rb +198 -198
- data/lib/ast/merge/provider_contract.rb +10 -10
- data/lib/ast/merge/provider_registry.rb +2 -2
- data/lib/ast/merge/provider_result.rb +2 -2
- data/lib/ast/merge/recipe/config.rb +42 -42
- data/lib/ast/merge/recipe/preset.rb +17 -17
- data/lib/ast/merge/recipe/runner.rb +75 -75
- data/lib/ast/merge/recipe/script_loader.rb +8 -8
- data/lib/ast/merge/recipe.rb +4 -4
- data/lib/ast/merge/rspec/README.md +15 -15
- data/lib/ast/merge/rspec/comment_behavior_matrix_adapters.rb +5 -5
- data/lib/ast/merge/rspec/conformance_fixtures.rb +15 -15
- data/lib/ast/merge/rspec/dependency_tags.rb +2 -2
- data/lib/ast/merge/rspec/dependency_tags_config.rb +3 -3
- data/lib/ast/merge/rspec/dependency_tags_helpers.rb +1 -1
- data/lib/ast/merge/rspec/merge_gem_registry.rb +3 -3
- data/lib/ast/merge/rspec/provider_conformance.rb +4 -4
- data/lib/ast/merge/rspec/provider_snapshot.rb +49 -49
- data/lib/ast/merge/rspec/setup.rb +2 -2
- data/lib/ast/merge/rspec/shared_examples/comment_attachment.rb +5 -5
- data/lib/ast/merge/rspec/shared_examples/comment_augmenter.rb +4 -4
- data/lib/ast/merge/rspec/shared_examples/comment_behavior_matrix.rb +204 -204
- data/lib/ast/merge/rspec/shared_examples/comment_region.rb +5 -5
- data/lib/ast/merge/rspec/shared_examples/conflict_resolver_base.rb +82 -82
- data/lib/ast/merge/rspec/shared_examples/debug_logger.rb +55 -55
- data/lib/ast/merge/rspec/shared_examples/feature_profile.rb +6 -6
- data/lib/ast/merge/rspec/shared_examples/file_analyzable.rb +47 -47
- data/lib/ast/merge/rspec/shared_examples/freeze_node_base.rb +62 -62
- data/lib/ast/merge/rspec/shared_examples/layout_attachment.rb +4 -4
- data/lib/ast/merge/rspec/shared_examples/layout_augmenter.rb +3 -3
- data/lib/ast/merge/rspec/shared_examples/merge_result_base.rb +28 -28
- data/lib/ast/merge/rspec/shared_examples/merger_config.rb +66 -66
- data/lib/ast/merge/rspec/shared_examples/provider_conformance.rb +11 -11
- data/lib/ast/merge/rspec/shared_examples/recipe_preset_contract.rb +13 -13
- data/lib/ast/merge/rspec/shared_examples/recursive_retained_blank_gap_compliance.rb +4 -4
- data/lib/ast/merge/rspec/shared_examples/removal_mode_compliance.rb +8 -8
- data/lib/ast/merge/rspec/shared_examples/reproducible_merge.rb +8 -8
- data/lib/ast/merge/rspec/shared_examples/reproducible_partial_merge.rb +7 -7
- data/lib/ast/merge/rspec/shared_examples/retained_blank_gap_compliance.rb +16 -16
- data/lib/ast/merge/rspec/shared_examples/runtime_debug_contract.rb +27 -27
- data/lib/ast/merge/rspec/shared_examples/tree_haver_backend_contract.rb +1 -1
- data/lib/ast/merge/rspec/shared_examples/unresolved_helper_contract.rb +56 -56
- data/lib/ast/merge/rspec/shared_examples/unresolved_review_state_transport_contract.rb +8 -8
- data/lib/ast/merge/rspec/shared_examples/unresolved_runtime_contract.rb +11 -11
- data/lib/ast/merge/rspec/shared_examples/unresolved_runtime_debug_contract.rb +10 -10
- data/lib/ast/merge/rspec/shared_examples.rb +28 -28
- data/lib/ast/merge/rspec.rb +5 -5
- data/lib/ast/merge/ruleset/config.rb +15 -15
- data/lib/ast/merge/ruleset/feature_profile.rb +14 -14
- data/lib/ast/merge/ruleset/parser.rb +9 -9
- data/lib/ast/merge/ruleset/profile_vocabulary.rb +16 -16
- data/lib/ast/merge/ruleset/runtime_declaration.rb +8 -8
- data/lib/ast/merge/ruleset.rb +11 -11
- data/lib/ast/merge/runtime/child_result.rb +6 -6
- data/lib/ast/merge/runtime/delegate.rb +9 -9
- data/lib/ast/merge/runtime/frame.rb +5 -5
- data/lib/ast/merge/runtime/operation.rb +10 -10
- data/lib/ast/merge/runtime/resolution_case.rb +15 -15
- data/lib/ast/merge/runtime/root_session_support.rb +3 -3
- data/lib/ast/merge/runtime/surface.rb +8 -8
- data/lib/ast/merge/runtime.rb +10 -10
- data/lib/ast/merge/rust_host_provider.rb +63 -63
- data/lib/ast/merge/section_typing.rb +4 -4
- data/lib/ast/merge/smart_merger_base.rb +7 -7
- data/lib/ast/merge/source_region_report_support.rb +59 -59
- data/lib/ast/merge/source_render/fragment.rb +6 -6
- data/lib/ast/merge/source_render/plan.rb +5 -5
- data/lib/ast/merge/source_render/renderer.rb +8 -8
- data/lib/ast/merge/source_render.rb +6 -6
- data/lib/ast/merge/structural_edit/README.md +5 -5
- data/lib/ast/merge/structural_edit/boundary.rb +1 -1
- data/lib/ast/merge/structural_edit/boundary_support.rb +3 -3
- data/lib/ast/merge/structural_edit/plan_set.rb +5 -5
- data/lib/ast/merge/structural_edit/rehome_plan.rb +4 -4
- data/lib/ast/merge/structural_edit/remove_plan.rb +9 -9
- data/lib/ast/merge/structural_edit/remove_plan_support.rb +1 -1
- data/lib/ast/merge/structural_edit/splice_plan.rb +11 -11
- data/lib/ast/merge/structural_edit.rb +8 -8
- data/lib/ast/merge/structured_review_apply_support.rb +2 -2
- data/lib/ast/merge/text/README.md +2 -2
- data/lib/ast/merge/text/conflict_resolver.rb +4 -4
- data/lib/ast/merge/text/file_analysis.rb +4 -4
- data/lib/ast/merge/text/line_node.rb +3 -3
- data/lib/ast/merge/text/section.rb +3 -3
- data/lib/ast/merge/text/section_splitter.rb +5 -5
- data/lib/ast/merge/text/smart_merger.rb +1 -1
- data/lib/ast/merge/text/word_node.rb +2 -2
- data/lib/ast/merge/text.rb +10 -10
- data/lib/ast/merge/token_match_refiner.rb +6 -6
- data/lib/ast/merge/trailing_groups/core.rb +4 -4
- data/lib/ast/merge/trailing_groups.rb +3 -3
- data/lib/ast/merge/typed_core_provider.rb +76 -76
- data/lib/ast/merge/unresolved_policy.rb +2 -2
- data/lib/ast/merge/unresolved_review_state.rb +5 -5
- data/lib/ast/merge/unresolved_support.rb +12 -12
- data/lib/ast/merge/version.rb +1 -1
- data/lib/ast/merge.rb +1410 -1410
- data/lib/ast-merge.rb +3 -3
- data/sig/ast/merge.rbs +5 -0
- data.tar.gz.sig +0 -0
- metadata +11 -12
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e956cb8f4fd2b0daf5f7f2a2e640968ce0ef98877e36549787da2dbdb3bb4b0
|
|
4
|
+
data.tar.gz: b599a42dc67109569ef83d925acfdd09fcffda9038d3554da1e9591b4f689556
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6488367ae70c5280ee1a4ccd77e6460554b4d7fa3404ef720be967394cd94b4f3536b487a7ba72ebf9159c2b52dc669bb9759f72cd0fea76b807c3b942298c8b
|
|
7
|
+
data.tar.gz: 6ffc067d41243f6340b6c26622b9e2ed8b06b5f85b6a3219d5165cd4667e65375cee1ae7b65ebd4614390cd62057e1d81cec3863f9a6458ba08d74394d0030ad
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/LICENSE.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# License
|
|
2
2
|
|
|
3
|
-
This project is made available under the following
|
|
3
|
+
This project is made available under the following license.
|
|
4
4
|
Choose the option that best fits your use case:
|
|
5
5
|
|
|
6
|
-
- [
|
|
7
|
-
- [PolyForm-Small-Business-1.0.0](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/PolyForm-Small-Business-1.0.0.md)
|
|
8
|
-
|
|
9
|
-
If none of the above licenses fit your use case, please [contact us](mailto:floss@galtzo.com) to discuss a custom commercial license.
|
|
6
|
+
- [MIT](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md)
|
|
10
7
|
|
|
11
8
|
## Copyright Notice
|
|
12
9
|
|
|
13
|
-
-
|
|
10
|
+
- Copyright (c) 2026 Peter H. Boling
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# ☯️ Ast::Merge
|
|
4
4
|
|
|
5
|
-
[![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License:
|
|
5
|
+
[![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: MIT][📄license-img]][📄license] [![Total downloads][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf]
|
|
6
6
|
|
|
7
7
|
`if ci_badges.map(&:color).detect { it != "green"}` ☝️ [let me know on Discord][✉️discord-invite] or [RubyForum][✉️ruby-forum], as I may have missed the notification.
|
|
8
8
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
[![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][🖇paypal-img]][🖇paypal] [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] [![Donate at ko-fi.com][🖇kofi-img]][🖇kofi]
|
|
12
12
|
|
|
13
13
|
<!-- kettle-sponsors:shields:start -->
|
|
14
|
+
<a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/github.svg" alt="services: GitHub"></a> <a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/healthsherpa.svg" alt="sponsor: HealthSherpa"></a> <a href="#corporate-sponsorship"><img src="https://logos.galtzo.com/assets/images/sponsors/shield/microsoft.svg" alt="compute: Microsoft"></a>
|
|
14
15
|
<!-- kettle-sponsors:shields:end -->
|
|
15
16
|
|
|
16
17
|
## 🌻 Synopsis <a href="https://discord.gg/3qme4XHNKN"><img alt="Galtzo FLOSS Logo by Aboling0, CC BY-SA 4.0" src="https://logos.galtzo.com/assets/images/galtzo-floss/avatar-128px.svg" width="8%" align="right"/></a> <a href="https://ruby-toolbox.com"><img alt="ruby-lang Logo, Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5" src="https://logos.galtzo.com/assets/images/ruby-lang/avatar-128px.svg" width="8%" align="right"/></a>
|
|
@@ -460,6 +461,17 @@ end
|
|
|
460
461
|
- `"Ast::Merge::FileAnalysisBase"` - Tests for FileAnalysis implementations
|
|
461
462
|
- `"Ast::Merge::MergerConfig"` - Tests for SmartMerger implementations
|
|
462
463
|
|
|
464
|
+
## 🏢 Corporate Sponsorship
|
|
465
|
+
|
|
466
|
+
<!-- kettle-sponsors:cards:start -->
|
|
467
|
+
<a href="https://github.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/github.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/github.svg" align="top" alt="Sponsor: GitHub - Copilot Max"></picture></a> <a href="https://healthsherpa.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/healthsherpa.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/healthsherpa.svg" align="top" alt="Sponsor: HealthSherpa - GitHub Sponsors => @pboling (maintainer)"></picture></a> <a href="https://opensource.microsoft.com"><picture><source media="(max-width: 600px)" srcset="https://logos.galtzo.com/assets/images/sponsors/phone/microsoft.svg"><img src="https://logos.galtzo.com/assets/images/sponsors/microsoft.svg" align="top" alt="Sponsor: Microsoft - Azure compute resources"></picture></a>
|
|
468
|
+
|
|
469
|
+
<sub>Create sponsorship badges for your project with [kettle-sponsors](https://github.com/kettle-dev/kettle-sponsors).</sub>
|
|
470
|
+
<!-- kettle-sponsors:cards:end -->
|
|
471
|
+
|
|
472
|
+
**If you're working in a company that's making significant use of structuredmerge tools we'd
|
|
473
|
+
appreciate it if you suggest to your company to become a structuredmerge sponsor.**
|
|
474
|
+
|
|
463
475
|
## 💡 Info you can shake a stick at
|
|
464
476
|
|
|
465
477
|
| Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
|
|
@@ -468,7 +480,7 @@ end
|
|
|
468
480
|
| Support & Community | [![Join Me on Daily.dev's RubyFriends][✉️ruby-friends-img]][✉️ruby-friends] [![Get help from RubyForum][✉️ruby-forum-img]][✉️ruby-forum] [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] [![Get help from me on Upwork][👨🏼🏫expsup-upwork-img]][👨🏼🏫expsup-upwork] [![Get help from me on Codementor][👨🏼🏫expsup-codementor-img]][👨🏼🏫expsup-codementor] |
|
|
469
481
|
| Source | [![Source on GitLab.com][📜src-gl-img]][📜src-gl] [![Source on CodeBerg.org][📜src-cb-img]][📜src-cb] [![Source on GitHub.com][📜src-gh-img]][📜src-gh] [![The best SHA: dQw4w9WgXcQ!][🧮kloc-img]][🧮kloc] |
|
|
470
482
|
| Documentation | [![Current release on RubyDoc.info][📜docs-cr-rd-img]][🚎yard-current] [![YARD on Galtzo.com][📜docs-head-rd-img]][🚎yard-head] [![Maintainer Blog][🚂maint-blog-img]][🚂maint-blog] [![GitLab Wiki][📜gl-wiki-img]][📜gl-wiki] [![GitHub Wiki][📜gh-wiki-img]][📜gh-wiki] |
|
|
471
|
-
| Compliance | [![License:
|
|
483
|
+
| Compliance | [![License: MIT][📄license-img]][📄license] [![Apache license compatibility: Category A][📄license-compat-img]][📄license-compat] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![Contributor Covenant 3.0][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] |
|
|
472
484
|
| Style | [![Enforced Code Style Linter][💎rlts-img]][💎rlts] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] [![Gitmoji Commits][📌gitmoji-img]][📌gitmoji] [![Compatibility appraised by: appraisal2][💎appraisal2-img]][💎appraisal2] |
|
|
473
485
|
| Maintainer 🎖️ | [![Follow Me on LinkedIn][💖🖇linkedin-img]][💖🖇linkedin] [![Follow Me on Ruby.Social][💖🐘ruby-mast-img]][💖🐘ruby-mast] [![Follow Me on Bluesky][💖🦋bluesky-img]][💖🦋bluesky] [![Contact Maintainer][🚂maint-contact-img]][🚂maint-contact] [![My technical writing][💖💁🏼♂️devto-img]][💖💁🏼♂️devto] |
|
|
474
486
|
| `...` 💖 | [![Find Me on WellFound:][💖✌️wellfound-img]][💖✌️wellfound] [![Find Me on CrunchBase][💖💲crunchbase-img]][💖💲crunchbase] [![My LinkTree][💖🌳linktree-img]][💖🌳linktree] [![More About Me][💖💁🏼♂️aboutme-img]][💖💁🏼♂️aboutme] [🧊][💖🧊berg] [🐙][💖🐙hub] [🛖][💖🛖hut] [🧪][💖🧪lab] |
|
|
@@ -515,6 +527,8 @@ We [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] so if you m
|
|
|
515
527
|
|
|
516
528
|
See [CONTRIBUTING.md][🤝contributing] for more detailed instructions.
|
|
517
529
|
|
|
530
|
+
Want to contribute with AI coding agents? This project is developed with [Cloudroom][🖇cloudroom] and ships an `AGENTS.md` with repo conventions so agents can jump straight in. Signing up with [my referral link][🖇cloudroom] also supports ongoing maintenance at no extra cost to you.
|
|
531
|
+
|
|
518
532
|
## 📌 Versioning
|
|
519
533
|
|
|
520
534
|
This library follows [![Semantic Versioning 2.0.0][📌semver-img]][📌semver] for its public API where practical.
|
|
@@ -543,10 +557,8 @@ See [CHANGELOG.md][📌changelog] for a list of releases.
|
|
|
543
557
|
|
|
544
558
|
## 📄 License
|
|
545
559
|
|
|
546
|
-
The gem is available under the
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
If none of the available licenses suit your use case, please [contact us](mailto:floss@galtzo.com) to discuss a custom commercial license.
|
|
560
|
+
The gem is available as open source under the terms of
|
|
561
|
+
the [MIT](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md) [![License: MIT][📄license-img]][📄license-ref].
|
|
550
562
|
|
|
551
563
|
### Please give the project a star ⭐ ♥.
|
|
552
564
|
|
|
@@ -556,6 +568,11 @@ If this project helps you, please consider supporting the maintainer. This is no
|
|
|
556
568
|
|
|
557
569
|
[![Sponsor me on GitHub Sponsors][🖇sponsor-bottom-img]][🖇sponsor] 💌 [![Sponsor me on Liberapay][⛳liberapay-bottom-img]][⛳liberapay] 💌 [![Donate on PayPal][🖇paypal-bottom-img]][🖇paypal] 💌 [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] 💌 [![Donate at ko-fi.com][🖇kofi-img]][🖇kofi]
|
|
558
570
|
|
|
571
|
+
I use [Cloudroom][🖇cloudroom], an agentic AI coding environment, every day. It's the first AI product that made me say "shut up and take my money."
|
|
572
|
+
If you sign up with [my referral link][🖇cloudroom], I receive a share of your subscription for as long as you stay subscribed, at no extra cost to you.
|
|
573
|
+
|
|
574
|
+
[🖇cloudroom]: https://go.cloudroom.dev/u9f53f181a
|
|
575
|
+
|
|
559
576
|
Thanks for RTFM. ☺️
|
|
560
577
|
|
|
561
578
|
[⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
|
|
@@ -613,7 +630,6 @@ Thanks for RTFM. ☺️
|
|
|
613
630
|
[💖🐙hub]: https://github.org/pboling
|
|
614
631
|
[💖🛖hut]: https://sr.ht/~galtzo/
|
|
615
632
|
[💖🧪lab]: https://gitlab.com/pboling
|
|
616
|
-
[🏙️entsup-tidelift-sonar]: https://blog.tidelift.com/tidelift-joins-sonar
|
|
617
633
|
[👨🏼🏫expsup-upwork]: https://www.upwork.com/freelancers/~014942e9b056abdf86?mp_source=share
|
|
618
634
|
[👨🏼🏫expsup-upwork-img]: https://img.shields.io/badge/UpWork-13544E?style=for-the-badge&logo=Upwork&logoColor=white
|
|
619
635
|
[👨🏼🏫expsup-codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
|
|
@@ -662,7 +678,7 @@ Thanks for RTFM. ☺️
|
|
|
662
678
|
[🖐contributors]: https://github.com/structuredmerge/structuredmerge-ruby/graphs/contributors
|
|
663
679
|
[🖐contributors-img]: https://contrib.rocks/image?repo=structuredmerge/structuredmerge-ruby
|
|
664
680
|
[🪇conduct]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/CODE_OF_CONDUCT.md
|
|
665
|
-
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-
|
|
681
|
+
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-3.0-259D6C.svg
|
|
666
682
|
[📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
|
667
683
|
[📌semver]: https://semver.org/spec/v2.0.0.html
|
|
668
684
|
[📌semver-img]: https://img.shields.io/badge/semver-2.0.0-259D6C.svg?style=flat
|
|
@@ -679,10 +695,10 @@ Thanks for RTFM. ☺️
|
|
|
679
695
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
680
696
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
681
697
|
[📄license]: LICENSE.md
|
|
682
|
-
[📄license-ref]:
|
|
683
|
-
[📄license-img]: https://img.shields.io/badge/License-
|
|
684
|
-
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-
|
|
685
|
-
[📄license-compat-img]: https://img.shields.io/badge/
|
|
698
|
+
[📄license-ref]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md
|
|
699
|
+
[📄license-img]: https://img.shields.io/badge/License-MIT-259D6C.svg
|
|
700
|
+
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-a
|
|
701
|
+
[📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-%E2%9C%93-259D6C.svg?style=flat&logo=Apache
|
|
686
702
|
|
|
687
703
|
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
|
|
688
704
|
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
|
data/lib/ast/merge/ast_node.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "tree_haver/base/node"
|
|
4
4
|
|
|
5
5
|
module Ast
|
|
6
6
|
module Merge
|
|
@@ -48,8 +48,8 @@ module Ast
|
|
|
48
48
|
# Hash-like access for compatibility
|
|
49
49
|
def [](key)
|
|
50
50
|
case key
|
|
51
|
-
when :row,
|
|
52
|
-
when :column,
|
|
51
|
+
when :row, "row" then row
|
|
52
|
+
when :column, "column" then column
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ module Ast
|
|
|
57
57
|
#
|
|
58
58
|
# @return [Hash{Symbol => Integer, nil}] row/column pair
|
|
59
59
|
def to_h
|
|
60
|
-
{
|
|
60
|
+
{row: row, column: column}
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# Return a compact human-readable point representation.
|
|
@@ -117,14 +117,14 @@ module Ast
|
|
|
117
117
|
# @return [String] Node type
|
|
118
118
|
def type
|
|
119
119
|
# Default: derive from class name (MyNode → "my_node")
|
|
120
|
-
self.class.name.split(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
self.class.name.split("::").last
|
|
121
|
+
.gsub(/([A-Z])/, '_\1')
|
|
122
|
+
.downcase
|
|
123
|
+
.sub(/^_/, "")
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
# Alias for tree-sitter compatibility
|
|
127
|
-
|
|
127
|
+
alias_method :kind, :type
|
|
128
128
|
|
|
129
129
|
# TreeHaver::Node protocol: text
|
|
130
130
|
# @return [String] The source text
|
|
@@ -32,7 +32,7 @@ You can inspect available styles with `Style.available_styles` and register cust
|
|
|
32
32
|
line = Ast::Merge::Comment::Line.new(
|
|
33
33
|
text: "# frozen_string_literal: true",
|
|
34
34
|
line_number: 1,
|
|
35
|
-
style: :hash_comment
|
|
35
|
+
style: :hash_comment
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
line.content
|
|
@@ -49,8 +49,8 @@ It can be built either from child line nodes or from raw block-comment text.
|
|
|
49
49
|
block = Ast::Merge::Comment::Block.new(
|
|
50
50
|
children: [
|
|
51
51
|
Ast::Merge::Comment::Line.new(text: "# one", line_number: 1),
|
|
52
|
-
Ast::Merge::Comment::Line.new(text: "# two", line_number: 2)
|
|
53
|
-
]
|
|
52
|
+
Ast::Merge::Comment::Line.new(text: "# two", line_number: 2)
|
|
53
|
+
]
|
|
54
54
|
)
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -69,7 +69,7 @@ empty = Ast::Merge::Comment::Empty.new(line_number: 3, text: "")
|
|
|
69
69
|
```ruby
|
|
70
70
|
nodes = Ast::Merge::Comment::Parser.parse(
|
|
71
71
|
["# heading", "", "# details"],
|
|
72
|
-
style: :hash_comment
|
|
72
|
+
style: :hash_comment
|
|
73
73
|
)
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -19,13 +19,13 @@ module Ast
|
|
|
19
19
|
# @return [Layout::Gap, nil] trailing layout gap associated with the owner
|
|
20
20
|
# @return [Hash] producer metadata for downstream consumers
|
|
21
21
|
attr_reader :owner,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
:leading_region,
|
|
23
|
+
:inline_region,
|
|
24
|
+
:trailing_region,
|
|
25
|
+
:orphan_regions,
|
|
26
|
+
:leading_gap,
|
|
27
|
+
:trailing_gap,
|
|
28
|
+
:metadata
|
|
29
29
|
|
|
30
30
|
# Build a passive comment attachment.
|
|
31
31
|
#
|
|
@@ -40,7 +40,7 @@ module Ast
|
|
|
40
40
|
# @param options [Hash] extra metadata merged into +metadata+
|
|
41
41
|
# @return [void]
|
|
42
42
|
def initialize(owner: nil, leading_region: nil, inline_region: nil, trailing_region: nil, orphan_regions: [],
|
|
43
|
-
|
|
43
|
+
leading_gap: nil, trailing_gap: nil, metadata: {}, **options)
|
|
44
44
|
@owner = owner
|
|
45
45
|
@leading_region = leading_region
|
|
46
46
|
@inline_region = inline_region
|
|
@@ -113,12 +113,12 @@ module Ast
|
|
|
113
113
|
# @return [String]
|
|
114
114
|
def inspect
|
|
115
115
|
owner_desc = if owner.respond_to?(:type)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
owner.method(:type).call
|
|
117
|
+
elsif owner.nil?
|
|
118
|
+
nil
|
|
119
|
+
else
|
|
120
|
+
owner.class.name
|
|
121
|
+
end
|
|
122
122
|
|
|
123
123
|
"#<#{self.class.name} owner=#{owner_desc.inspect} regions=#{regions.size} layout_gaps=#{layout_gaps.size}>"
|
|
124
124
|
end
|
|
@@ -11,15 +11,15 @@ module Ast
|
|
|
11
11
|
# objects that format gems can adopt incrementally.
|
|
12
12
|
class Augmenter
|
|
13
13
|
attr_reader :lines,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
:owners,
|
|
15
|
+
:tracked_comments,
|
|
16
|
+
:style,
|
|
17
|
+
:attachment_policy,
|
|
18
|
+
:capability,
|
|
19
|
+
:attachments_by_owner,
|
|
20
|
+
:preamble_region,
|
|
21
|
+
:postlude_region,
|
|
22
|
+
:orphan_regions
|
|
23
23
|
|
|
24
24
|
class << self
|
|
25
25
|
# Build an augmenter and run augmentation immediately.
|
|
@@ -32,7 +32,7 @@ module Ast
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def initialize(lines: nil, source: nil, comments: [], owners: [], style: nil, capability: nil,
|
|
35
|
-
|
|
35
|
+
attachment_policy: :preceding_owner, **options)
|
|
36
36
|
@lines = normalize_lines(lines, source)
|
|
37
37
|
@style = resolve_style(style)
|
|
38
38
|
@attachment_policy = normalize_attachment_policy(attachment_policy)
|
|
@@ -73,7 +73,7 @@ module Ast
|
|
|
73
73
|
leading.each { |comment| claimed << comment.object_id }
|
|
74
74
|
inline.each { |comment| claimed << comment.object_id }
|
|
75
75
|
trailing.each { |comment| claimed << comment.object_id }
|
|
76
|
-
[owner, {
|
|
76
|
+
[owner, {leading: leading, inline: inline, trailing: trailing}]
|
|
77
77
|
end
|
|
78
78
|
layout_attachments = build_layout_attachments_by_owner
|
|
79
79
|
|
|
@@ -217,10 +217,10 @@ module Ast
|
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
kind = if first_owner_start && group.last[:line] < first_owner_start
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
@preamble_region.nil? ? :preamble : :orphan
|
|
221
|
+
else
|
|
222
|
+
:orphan
|
|
223
|
+
end
|
|
224
224
|
|
|
225
225
|
region = build_region(kind, group)
|
|
226
226
|
if kind == :preamble && @preamble_region.nil?
|
|
@@ -309,7 +309,7 @@ module Ast
|
|
|
309
309
|
((previous_line + 1)...comment[:line]).each do |line_number|
|
|
310
310
|
if blank_line?(line_number)
|
|
311
311
|
nodes << Empty.new(line_number: line_number,
|
|
312
|
-
|
|
312
|
+
text: line_at(line_number).to_s)
|
|
313
313
|
end
|
|
314
314
|
end
|
|
315
315
|
end
|
|
@@ -373,7 +373,7 @@ module Ast
|
|
|
373
373
|
end
|
|
374
374
|
|
|
375
375
|
def normalize_comment_hash(comment)
|
|
376
|
-
raise ArgumentError,
|
|
376
|
+
raise ArgumentError, "comment must be a Hash" unless comment.is_a?(Hash)
|
|
377
377
|
|
|
378
378
|
comment.each_with_object({}) do |(key, value), result|
|
|
379
379
|
result[key.to_sym] = value
|
|
@@ -389,7 +389,7 @@ module Ast
|
|
|
389
389
|
def validate_owner!(owner)
|
|
390
390
|
return if owner.respond_to?(:start_line) && owner.respond_to?(:end_line)
|
|
391
391
|
|
|
392
|
-
raise ArgumentError,
|
|
392
|
+
raise ArgumentError, "owner must respond to #start_line and #end_line"
|
|
393
393
|
end
|
|
394
394
|
|
|
395
395
|
def blank_line?(line_number)
|
|
@@ -41,7 +41,7 @@ module Ast
|
|
|
41
41
|
# TreeHaver::Node protocol: type
|
|
42
42
|
# @return [String] "comment_block"
|
|
43
43
|
def type
|
|
44
|
-
|
|
44
|
+
"comment_block"
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Initialize a new Block.
|
|
@@ -181,11 +181,11 @@ module Ast
|
|
|
181
181
|
def first_meaningful_content
|
|
182
182
|
if raw_content
|
|
183
183
|
# Extract first line of content from block comment
|
|
184
|
-
extract_block_content.split("\n").first&.strip&.downcase ||
|
|
184
|
+
extract_block_content.split("\n").first&.strip&.downcase || ""
|
|
185
185
|
else
|
|
186
186
|
# Find first comment line with actual content
|
|
187
187
|
first_content = children.find { |c| c.is_a?(Line) && !c.content.strip.empty? }
|
|
188
|
-
first_content&.content&.strip&.downcase ||
|
|
188
|
+
first_content&.content&.strip&.downcase || ""
|
|
189
189
|
end
|
|
190
190
|
end
|
|
191
191
|
|
|
@@ -195,21 +195,21 @@ module Ast
|
|
|
195
195
|
#
|
|
196
196
|
# @return [String] The content without delimiters
|
|
197
197
|
def extract_block_content
|
|
198
|
-
return
|
|
198
|
+
return "" unless raw_content
|
|
199
199
|
|
|
200
200
|
content = raw_content.to_s
|
|
201
201
|
|
|
202
202
|
# Remove block start delimiter
|
|
203
|
-
content = content.sub(/^\s*#{Regexp.escape(style.block_start)}\s*/,
|
|
203
|
+
content = content.sub(/^\s*#{Regexp.escape(style.block_start)}\s*/, "") if style.block_start
|
|
204
204
|
|
|
205
205
|
# Remove block end delimiter
|
|
206
|
-
content = content.sub(/\s*#{Regexp.escape(style.block_end)}\s*$/,
|
|
206
|
+
content = content.sub(/\s*#{Regexp.escape(style.block_end)}\s*$/, "") if style.block_end
|
|
207
207
|
|
|
208
208
|
# Clean up common patterns in multi-line block comments
|
|
209
209
|
# (leading asterisks on each line, common in /* ... */ style)
|
|
210
210
|
lines = content.split("\n")
|
|
211
211
|
if lines.size > 1 && lines[1..].all? { |l| l.match?(/^\s*\*/) }
|
|
212
|
-
lines = lines.map { |l| l.sub(/^\s*\*\s?/,
|
|
212
|
+
lines = lines.map { |l| l.sub(/^\s*\*\s?/, "") }
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
lines.map(&:strip).join("\n")
|
|
@@ -220,17 +220,17 @@ module Ast
|
|
|
220
220
|
# ----------------------------------------------------------------
|
|
221
221
|
|
|
222
222
|
def comment_attachment_for(owner, line_num: nil, leading_comments: nil, inline_comment: nil,
|
|
223
|
-
|
|
223
|
+
trailing_comments: nil, **metadata)
|
|
224
224
|
resolved_line_num = line_num || owner_line_num(owner)
|
|
225
225
|
resolved_end_line = owner_end_line(owner) || resolved_line_num
|
|
226
226
|
leading_region = if resolved_line_num
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
leading_comment_region_before(resolved_line_num, comments: leading_comments)
|
|
228
|
+
end
|
|
229
229
|
inline_region = (inline_comment_region_at(resolved_line_num, comment: inline_comment) if resolved_line_num)
|
|
230
230
|
trailing_region = if resolved_end_line
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
trailing_comment_region_after(resolved_end_line, comments: trailing_comments,
|
|
232
|
+
owner: owner)
|
|
233
|
+
end
|
|
234
234
|
|
|
235
235
|
Attachment.new(
|
|
236
236
|
owner: owner,
|
|
@@ -358,21 +358,21 @@ module Ast
|
|
|
358
358
|
current_block_comment[:raw_lines] << line if current_block_comment
|
|
359
359
|
current_block_comment[:raw] = current_block_comment[:raw_lines].join("\n") if current_block_comment
|
|
360
360
|
|
|
361
|
-
if line.include?(
|
|
361
|
+
if line.include?("*/")
|
|
362
362
|
in_block_comment = false
|
|
363
363
|
current_block_comment = nil
|
|
364
364
|
end
|
|
365
365
|
next
|
|
366
366
|
end
|
|
367
367
|
|
|
368
|
-
if line.include?(
|
|
368
|
+
if line.include?("/*") && !line.include?("*/")
|
|
369
369
|
in_block_comment = true
|
|
370
370
|
indent_match = line.match(/\A(?<indent>\s*)/)
|
|
371
371
|
current_block_comment = {
|
|
372
372
|
line: line_num,
|
|
373
373
|
end_line: line_num,
|
|
374
374
|
indent: indent_match ? indent_match[:indent].length : 0,
|
|
375
|
-
text: line.sub(%r{\A\s*/\*\s?},
|
|
375
|
+
text: line.sub(%r{\A\s*/\*\s?}, "").strip,
|
|
376
376
|
full_line: true,
|
|
377
377
|
block: true,
|
|
378
378
|
raw: line,
|
|
@@ -416,9 +416,9 @@ module Ast
|
|
|
416
416
|
end
|
|
417
417
|
|
|
418
418
|
def extract_inline_comment(line, line_num)
|
|
419
|
-
return unless line.include?(
|
|
419
|
+
return unless line.include?("//")
|
|
420
420
|
|
|
421
|
-
before_comment, after_comment = line.split(
|
|
421
|
+
before_comment, after_comment = line.split("//", 2)
|
|
422
422
|
return unless after_comment
|
|
423
423
|
return if before_comment.to_s.strip.empty?
|
|
424
424
|
return unless inline_comment_candidate?(before_comment, after_comment, line: line, line_num: line_num)
|
|
@@ -154,7 +154,7 @@ module Ast
|
|
|
154
154
|
return normalized if LEVELS.include?(normalized)
|
|
155
155
|
|
|
156
156
|
raise ArgumentError,
|
|
157
|
-
|
|
157
|
+
"Unknown comment capability level: #{level.inspect}. Expected one of: #{LEVELS.join(", ")}"
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
end
|
|
@@ -29,14 +29,14 @@ module Ast
|
|
|
29
29
|
# TreeHaver::Node protocol: type
|
|
30
30
|
# @return [String] "empty_line"
|
|
31
31
|
def type
|
|
32
|
-
|
|
32
|
+
"empty_line"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Initialize a new Empty line.
|
|
36
36
|
#
|
|
37
37
|
# @param line_number [Integer] The 1-based line number
|
|
38
38
|
# @param text [String] The actual line content (may have whitespace)
|
|
39
|
-
def initialize(line_number:, text:
|
|
39
|
+
def initialize(line_number:, text: "")
|
|
40
40
|
@line_number = line_number
|
|
41
41
|
@text = text.to_s
|
|
42
42
|
|
|
@@ -61,7 +61,7 @@ module Ast
|
|
|
61
61
|
|
|
62
62
|
# @return [String] Empty normalized content
|
|
63
63
|
def normalized_content
|
|
64
|
-
|
|
64
|
+
""
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# Empty lines never contain freeze markers.
|
|
@@ -60,10 +60,10 @@ module Ast
|
|
|
60
60
|
def initialize(lines, tree_haver_comments: nil)
|
|
61
61
|
@lines = Array(lines)
|
|
62
62
|
@comments = if tree_haver_comments
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
comments_from_tree_haver(tree_haver_comments)
|
|
64
|
+
else
|
|
65
|
+
extract_comments
|
|
66
|
+
end
|
|
67
67
|
@comments_by_line = @comments.group_by { |c| c[:line] }
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -276,17 +276,17 @@ module Ast
|
|
|
276
276
|
# @param metadata [Hash] Additional metadata preserved on the attachment
|
|
277
277
|
# @return [Ast::Merge::Comment::Attachment]
|
|
278
278
|
def comment_attachment_for(owner, line_num: nil, leading_comments: nil, inline_comment: nil,
|
|
279
|
-
|
|
279
|
+
trailing_comments: nil, **metadata)
|
|
280
280
|
resolved_line_num = line_num || owner_line_num(owner)
|
|
281
281
|
resolved_end_line = owner_end_line(owner) || resolved_line_num
|
|
282
282
|
leading_region = if resolved_line_num
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
leading_comment_region_before(resolved_line_num, comments: leading_comments)
|
|
284
|
+
end
|
|
285
285
|
inline_region = (inline_comment_region_at(resolved_line_num, comment: inline_comment) if resolved_line_num)
|
|
286
286
|
trailing_region = if resolved_end_line
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
trailing_comment_region_after(resolved_end_line, comments: trailing_comments,
|
|
288
|
+
owner: owner)
|
|
289
|
+
end
|
|
290
290
|
|
|
291
291
|
Attachment.new(
|
|
292
292
|
owner: owner,
|
|
@@ -410,7 +410,7 @@ module Ast
|
|
|
410
410
|
# @return [Array<Hash>]
|
|
411
411
|
def extract_comments
|
|
412
412
|
raise NotImplementedError,
|
|
413
|
-
|
|
413
|
+
"#{self.class}#extract_comments must be implemented by the format-specific subclass"
|
|
414
414
|
end
|
|
415
415
|
|
|
416
416
|
# Convert a flat list of +TreeHaver::Base::Comment+ objects to the
|
|
@@ -442,7 +442,7 @@ module Ast
|
|
|
442
442
|
indent = th_comment.start_point[:column]
|
|
443
443
|
# Strip the leading `# ` or `#` prefix to get the bare content text.
|
|
444
444
|
# tree_haver's #text includes the delimiter, matching Prism's #slice.
|
|
445
|
-
content = th_comment.text.sub(/\A#\s?/,
|
|
445
|
+
content = th_comment.text.sub(/\A#\s?/, "")
|
|
446
446
|
# :inline means non-whitespace code appears before the # on the same line.
|
|
447
447
|
# :leading and :trailing both represent full-line (standalone) comments.
|
|
448
448
|
full_line = th_comment.attachment_hint != :inline
|
|
@@ -461,8 +461,8 @@ module Ast
|
|
|
461
461
|
return line if line
|
|
462
462
|
|
|
463
463
|
raise MissingTrackedLineError,
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
"tree_haver comment at line #{line_num} could not be mapped back to tracker source lines. " \
|
|
465
|
+
"HashTrackerBase requires source lines and tree_haver comments to describe the same input."
|
|
466
466
|
end
|
|
467
467
|
|
|
468
468
|
# Resolve a structural owner to a 1-based line number.
|
|
@@ -38,7 +38,7 @@ module Ast
|
|
|
38
38
|
# TreeHaver::Node protocol: type
|
|
39
39
|
# @return [String] "comment_line"
|
|
40
40
|
def type
|
|
41
|
-
|
|
41
|
+
"comment_line"
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Initialize a new Line.
|
|
@@ -94,10 +94,10 @@ module Ast
|
|
|
94
94
|
return false unless token
|
|
95
95
|
|
|
96
96
|
pattern = if action
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
/#{Regexp.escape(token)}:#{action}/i
|
|
98
|
+
else
|
|
99
|
+
/#{Regexp.escape(token)}/i
|
|
100
|
+
end
|
|
101
101
|
text.match?(pattern)
|
|
102
102
|
end
|
|
103
103
|
|
|
@@ -199,7 +199,7 @@ module Ast
|
|
|
199
199
|
current_block_lines = []
|
|
200
200
|
end
|
|
201
201
|
|
|
202
|
-
current_block_lines << {
|
|
202
|
+
current_block_lines << {line: line.to_s, line_number: line_number}
|
|
203
203
|
in_block_comment = true
|
|
204
204
|
|
|
205
205
|
# Check if block ends on same line
|
|
@@ -210,7 +210,7 @@ module Ast
|
|
|
210
210
|
end
|
|
211
211
|
elsif in_block_comment
|
|
212
212
|
# Inside a block comment
|
|
213
|
-
current_block_lines << {
|
|
213
|
+
current_block_lines << {line: line.to_s, line_number: line_number}
|
|
214
214
|
|
|
215
215
|
# Check if block ends
|
|
216
216
|
if style.match_block_end?(stripped)
|
|
@@ -220,7 +220,7 @@ module Ast
|
|
|
220
220
|
end
|
|
221
221
|
elsif style.supports_line_comments? && style.match_line?(stripped)
|
|
222
222
|
# Line comment (in a style that supports both line and block)
|
|
223
|
-
current_block_lines << {
|
|
223
|
+
current_block_lines << {line: line.to_s, line_number: line_number}
|
|
224
224
|
else
|
|
225
225
|
# Other content - flush and add as-is
|
|
226
226
|
if current_block_lines.any?
|