ast-merge 7.1.20 → 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 +94 -60
- 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 +4 -4
- 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,22 +2,17 @@
|
|
|
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
|
|
|
9
|
-
---
|
|
10
|
-
|
|
11
9
|
`if ci_badges.map(&:color).all? { it == "green"}` 👇️ send money so I can do more of this. FLOSS maintenance is now my full-time job.
|
|
12
10
|
|
|
13
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]
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
I've summarized my thoughts in [this blog post](https://dev.to/galtzo/hostile-takeover-of-rubygems-my-thoughts-5hlo).
|
|
19
|
-
|
|
20
|
-
</details>
|
|
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>
|
|
15
|
+
<!-- kettle-sponsors:shields:end -->
|
|
21
16
|
|
|
22
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>
|
|
23
18
|
|
|
@@ -351,48 +346,6 @@ The `Ast::Merge` module is organized into several namespaces, each with detailed
|
|
|
351
346
|
|
|
352
347
|
[tree_haver]: https://github.com/structuredmerge/structuredmerge-ruby/tree/main/gems/tree_haver
|
|
353
348
|
|
|
354
|
-
## 💡 Info you can shake a stick at
|
|
355
|
-
|
|
356
|
-
| Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
|
|
357
|
-
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
358
|
-
| Works with MRI Ruby 4 | [![Ruby current Compat][💎ruby-c-i]][🚎11-c-wf]|
|
|
359
|
-
| 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] |
|
|
360
|
-
| 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] |
|
|
361
|
-
| 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] |
|
|
362
|
-
| Compliance | [![License: AGPL-3.0-only OR PolyForm-Small-Business-1.0.0][📄license-img]][📄license] [![Apache license compatibility: Category X][📄license-compat-img]][📄license-compat] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![Contributor Covenant 2.1][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] |
|
|
363
|
-
| 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] |
|
|
364
|
-
| 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] |
|
|
365
|
-
| `...` 💖 | [![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] |
|
|
366
|
-
|
|
367
|
-
### Compatibility
|
|
368
|
-
|
|
369
|
-
The gem's declared runtime compatibility floor is MRI Ruby 4.0.0+, with concordant releases of JRuby and TruffleRuby.
|
|
370
|
-
CI workflows and Appraisals are generated for MRI Ruby 4.0.0+.
|
|
371
|
-
The current MRI CI lane runs on Linux and macOS.
|
|
372
|
-
The test floor is configured by `ruby.test_minimum` in `.kettle-jem.yml`.
|
|
373
|
-
When it is higher than the runtime floor, older runtime-compatible Rubies are
|
|
374
|
-
not covered by the generated CI or Appraisal matrix.
|
|
375
|
-
|
|
376
|
-
<a href="https://github.com/kettle-dev"><img alt="kettle-dev Logo by Aboling0, CC BY-SA 4.0" src="https://logos.galtzo.com/assets/images/kettle-dev/avatar-128px.svg" width="14%" align="right"/></a>
|
|
377
|
-
|
|
378
|
-
The _amazing_ test matrix is powered by the kettle-dev stack.
|
|
379
|
-
|
|
380
|
-
<details markdown="1">
|
|
381
|
-
<summary>How kettle-dev manages complexity in tests</summary>
|
|
382
|
-
|
|
383
|
-
| Gem | Source | Role | Total downloads |
|
|
384
|
-
|-----|--------|------|---------------------|
|
|
385
|
-
| [appraisal2](https://clickgems.clickhouse.com/dashboard/appraisal2) | [GitHub](https://github.com/appraisal-rb/appraisal2) | multi-dependency Appraisal matrix generation | [](https://clickgems.clickhouse.com/dashboard/appraisal2) |
|
|
386
|
-
| [appraisal2-rubocop](https://clickgems.clickhouse.com/dashboard/appraisal2-rubocop) | [GitHub](https://github.com/appraisal-rb/appraisal2-rubocop) | RuboCop Appraisal generator integration | [](https://clickgems.clickhouse.com/dashboard/appraisal2-rubocop) |
|
|
387
|
-
| [kettle-dev](https://clickgems.clickhouse.com/dashboard/kettle-dev) | [GitHub](https://github.com/kettle-dev/kettle-dev) | development, release, and CI workflow tooling | [](https://clickgems.clickhouse.com/dashboard/kettle-dev) |
|
|
388
|
-
| [kettle-jem](https://clickgems.clickhouse.com/dashboard/kettle-jem) | [GitHub](https://github.com/kettle-dev/kettle-jem) | Appraisals & CI workflow templates | [](https://clickgems.clickhouse.com/dashboard/kettle-jem) |
|
|
389
|
-
| [kettle-soup-cover](https://clickgems.clickhouse.com/dashboard/kettle-soup-cover) | [GitHub](https://github.com/kettle-dev/kettle-soup-cover) | SimpleCov coverage policy and reporting | [](https://clickgems.clickhouse.com/dashboard/kettle-soup-cover) |
|
|
390
|
-
| [kettle-test](https://clickgems.clickhouse.com/dashboard/kettle-test) | [GitHub](https://github.com/kettle-dev/kettle-test) | standard test runner and coverage harness | [](https://clickgems.clickhouse.com/dashboard/kettle-test) |
|
|
391
|
-
| [rubocop-lts](https://clickgems.clickhouse.com/dashboard/rubocop-lts) | [GitHub](https://github.com/rubocop-lts/rubocop-lts) | Ruby-version-aware linting | [](https://clickgems.clickhouse.com/dashboard/rubocop-lts) |
|
|
392
|
-
| [turbo_tests2](https://clickgems.clickhouse.com/dashboard/turbo_tests2) | [GitHub](https://github.com/galtzo-floss/turbo_tests2) | parallel test execution | [](https://clickgems.clickhouse.com/dashboard/turbo_tests2) |
|
|
393
|
-
|
|
394
|
-
</details>
|
|
395
|
-
|
|
396
349
|
## ✨ Installation
|
|
397
350
|
|
|
398
351
|
Install the gem and add to the application's Gemfile by executing:
|
|
@@ -508,6 +461,59 @@ end
|
|
|
508
461
|
- `"Ast::Merge::FileAnalysisBase"` - Tests for FileAnalysis implementations
|
|
509
462
|
- `"Ast::Merge::MergerConfig"` - Tests for SmartMerger implementations
|
|
510
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
|
+
|
|
475
|
+
## 💡 Info you can shake a stick at
|
|
476
|
+
|
|
477
|
+
| Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
|
|
478
|
+
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
479
|
+
| Works with MRI Ruby 4 | [![Ruby current Compat][💎ruby-c-i]][🚎11-c-wf]|
|
|
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] |
|
|
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] |
|
|
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] |
|
|
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] |
|
|
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] |
|
|
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] |
|
|
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] |
|
|
487
|
+
|
|
488
|
+
### Compatibility
|
|
489
|
+
|
|
490
|
+
The gem's declared runtime compatibility floor is MRI Ruby 4.0.0+, with concordant releases of JRuby and TruffleRuby.
|
|
491
|
+
CI workflows and Appraisals are generated for MRI Ruby 4.0.0+.
|
|
492
|
+
The current MRI CI lane runs on Linux and macOS.
|
|
493
|
+
The test floor is configured by `ruby.test_minimum` in `.structuredmerge/kettle-jem.yml`.
|
|
494
|
+
When it is higher than the runtime floor, older runtime-compatible Rubies are
|
|
495
|
+
not covered by the generated CI or Appraisal matrix.
|
|
496
|
+
|
|
497
|
+
<a href="https://github.com/kettle-dev"><img alt="kettle-dev Logo by Aboling0, CC BY-SA 4.0" src="https://logos.galtzo.com/assets/images/kettle-dev/avatar-128px.svg" width="14%" align="right"/></a>
|
|
498
|
+
|
|
499
|
+
The _amazing_ test matrix is powered by the kettle-dev stack.
|
|
500
|
+
|
|
501
|
+
<details markdown="1">
|
|
502
|
+
<summary>How kettle-dev manages complexity in tests</summary>
|
|
503
|
+
|
|
504
|
+
| Gem | Source | Role | Total downloads |
|
|
505
|
+
|-----|--------|------|---------------------|
|
|
506
|
+
| [appraisal2](https://clickgems.clickhouse.com/dashboard/appraisal2) | [GitHub](https://github.com/appraisal-rb/appraisal2) | multi-dependency Appraisal matrix generation | [](https://clickgems.clickhouse.com/dashboard/appraisal2) |
|
|
507
|
+
| [appraisal2-rubocop](https://clickgems.clickhouse.com/dashboard/appraisal2-rubocop) | [GitHub](https://github.com/appraisal-rb/appraisal2-rubocop) | RuboCop Appraisal generator integration | [](https://clickgems.clickhouse.com/dashboard/appraisal2-rubocop) |
|
|
508
|
+
| [kettle-dev](https://clickgems.clickhouse.com/dashboard/kettle-dev) | [GitHub](https://github.com/kettle-dev/kettle-dev) | development, release, and CI workflow tooling | [](https://clickgems.clickhouse.com/dashboard/kettle-dev) |
|
|
509
|
+
| [kettle-jem](https://clickgems.clickhouse.com/dashboard/kettle-jem) | [GitHub](https://github.com/kettle-dev/kettle-jem) | Appraisals & CI workflow templates | [](https://clickgems.clickhouse.com/dashboard/kettle-jem) |
|
|
510
|
+
| [kettle-soup-cover](https://clickgems.clickhouse.com/dashboard/kettle-soup-cover) | [GitHub](https://github.com/kettle-dev/kettle-soup-cover) | SimpleCov coverage policy and reporting | [](https://clickgems.clickhouse.com/dashboard/kettle-soup-cover) |
|
|
511
|
+
| [kettle-test](https://clickgems.clickhouse.com/dashboard/kettle-test) | [GitHub](https://github.com/kettle-dev/kettle-test) | standard test runner and coverage harness | [](https://clickgems.clickhouse.com/dashboard/kettle-test) |
|
|
512
|
+
| [rubocop-lts](https://clickgems.clickhouse.com/dashboard/rubocop-lts) | [GitHub](https://github.com/rubocop-lts/rubocop-lts) | Ruby-version-aware linting | [](https://clickgems.clickhouse.com/dashboard/rubocop-lts) |
|
|
513
|
+
| [turbo_tests2](https://clickgems.clickhouse.com/dashboard/turbo_tests2) | [GitHub](https://github.com/galtzo-floss/turbo_tests2) | parallel test execution | [](https://clickgems.clickhouse.com/dashboard/turbo_tests2) |
|
|
514
|
+
|
|
515
|
+
</details>
|
|
516
|
+
|
|
511
517
|
## 🔐 Security
|
|
512
518
|
|
|
513
519
|
See [SECURITY.md][🔐security].
|
|
@@ -521,6 +527,8 @@ We [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] so if you m
|
|
|
521
527
|
|
|
522
528
|
See [CONTRIBUTING.md][🤝contributing] for more detailed instructions.
|
|
523
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
|
+
|
|
524
532
|
## 📌 Versioning
|
|
525
533
|
|
|
526
534
|
This library follows [![Semantic Versioning 2.0.0][📌semver-img]][📌semver] for its public API where practical.
|
|
@@ -549,10 +557,23 @@ See [CHANGELOG.md][📌changelog] for a list of releases.
|
|
|
549
557
|
|
|
550
558
|
## 📄 License
|
|
551
559
|
|
|
552
|
-
The gem is available under the
|
|
553
|
-
|
|
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].
|
|
562
|
+
|
|
563
|
+
### Please give the project a star ⭐ ♥.
|
|
564
|
+
|
|
565
|
+
Many parts of this project are actively managed by a [kettle-jem](https://github.com/structuredmerge/structuredmerge-ruby/tree/main/gems/kettle-jem) smart template utilizing [StructuredMerge.org](https://structuredmerge.org) merge contracts.
|
|
554
566
|
|
|
555
|
-
If
|
|
567
|
+
If this project helps you, please consider supporting the maintainer. This is not gated on the project's license; it appears in every README:
|
|
568
|
+
|
|
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]
|
|
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
|
+
|
|
576
|
+
Thanks for RTFM. ☺️
|
|
556
577
|
|
|
557
578
|
[⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
|
|
558
579
|
[⛳liberapay-bottom-img]: https://img.shields.io/liberapay/goal/pboling.svg?style=for-the-badge&logo=liberapay&color=a51611
|
|
@@ -577,6 +598,7 @@ If none of the available licenses suit your use case, please [contact us](mailto
|
|
|
577
598
|
[✉️ruby-forum-top-img]: https://img.shields.io/discourse/topics?server=https%3A%2F%2Fwww.rubyforum.org&style=flat&logo=discourse&label=Ruby%20Users%20Forum
|
|
578
599
|
[✉️ruby-forum-img]: https://img.shields.io/discourse/topics?server=https%3A%2F%2Fwww.rubyforum.org&style=for-the-badge&logo=discourse&label=Ruby%20Users%20Forum
|
|
579
600
|
[✉️ruby-forum]: https://www.rubyforum.org/tag/ast-merge
|
|
601
|
+
|
|
580
602
|
[✇bundle-group-pattern]: https://gist.github.com/pboling/4564780
|
|
581
603
|
[⛳️gem-namespace]: https://github.com/structuredmerge/structuredmerge-ruby/tree/main/gems/ast-merge
|
|
582
604
|
[⛳️namespace-img]: https://img.shields.io/badge/namespace-Ast::Merge-3C2D2D.svg?style=square&logo=ruby&logoColor=white
|
|
@@ -630,6 +652,16 @@ If none of the available licenses suit your use case, please [contact us](mailto
|
|
|
630
652
|
[👽dl-ranki]: https://img.shields.io/gem/dt/ast-merge.svg
|
|
631
653
|
[👽version]: https://clickgems.clickhouse.com/dashboard/ast-merge
|
|
632
654
|
[👽versioni]: https://img.shields.io/gem/v/ast-merge.svg
|
|
655
|
+
[🏀qlty-mnt]: https://qlty.sh/gh/structuredmerge/projects/structuredmerge-ruby
|
|
656
|
+
[🏀qlty-mnti]: https://qlty.sh/gh/structuredmerge/projects/structuredmerge-ruby/maintainability.svg
|
|
657
|
+
[🏀qlty-cov]: https://qlty.sh/gh/structuredmerge/projects/structuredmerge-ruby/metrics/code?sort=coverageRating
|
|
658
|
+
[🏀qlty-covi]: https://qlty.sh/gh/structuredmerge/projects/structuredmerge-ruby/coverage.svg
|
|
659
|
+
[🏀codecov]: https://codecov.io/gh/structuredmerge/structuredmerge-ruby
|
|
660
|
+
[🏀codecovi]: https://codecov.io/gh/structuredmerge/structuredmerge-ruby/graph/badge.svg
|
|
661
|
+
[🏀coveralls]: https://coveralls.io/github/structuredmerge/structuredmerge-ruby?branch=main
|
|
662
|
+
[🏀coveralls-img]: https://coveralls.io/repos/github/structuredmerge/structuredmerge-ruby/badge.svg?branch=main
|
|
663
|
+
[🚎2-cov-wf]: https://github.com/structuredmerge/structuredmerge-ruby/actions/workflows/coverage.yml
|
|
664
|
+
[🚎2-cov-wfi]: https://github.com/structuredmerge/structuredmerge-ruby/actions/workflows/coverage.yml/badge.svg
|
|
633
665
|
[🚎11-c-wf]: https://github.com/structuredmerge/structuredmerge-ruby/actions/workflows/current.yml
|
|
634
666
|
[🚎11-c-wfi]: https://github.com/structuredmerge/structuredmerge-ruby/actions/workflows/current.yml/badge.svg
|
|
635
667
|
[💎ruby-c-i]: https://img.shields.io/badge/Ruby-current-CC342D?style=for-the-badge&logo=ruby&logoColor=green
|
|
@@ -641,11 +673,12 @@ If none of the available licenses suit your use case, please [contact us](mailto
|
|
|
641
673
|
[🤝cb-pulls]: https://codeberg.org/structuredmerge/structuredmerge-ruby/pulls
|
|
642
674
|
[🤝cb-donate]: https://donate.codeberg.org/
|
|
643
675
|
[🤝contributing]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/CONTRIBUTING.md
|
|
676
|
+
[🏀codecov-g]: https://codecov.io/gh/structuredmerge/structuredmerge-ruby/graph/badge.svg
|
|
644
677
|
[🖐contrib-rocks]: https://contrib.rocks
|
|
645
678
|
[🖐contributors]: https://github.com/structuredmerge/structuredmerge-ruby/graphs/contributors
|
|
646
679
|
[🖐contributors-img]: https://contrib.rocks/image?repo=structuredmerge/structuredmerge-ruby
|
|
647
680
|
[🪇conduct]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/CODE_OF_CONDUCT.md
|
|
648
|
-
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-
|
|
681
|
+
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-3.0-259D6C.svg
|
|
649
682
|
[📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
|
650
683
|
[📌semver]: https://semver.org/spec/v2.0.0.html
|
|
651
684
|
[📌semver-img]: https://img.shields.io/badge/semver-2.0.0-259D6C.svg?style=flat
|
|
@@ -657,15 +690,16 @@ If none of the available licenses suit your use case, please [contact us](mailto
|
|
|
657
690
|
[📌gitmoji]: https://gitmoji.dev
|
|
658
691
|
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
659
692
|
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
660
|
-
[🧮kloc-img]: https://img.shields.io/badge/KLOC-
|
|
693
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-11.926-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
661
694
|
[🔐security]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/SECURITY.md
|
|
662
695
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
663
696
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
664
697
|
[📄license]: LICENSE.md
|
|
665
|
-
[📄license-ref]:
|
|
666
|
-
[📄license-img]: https://img.shields.io/badge/License-
|
|
667
|
-
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-
|
|
668
|
-
[📄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
|
|
702
|
+
|
|
669
703
|
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
|
|
670
704
|
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
|
|
671
705
|
[🚎yard-current]: http://rubydoc.info/gems/ast-merge
|
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
|