typescript-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/typescript/merge/file_analysis.rb +5 -5
- data/lib/typescript/merge/node_wrapper.rb +43 -43
- data/lib/typescript/merge/provider.rb +63 -63
- data/lib/typescript/merge/rust_host_provider.rb +13 -13
- data/lib/typescript/merge/version.rb +1 -1
- data/lib/typescript/merge.rb +35 -35
- data/lib/typescript-merge.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +13 -14
- 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: 490d89c8f95016ef09ea7e11b5667b028fd099bcec7756257b97cb179dfa837c
|
|
4
|
+
data.tar.gz: b1d2ac07c1d1ee91b164577532bd13b4c9ab2425c68655e891570f262fbec29f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fcb74e221628e2b99611d9235371615da59343b58c8d52e92291b91205148d2592906b52bd0926c3ca8f2ac0fa02507ae70a1b5d73650f3f02da1445b3057da
|
|
7
|
+
data.tar.gz: 4c42d513b0d3b0bb3b791a6b72c3e8cd3b5784a4ac56bda8edbb8e463d7247f137df1bc8a85416277de246519d170f28cb8f4ebfd2b1527d7807d173f933ecfc
|
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
|
# ☯️ TypeScript::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>
|
|
@@ -65,6 +66,17 @@ File.write("index.ts", result.fetch(:output))
|
|
|
65
66
|
|
|
66
67
|
Most module-level merge methods return a Hash with `:ok`, `:diagnostics`, `:output`, and `:policies`. Check `:ok` before writing the result; diagnostics are structured for CI output and fixture conformance reports.
|
|
67
68
|
|
|
69
|
+
## 🏢 Corporate Sponsorship
|
|
70
|
+
|
|
71
|
+
<!-- kettle-sponsors:cards:start -->
|
|
72
|
+
<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>
|
|
73
|
+
|
|
74
|
+
<sub>Create sponsorship badges for your project with [kettle-sponsors](https://github.com/kettle-dev/kettle-sponsors).</sub>
|
|
75
|
+
<!-- kettle-sponsors:cards:end -->
|
|
76
|
+
|
|
77
|
+
**If you're working in a company that's making significant use of structuredmerge tools we'd
|
|
78
|
+
appreciate it if you suggest to your company to become a structuredmerge sponsor.**
|
|
79
|
+
|
|
68
80
|
## 💡 Info you can shake a stick at
|
|
69
81
|
|
|
70
82
|
| Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
|
|
@@ -73,7 +85,7 @@ Most module-level merge methods return a Hash with `:ok`, `:diagnostics`, `:outp
|
|
|
73
85
|
| 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] |
|
|
74
86
|
| 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] |
|
|
75
87
|
| 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] |
|
|
76
|
-
| Compliance | [![License:
|
|
88
|
+
| 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] |
|
|
77
89
|
| 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] |
|
|
78
90
|
| 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] |
|
|
79
91
|
| `...` 💖 | [![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] |
|
|
@@ -120,6 +132,8 @@ We [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] so if you m
|
|
|
120
132
|
|
|
121
133
|
See [CONTRIBUTING.md][🤝contributing] for more detailed instructions.
|
|
122
134
|
|
|
135
|
+
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.
|
|
136
|
+
|
|
123
137
|
## 📌 Versioning
|
|
124
138
|
|
|
125
139
|
This library follows [![Semantic Versioning 2.0.0][📌semver-img]][📌semver] for its public API where practical.
|
|
@@ -148,10 +162,8 @@ See [CHANGELOG.md][📌changelog] for a list of releases.
|
|
|
148
162
|
|
|
149
163
|
## 📄 License
|
|
150
164
|
|
|
151
|
-
The gem is available under the
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
If none of the available licenses suit your use case, please [contact us](mailto:floss@galtzo.com) to discuss a custom commercial license.
|
|
165
|
+
The gem is available as open source under the terms of
|
|
166
|
+
the [MIT](https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md) [![License: MIT][📄license-img]][📄license-ref].
|
|
155
167
|
|
|
156
168
|
### Please give the project a star ⭐ ♥.
|
|
157
169
|
|
|
@@ -161,6 +173,11 @@ If this project helps you, please consider supporting the maintainer. This is no
|
|
|
161
173
|
|
|
162
174
|
[![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]
|
|
163
175
|
|
|
176
|
+
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."
|
|
177
|
+
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.
|
|
178
|
+
|
|
179
|
+
[🖇cloudroom]: https://go.cloudroom.dev/u9f53f181a
|
|
180
|
+
|
|
164
181
|
Thanks for RTFM. ☺️
|
|
165
182
|
|
|
166
183
|
[⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
|
|
@@ -218,7 +235,6 @@ Thanks for RTFM. ☺️
|
|
|
218
235
|
[💖🐙hub]: https://github.org/pboling
|
|
219
236
|
[💖🛖hut]: https://sr.ht/~galtzo/
|
|
220
237
|
[💖🧪lab]: https://gitlab.com/pboling
|
|
221
|
-
[🏙️entsup-tidelift-sonar]: https://blog.tidelift.com/tidelift-joins-sonar
|
|
222
238
|
[👨🏼🏫expsup-upwork]: https://www.upwork.com/freelancers/~014942e9b056abdf86?mp_source=share
|
|
223
239
|
[👨🏼🏫expsup-upwork-img]: https://img.shields.io/badge/UpWork-13544E?style=for-the-badge&logo=Upwork&logoColor=white
|
|
224
240
|
[👨🏼🏫expsup-codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
|
|
@@ -267,7 +283,7 @@ Thanks for RTFM. ☺️
|
|
|
267
283
|
[🖐contributors]: https://github.com/structuredmerge/structuredmerge-ruby/graphs/contributors
|
|
268
284
|
[🖐contributors-img]: https://contrib.rocks/image?repo=structuredmerge/structuredmerge-ruby
|
|
269
285
|
[🪇conduct]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/CODE_OF_CONDUCT.md
|
|
270
|
-
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-
|
|
286
|
+
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-3.0-259D6C.svg
|
|
271
287
|
[📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
|
272
288
|
[📌semver]: https://semver.org/spec/v2.0.0.html
|
|
273
289
|
[📌semver-img]: https://img.shields.io/badge/semver-2.0.0-259D6C.svg?style=flat
|
|
@@ -284,10 +300,10 @@ Thanks for RTFM. ☺️
|
|
|
284
300
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
285
301
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
286
302
|
[📄license]: LICENSE.md
|
|
287
|
-
[📄license-ref]:
|
|
288
|
-
[📄license-img]: https://img.shields.io/badge/License-
|
|
289
|
-
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-
|
|
290
|
-
[📄license-compat-img]: https://img.shields.io/badge/
|
|
303
|
+
[📄license-ref]: https://github.com/structuredmerge/structuredmerge-ruby/blob/main/MIT.md
|
|
304
|
+
[📄license-img]: https://img.shields.io/badge/License-MIT-259D6C.svg
|
|
305
|
+
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-a
|
|
306
|
+
[📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-%E2%9C%93-259D6C.svg?style=flat&logo=Apache
|
|
291
307
|
|
|
292
308
|
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
|
|
293
309
|
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
|
|
@@ -13,7 +13,7 @@ module TypeScript
|
|
|
13
13
|
@backend = TREE_SITTER_BACKEND.id.to_sym
|
|
14
14
|
@errors = []
|
|
15
15
|
parse!
|
|
16
|
-
rescue
|
|
16
|
+
rescue => e
|
|
17
17
|
@root_node = nil
|
|
18
18
|
@declarations = [].freeze
|
|
19
19
|
@errors = [e].freeze
|
|
@@ -22,15 +22,15 @@ module TypeScript
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
24
|
def parse!
|
|
25
|
-
language = dialect == :tsx ? :tsx : :typescript
|
|
25
|
+
language = (dialect == :tsx) ? :tsx : :typescript
|
|
26
26
|
@root_node = TreeHaver.parser_for(language, backend_type: :tree_sitter).parse(source).root_node
|
|
27
|
-
raise TreeHaver::NotAvailable,
|
|
28
|
-
raise TreeHaver::NotAvailable,
|
|
27
|
+
raise TreeHaver::NotAvailable, "TypeScript parse returned no root node" unless root_node
|
|
28
|
+
raise TreeHaver::NotAvailable, "TypeScript parse contains syntax errors" if root_node.has_error?
|
|
29
29
|
|
|
30
30
|
wrappers = []
|
|
31
31
|
pending_comments = []
|
|
32
32
|
root_node.children.each do |node|
|
|
33
|
-
if node.type ==
|
|
33
|
+
if node.type == "comment"
|
|
34
34
|
if trailing_comment?(wrappers.last, node)
|
|
35
35
|
wrappers.last.attach_trailing_comment!(node)
|
|
36
36
|
else
|
|
@@ -21,13 +21,13 @@ module TypeScript
|
|
|
21
21
|
variable_declaration
|
|
22
22
|
].freeze
|
|
23
23
|
NAMED_DECLARATIONS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
"class_declaration" => [:class, %w[type_identifier identifier]],
|
|
25
|
+
"enum_declaration" => [:enum, %w[identifier type_identifier]],
|
|
26
|
+
"interface_declaration" => [:interface, %w[type_identifier identifier]],
|
|
27
|
+
"type_alias_declaration" => [:type, %w[type_identifier identifier]],
|
|
28
|
+
"internal_module" => [:namespace, %w[identifier string nested_identifier]],
|
|
29
|
+
"function_declaration" => [:function, %w[identifier]],
|
|
30
|
+
"function_signature" => [:function, %w[identifier]]
|
|
31
31
|
}.freeze
|
|
32
32
|
|
|
33
33
|
attr_reader :node, :source, :leading_comments, :trailing_comments
|
|
@@ -40,11 +40,11 @@ module TypeScript
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def signature
|
|
43
|
-
return expression_statement_signature if node.type ==
|
|
44
|
-
return import_signature if node.type ==
|
|
45
|
-
return export_signature if node.type ==
|
|
43
|
+
return expression_statement_signature if node.type == "expression_statement"
|
|
44
|
+
return import_signature if node.type == "import_statement"
|
|
45
|
+
return export_signature if node.type == "export_statement"
|
|
46
46
|
return variable_signature(node) if variable_declaration?(node)
|
|
47
|
-
return ambient_signature if node.type ==
|
|
47
|
+
return ambient_signature if node.type == "ambient_declaration"
|
|
48
48
|
|
|
49
49
|
named_signature(node)
|
|
50
50
|
end
|
|
@@ -69,49 +69,49 @@ module TypeScript
|
|
|
69
69
|
declaration = node.children.find { |child| NAMED_DECLARATIONS.key?(child.type) }
|
|
70
70
|
return named_signature(declaration) if declaration
|
|
71
71
|
|
|
72
|
-
call = direct_child(node,
|
|
73
|
-
raise ArgumentError,
|
|
72
|
+
call = direct_child(node, "call_expression")
|
|
73
|
+
raise ArgumentError, "expression statement is not a supported top-level call" unless call
|
|
74
74
|
|
|
75
75
|
callee = call.children.find(&:named?)
|
|
76
|
-
unless callee && callee.type ==
|
|
77
|
-
raise ArgumentError,
|
|
76
|
+
unless callee && callee.type == "identifier"
|
|
77
|
+
raise ArgumentError, "top-level call has no safely attributable named callee"
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
arguments = direct_child(call,
|
|
80
|
+
arguments = direct_child(call, "arguments")
|
|
81
81
|
identity = arguments&.children&.find(&:named?)
|
|
82
|
-
unless identity && identity.type ==
|
|
83
|
-
raise ArgumentError,
|
|
82
|
+
unless identity && identity.type == "string"
|
|
83
|
+
raise ArgumentError, "top-level call has no literal string identity"
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
[:call, text(callee), text(identity)]
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def import_signature
|
|
90
|
-
source_node = direct_child(node,
|
|
91
|
-
raise ArgumentError,
|
|
90
|
+
source_node = direct_child(node, "string") || find_descendant(node, %w[string])
|
|
91
|
+
raise ArgumentError, "import_statement has no structural module source" unless source_node
|
|
92
92
|
|
|
93
|
-
return [:import, text(source_node), :import_equals] if direct_child(node,
|
|
93
|
+
return [:import, text(source_node), :import_equals] if direct_child(node, "import_require_clause")
|
|
94
94
|
|
|
95
|
-
clause = direct_child(node,
|
|
96
|
-
type_only = !direct_child(node,
|
|
95
|
+
clause = direct_child(node, "import_clause")
|
|
96
|
+
type_only = !direct_child(node, "type").nil?
|
|
97
97
|
[:import, text(source_node), type_only ? :type : :value, import_form(clause)]
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def export_signature
|
|
101
|
-
default = node.children.any? { |child| child.type ==
|
|
101
|
+
default = node.children.any? { |child| child.type == "default" }
|
|
102
102
|
return [:default_export] if default
|
|
103
103
|
|
|
104
104
|
declaration = node.children.find { |child| DECLARATION_TYPES.include?(child.type) }
|
|
105
105
|
return [:export_declaration, declaration_signature(declaration)] if declaration
|
|
106
106
|
|
|
107
|
-
source_node = direct_child(node,
|
|
108
|
-
type_only = !direct_child(node,
|
|
107
|
+
source_node = direct_child(node, "string")
|
|
108
|
+
type_only = !direct_child(node, "type").nil?
|
|
109
109
|
if source_node
|
|
110
110
|
return [:export_from, text(source_node), type_only ? :type : :value, export_form]
|
|
111
111
|
end
|
|
112
|
-
return [:export_local, type_only ? :type : :value, :named] if direct_child(node,
|
|
113
|
-
return [:export_assignment] if node.children.any? { |child| child.type ==
|
|
114
|
-
return [:export_as_namespace] if node.children.any? { |child| child.type ==
|
|
112
|
+
return [:export_local, type_only ? :type : :value, :named] if direct_child(node, "export_clause")
|
|
113
|
+
return [:export_assignment] if node.children.any? { |child| child.type == "=" }
|
|
114
|
+
return [:export_as_namespace] if node.children.any? { |child| child.type == "namespace" }
|
|
115
115
|
|
|
116
116
|
[:export, semantic_node(node)]
|
|
117
117
|
end
|
|
@@ -120,9 +120,9 @@ module TypeScript
|
|
|
120
120
|
return :side_effect unless clause
|
|
121
121
|
|
|
122
122
|
child_types = clause.children.select(&:named?).map(&:type)
|
|
123
|
-
default = child_types.include?(
|
|
124
|
-
named = child_types.include?(
|
|
125
|
-
namespace = child_types.include?(
|
|
123
|
+
default = child_types.include?("identifier")
|
|
124
|
+
named = child_types.include?("named_imports")
|
|
125
|
+
namespace = child_types.include?("namespace_import")
|
|
126
126
|
return :default_named if default && named
|
|
127
127
|
return :default_namespace if default && namespace
|
|
128
128
|
return :default if default
|
|
@@ -133,16 +133,16 @@ module TypeScript
|
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
def export_form
|
|
136
|
-
return :named if direct_child(node,
|
|
137
|
-
return :namespace if direct_child(node,
|
|
138
|
-
return :all if node.children.any? { |child| child.type ==
|
|
136
|
+
return :named if direct_child(node, "export_clause")
|
|
137
|
+
return :namespace if direct_child(node, "namespace_export")
|
|
138
|
+
return :all if node.children.any? { |child| child.type == "*" }
|
|
139
139
|
|
|
140
|
-
raise ArgumentError,
|
|
140
|
+
raise ArgumentError, "unsupported structural export-from form"
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
def declaration_signature(declaration)
|
|
144
144
|
return variable_signature(declaration) if variable_declaration?(declaration)
|
|
145
|
-
return ambient_signature(declaration) if declaration.type ==
|
|
145
|
+
return ambient_signature(declaration) if declaration.type == "ambient_declaration"
|
|
146
146
|
|
|
147
147
|
named_signature(declaration)
|
|
148
148
|
end
|
|
@@ -158,10 +158,10 @@ module TypeScript
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
def variable_signature(value)
|
|
161
|
-
declarators = value.children.select { |child| child.type ==
|
|
161
|
+
declarators = value.children.select { |child| child.type == "variable_declarator" }
|
|
162
162
|
names = declarators.map do |declarator|
|
|
163
163
|
name = declarator.children.find(&:named?)
|
|
164
|
-
raise ArgumentError,
|
|
164
|
+
raise ArgumentError, "variable_declarator has no binding" unless name
|
|
165
165
|
raise ArgumentError, "unsupported variable binding #{name.type}" unless %w[identifier].include?(name.type)
|
|
166
166
|
|
|
167
167
|
text(name)
|
|
@@ -173,12 +173,12 @@ module TypeScript
|
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
def ambient_signature(value = node)
|
|
176
|
-
declaration = value.children.find { |child| child.named? && child.type !=
|
|
177
|
-
raise ArgumentError,
|
|
176
|
+
declaration = value.children.find { |child| child.named? && child.type != "declare" }
|
|
177
|
+
raise ArgumentError, "ambient_declaration has no declaration" unless declaration
|
|
178
178
|
|
|
179
|
-
if declaration.type ==
|
|
179
|
+
if declaration.type == "module"
|
|
180
180
|
name = declaration.children.find { |child| %w[string identifier nested_identifier].include?(child.type) }
|
|
181
|
-
raise ArgumentError,
|
|
181
|
+
raise ArgumentError, "module augmentation has no structural name" unless name
|
|
182
182
|
|
|
183
183
|
return [:module_augmentation, text(name)]
|
|
184
184
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "digest"
|
|
4
|
+
require "json"
|
|
5
5
|
|
|
6
6
|
module TypeScript
|
|
7
7
|
module Merge
|
|
@@ -16,8 +16,8 @@ module TypeScript
|
|
|
16
16
|
ExactDocument = Data.define(:source, :analysis, :declarations, :issues, :role)
|
|
17
17
|
Decision = Data.define(:changes, :conflicts, :choices)
|
|
18
18
|
|
|
19
|
-
def provider_id =
|
|
20
|
-
def family =
|
|
19
|
+
def provider_id = "ruby.typescript"
|
|
20
|
+
def family = "typescript"
|
|
21
21
|
|
|
22
22
|
def capabilities
|
|
23
23
|
{
|
|
@@ -43,7 +43,7 @@ module TypeScript
|
|
|
43
43
|
valid: true,
|
|
44
44
|
declarations: document.owners.map { |owner| owner_description(owner) }
|
|
45
45
|
},
|
|
46
|
-
verification: {
|
|
46
|
+
verification: {source_parsed: true}
|
|
47
47
|
)
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -58,9 +58,9 @@ module TypeScript
|
|
|
58
58
|
result(
|
|
59
59
|
:diff2,
|
|
60
60
|
request,
|
|
61
|
-
diff: {
|
|
61
|
+
diff: {changes: changes},
|
|
62
62
|
changes: changes,
|
|
63
|
-
verification: {
|
|
63
|
+
verification: {before_parsed: true, after_parsed: true}
|
|
64
64
|
)
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -110,7 +110,7 @@ module TypeScript
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def parse_document(operation, request, role)
|
|
113
|
-
source = request.fetch(role == :source ? :source : :"#{role}_source")
|
|
113
|
+
source = request.fetch((role == :source) ? :source : :"#{role}_source")
|
|
114
114
|
parsed = parse_source(source, role, request[:dialect])
|
|
115
115
|
return parse_failure(operation, request, role, parsed) if provider_failure?(parsed)
|
|
116
116
|
|
|
@@ -120,11 +120,11 @@ module TypeScript
|
|
|
120
120
|
def parse_source(source, role, dialect = nil)
|
|
121
121
|
analysis = FileAnalysis.new(source, dialect: dialect || :typescript)
|
|
122
122
|
unless analysis.errors.empty? && analysis.backend == TREE_SITTER_BACKEND.id.to_sym
|
|
123
|
-
return {
|
|
123
|
+
return {parse_error: analysis.errors.map(&:to_s).join("; "), source_role: role}
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
owners = analysis.declarations.map do |wrapper|
|
|
127
|
-
return {
|
|
127
|
+
return {unsafe_range: wrapper.signature, source_role: role} unless safe_range?(source, wrapper)
|
|
128
128
|
|
|
129
129
|
signature = wrapper.signature
|
|
130
130
|
Owner.new(
|
|
@@ -137,12 +137,12 @@ module TypeScript
|
|
|
137
137
|
)
|
|
138
138
|
end
|
|
139
139
|
duplicate = owners.group_by(&:id).find { |_id, matches| matches.length > 1 }
|
|
140
|
-
return {
|
|
140
|
+
return {ambiguous_owner: duplicate.first, source_role: role} if duplicate
|
|
141
141
|
|
|
142
142
|
declaration_merge = owners.group_by { |owner| declaration_merge_key(owner.signature) }
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
return {
|
|
143
|
+
.find { |key, matches| key && matches.length > 1 }
|
|
144
|
+
return {ambiguous_owner: declaration_merge.first, source_role: role} if declaration_merge
|
|
145
|
+
return {unsafe_range: :overlapping_declarations, source_role: role} unless non_overlapping?(owners)
|
|
146
146
|
|
|
147
147
|
Document.new(
|
|
148
148
|
source: source,
|
|
@@ -151,14 +151,14 @@ module TypeScript
|
|
|
151
151
|
by_id: owners.to_h { |owner| [owner.id, owner] }.freeze,
|
|
152
152
|
unmanaged_fingerprint: unmanaged_fingerprint(source, owners)
|
|
153
153
|
)
|
|
154
|
-
rescue
|
|
155
|
-
{
|
|
154
|
+
rescue => e
|
|
155
|
+
{parse_error: e.message, source_role: role}
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
def parse_exact_source(source, role, dialect = nil)
|
|
159
159
|
analysis = FileAnalysis.new(source, dialect: dialect || :typescript)
|
|
160
160
|
unless analysis.errors.empty? && analysis.backend == TREE_SITTER_BACKEND.id.to_sym
|
|
161
|
-
return {
|
|
161
|
+
return {parse_error: analysis.errors.map(&:to_s).join("; "), source_role: role}
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
declarations = analysis.declarations.map do |wrapper|
|
|
@@ -185,8 +185,8 @@ module TypeScript
|
|
|
185
185
|
issues: issues.freeze,
|
|
186
186
|
role: role
|
|
187
187
|
)
|
|
188
|
-
rescue
|
|
189
|
-
{
|
|
188
|
+
rescue => e
|
|
189
|
+
{parse_error: e.message, source_role: role}
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
def safe_range?(source, wrapper)
|
|
@@ -229,14 +229,14 @@ module TypeScript
|
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
def declaration_merge_key(signature)
|
|
232
|
-
value = signature.first == :export_declaration ? signature.fetch(1) : signature
|
|
232
|
+
value = (signature.first == :export_declaration) ? signature.fetch(1) : signature
|
|
233
233
|
return unless %i[class enum function interface namespace].include?(value.first)
|
|
234
234
|
|
|
235
235
|
value.last
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
def owner_path(owner)
|
|
239
|
-
owner ? owner.signature.inspect :
|
|
239
|
+
owner ? owner.signature.inspect : "<document>"
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
def owner_description(owner)
|
|
@@ -264,9 +264,9 @@ module TypeScript
|
|
|
264
264
|
end
|
|
265
265
|
|
|
266
266
|
def change_side(owner)
|
|
267
|
-
return {
|
|
267
|
+
return {present: false} unless owner
|
|
268
268
|
|
|
269
|
-
{
|
|
269
|
+
{present: true, source_role: owner.role, line_range: [owner.start_line, owner.end_line]}
|
|
270
270
|
end
|
|
271
271
|
|
|
272
272
|
def ordered_ids(*documents)
|
|
@@ -316,9 +316,9 @@ module TypeScript
|
|
|
316
316
|
return if ours == theirs
|
|
317
317
|
|
|
318
318
|
change = {
|
|
319
|
-
path:
|
|
320
|
-
ours: base == ours ? :unchanged : :edited,
|
|
321
|
-
theirs: base == theirs ? :unchanged : :edited
|
|
319
|
+
path: "<unmanaged-source>",
|
|
320
|
+
ours: (base == ours) ? :unchanged : :edited,
|
|
321
|
+
theirs: (base == theirs) ? :unchanged : :edited
|
|
322
322
|
}.freeze
|
|
323
323
|
changes << change
|
|
324
324
|
conflicts << {
|
|
@@ -333,7 +333,7 @@ module TypeScript
|
|
|
333
333
|
def grouped_ownership_failure(request, documents)
|
|
334
334
|
signatures = documents.transform_values do |document|
|
|
335
335
|
document.owners.filter_map { |owner| owner.signature if grouped_owner?(owner) }
|
|
336
|
-
|
|
336
|
+
.sort_by { |signature| JSON.generate(Ast::Merge.json_ready(signature)) }
|
|
337
337
|
end
|
|
338
338
|
return if signatures.values.uniq.length == 1
|
|
339
339
|
|
|
@@ -341,7 +341,7 @@ module TypeScript
|
|
|
341
341
|
conflict = {
|
|
342
342
|
conflict_id: "typescript-compound-#{signature_digest[0, 16]}",
|
|
343
343
|
category: :unproven_compound_ownership,
|
|
344
|
-
path:
|
|
344
|
+
path: "<compound-declarations>",
|
|
345
345
|
owner_id: nil,
|
|
346
346
|
member_signatures: signatures
|
|
347
347
|
}.freeze
|
|
@@ -351,12 +351,12 @@ module TypeScript
|
|
|
351
351
|
:merge3,
|
|
352
352
|
request,
|
|
353
353
|
category: :unproven_compound_ownership,
|
|
354
|
-
message:
|
|
355
|
-
|
|
354
|
+
message: "Compound TypeScript declaration membership differs across revisions; " \
|
|
355
|
+
"whole-owner identity is unproven.",
|
|
356
356
|
conflicts: [conflict],
|
|
357
357
|
conflicted_output: rendered.content,
|
|
358
358
|
render_report: render_report(rendered, :full_file_conflict),
|
|
359
|
-
verification: {
|
|
359
|
+
verification: {base_participated: true},
|
|
360
360
|
fallbacks: [{
|
|
361
361
|
from: :compound_declaration_ownership,
|
|
362
362
|
to: :full_file_conflict,
|
|
@@ -393,7 +393,7 @@ module TypeScript
|
|
|
393
393
|
def conflict_for(id, base, ours, theirs, change)
|
|
394
394
|
{
|
|
395
395
|
conflict_id: "typescript-declaration-#{id[0, 16]}",
|
|
396
|
-
category: base && (!ours || !theirs) ? :delete_edit : :edit_edit,
|
|
396
|
+
category: (base && (!ours || !theirs)) ? :delete_edit : :edit_edit,
|
|
397
397
|
path: change.fetch(:path),
|
|
398
398
|
owner_id: id,
|
|
399
399
|
base: owner_state(base),
|
|
@@ -440,8 +440,8 @@ module TypeScript
|
|
|
440
440
|
:merge3,
|
|
441
441
|
request,
|
|
442
442
|
category: :render_failure,
|
|
443
|
-
message:
|
|
444
|
-
|
|
443
|
+
message: "TypeScript exact revision did not remain byte-exact and semantically identical " \
|
|
444
|
+
"after native reparse.",
|
|
445
445
|
source_role: role,
|
|
446
446
|
render_report: render_report(rendered, :exact_revision),
|
|
447
447
|
verification: verification.merge(base_participated: true)
|
|
@@ -518,7 +518,7 @@ module TypeScript
|
|
|
518
518
|
:merge3,
|
|
519
519
|
request,
|
|
520
520
|
category: :render_failure,
|
|
521
|
-
message:
|
|
521
|
+
message: "TypeScript composite did not match the planned ordered declaration structure and AST attributes.",
|
|
522
522
|
changes: decision.changes,
|
|
523
523
|
render_report: render_report(rendered, :exact_declaration_composite),
|
|
524
524
|
verification: verification.merge(base_participated: true)
|
|
@@ -617,15 +617,15 @@ module TypeScript
|
|
|
617
617
|
fragments.pop
|
|
618
618
|
end
|
|
619
619
|
content = if fragment.is_a?(Ast::Merge::SourceRender::SourceFragment)
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
620
|
+
documents.fetch(fragment.revision).source.lines.fetch(fragment.end_line - 1)
|
|
621
|
+
else
|
|
622
|
+
fragment.content
|
|
623
|
+
end
|
|
624
624
|
fragments << Ast::Merge::SourceRender::SynthesizedFragment.new(
|
|
625
625
|
content: "#{content}\n",
|
|
626
626
|
reason: :declaration_separator,
|
|
627
627
|
producer: provider_id,
|
|
628
|
-
metadata: {
|
|
628
|
+
metadata: {source_role: fragment.respond_to?(:revision) ? fragment.revision : nil, copied_source: true}
|
|
629
629
|
)
|
|
630
630
|
end
|
|
631
631
|
|
|
@@ -668,7 +668,7 @@ module TypeScript
|
|
|
668
668
|
end
|
|
669
669
|
|
|
670
670
|
def grouped_owner?(owner)
|
|
671
|
-
signature = owner.signature.first == :export_declaration ? owner.signature.fetch(1) : owner.signature
|
|
671
|
+
signature = (owner.signature.first == :export_declaration) ? owner.signature.fetch(1) : owner.signature
|
|
672
672
|
signature.first == :variables && signature.last.length > 1
|
|
673
673
|
end
|
|
674
674
|
|
|
@@ -676,7 +676,7 @@ module TypeScript
|
|
|
676
676
|
owner.signature.first == :import
|
|
677
677
|
end
|
|
678
678
|
|
|
679
|
-
|
|
679
|
+
alias_method :package_or_import_owner?, :import_owner?
|
|
680
680
|
|
|
681
681
|
def verify_rendered(output, expected, dialect)
|
|
682
682
|
parsed = parse_source(output, :output, dialect)
|
|
@@ -713,7 +713,7 @@ module TypeScript
|
|
|
713
713
|
decision,
|
|
714
714
|
rendered,
|
|
715
715
|
:full_file_conflict,
|
|
716
|
-
fallbacks: [{
|
|
716
|
+
fallbacks: [{from: :declaration_localization, to: :full_file_conflict, reason: :source_ownership_unproven}]
|
|
717
717
|
)
|
|
718
718
|
end
|
|
719
719
|
|
|
@@ -747,7 +747,7 @@ module TypeScript
|
|
|
747
747
|
theirs: conflict_declaration_side(documents, conflict, :theirs),
|
|
748
748
|
labels: request.fetch(:labels, {}),
|
|
749
749
|
marker_size: request.fetch(:conflict_marker_size, 7),
|
|
750
|
-
metadata: {
|
|
750
|
+
metadata: {path: conflict.fetch(:path), category: conflict.fetch(:category)}
|
|
751
751
|
)
|
|
752
752
|
end
|
|
753
753
|
|
|
@@ -764,7 +764,7 @@ module TypeScript
|
|
|
764
764
|
conflict = {
|
|
765
765
|
conflict_id: conflict_id,
|
|
766
766
|
category: parsed[:ambiguous_owner] ? :ambiguous_owner : :unsafe_source_range,
|
|
767
|
-
path:
|
|
767
|
+
path: "<document>",
|
|
768
768
|
owner_id: nil,
|
|
769
769
|
source_role: role
|
|
770
770
|
}
|
|
@@ -781,7 +781,7 @@ module TypeScript
|
|
|
781
781
|
conflicted_output: rendered.content,
|
|
782
782
|
source_role: role,
|
|
783
783
|
render_report: render_report(rendered, :full_file_conflict),
|
|
784
|
-
verification: {
|
|
784
|
+
verification: {base_participated: true}
|
|
785
785
|
)
|
|
786
786
|
end
|
|
787
787
|
|
|
@@ -793,7 +793,7 @@ module TypeScript
|
|
|
793
793
|
theirs: [conflict_whole_source_fragment(:theirs, request.fetch(:theirs_source))],
|
|
794
794
|
labels: request.fetch(:labels, {}),
|
|
795
795
|
marker_size: request.fetch(:conflict_marker_size, 7),
|
|
796
|
-
metadata: {
|
|
796
|
+
metadata: {conflicts: decision.conflicts.map { |conflict| conflict[:conflict_id] }}
|
|
797
797
|
)
|
|
798
798
|
end
|
|
799
799
|
|
|
@@ -815,12 +815,12 @@ module TypeScript
|
|
|
815
815
|
content: content,
|
|
816
816
|
reason: reason,
|
|
817
817
|
producer: provider_id,
|
|
818
|
-
metadata: {
|
|
818
|
+
metadata: {source_role: role, copied_source: true}
|
|
819
819
|
)
|
|
820
820
|
end
|
|
821
821
|
|
|
822
822
|
def whole_source_fragment(role, source)
|
|
823
|
-
return synthesized_copy(
|
|
823
|
+
return synthesized_copy("", :exact_empty_source, role) if source.empty?
|
|
824
824
|
|
|
825
825
|
source_range_fragment(role, 1, source.lines.length)
|
|
826
826
|
end
|
|
@@ -830,7 +830,7 @@ module TypeScript
|
|
|
830
830
|
revision: role,
|
|
831
831
|
start_line: start_line,
|
|
832
832
|
end_line: end_line,
|
|
833
|
-
metadata: {
|
|
833
|
+
metadata: {source_role: role}
|
|
834
834
|
)
|
|
835
835
|
end
|
|
836
836
|
|
|
@@ -843,7 +843,7 @@ module TypeScript
|
|
|
843
843
|
theirs: request[:theirs_source].to_s
|
|
844
844
|
},
|
|
845
845
|
fragments: fragments,
|
|
846
|
-
metadata: {
|
|
846
|
+
metadata: {provider_id: provider_id}
|
|
847
847
|
)
|
|
848
848
|
)
|
|
849
849
|
end
|
|
@@ -863,24 +863,24 @@ module TypeScript
|
|
|
863
863
|
:merge3,
|
|
864
864
|
request,
|
|
865
865
|
category: :merge_conflict,
|
|
866
|
-
message:
|
|
866
|
+
message: "TypeScript top-level declaration changed incompatibly on both sides.",
|
|
867
867
|
changes: decision.changes,
|
|
868
868
|
conflicts: decision.conflicts,
|
|
869
869
|
conflicted_output: rendered.content,
|
|
870
870
|
render_report: render_report(rendered, strategy),
|
|
871
|
-
verification: {
|
|
871
|
+
verification: {base_participated: true},
|
|
872
872
|
fallbacks: fallbacks
|
|
873
873
|
)
|
|
874
874
|
end
|
|
875
875
|
|
|
876
876
|
def parse_failure(operation, request, role, parsed)
|
|
877
877
|
category = if parsed[:parse_error]
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
878
|
+
:parse_error
|
|
879
|
+
elsif parsed[:ambiguous_owner]
|
|
880
|
+
:ambiguous_owner
|
|
881
|
+
else
|
|
882
|
+
:unsafe_source_range
|
|
883
|
+
end
|
|
884
884
|
failure(
|
|
885
885
|
operation,
|
|
886
886
|
request,
|
|
@@ -918,7 +918,7 @@ module TypeScript
|
|
|
918
918
|
end
|
|
919
919
|
|
|
920
920
|
def failure(operation, request, category:, message:, changes: [], conflicts: [], fallbacks: [],
|
|
921
|
-
|
|
921
|
+
render_report: {}, verification: {}, **payload)
|
|
922
922
|
Ast::Merge::ProviderResult.build(
|
|
923
923
|
operation: operation,
|
|
924
924
|
success: false,
|
|
@@ -927,7 +927,7 @@ module TypeScript
|
|
|
927
927
|
changes: changes,
|
|
928
928
|
conflicts: conflicts,
|
|
929
929
|
fallbacks: fallbacks,
|
|
930
|
-
diagnostics: [{
|
|
930
|
+
diagnostics: [{category: category, severity: :error, message: message, blocking: true}],
|
|
931
931
|
render_report: render_report,
|
|
932
932
|
verification: verification
|
|
933
933
|
),
|
|
@@ -942,10 +942,10 @@ module TypeScript
|
|
|
942
942
|
family: family,
|
|
943
943
|
dialect: request[:dialect] || :typescript,
|
|
944
944
|
backend: request[:backend] || TREE_SITTER_BACKEND.id.to_sym,
|
|
945
|
-
package:
|
|
945
|
+
package: "typescript-merge",
|
|
946
946
|
package_version: TypeScript::Merge::Version::VERSION
|
|
947
947
|
},
|
|
948
|
-
profile: {
|
|
948
|
+
profile: {profile_id: request[:profile_id] || DEFAULT_PROFILE}
|
|
949
949
|
}.merge(fields)
|
|
950
950
|
end
|
|
951
951
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "ast/merge"
|
|
4
|
+
require "ast/merge/typed_core_provider"
|
|
5
5
|
|
|
6
6
|
module TypeScript
|
|
7
7
|
module Merge
|
|
8
8
|
# Opt-in typed TypeScript/TSX declaration profile. Compatibility name, not a prototype dependency.
|
|
9
9
|
class RustHostProvider < Ast::Merge::TypedCoreProvider
|
|
10
|
-
PROVIDER_ID =
|
|
11
|
-
FAMILY =
|
|
10
|
+
PROVIDER_ID = "rust.typescript"
|
|
11
|
+
FAMILY = "typescript"
|
|
12
12
|
DIALECTS = %i[typescript tsx].freeze
|
|
13
13
|
OPERATIONS = %i[analyze diff2 merge2 merge3].freeze
|
|
14
|
-
CORE_PROVIDER =
|
|
15
|
-
CORE_PROFILE =
|
|
16
|
-
PACKAGE =
|
|
14
|
+
CORE_PROVIDER = "kernel.typescript"
|
|
15
|
+
CORE_PROFILE = "kernel.typescript.owners.v1"
|
|
16
|
+
PACKAGE = "typescript-merge"
|
|
17
17
|
|
|
18
18
|
def capabilities
|
|
19
19
|
super.merge(ast_ownership: :top_level_declarations).freeze
|
|
@@ -24,23 +24,23 @@ module TypeScript
|
|
|
24
24
|
def parser_backends = %i[rust_tslp typescript_oxc]
|
|
25
25
|
|
|
26
26
|
def parser_backend_available?(backend)
|
|
27
|
-
return super unless backend ==
|
|
27
|
+
return super unless backend == "typescript_oxc"
|
|
28
28
|
|
|
29
|
-
require
|
|
29
|
+
require "structuredmerge_core" unless defined?(::StructuredmergeCore)
|
|
30
30
|
::StructuredmergeCore.respond_to?(:register_typescript_oxc_parser)
|
|
31
31
|
rescue LoadError
|
|
32
32
|
false
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def register_parser_backend(dialect, backend)
|
|
36
|
-
return super unless backend ==
|
|
36
|
+
return super unless backend == "typescript_oxc"
|
|
37
37
|
|
|
38
|
-
core.register_typescript_oxc_parser(
|
|
38
|
+
core.register_typescript_oxc_parser("typescript.oxc.ruby").id
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def package_version = TypeScript::Merge::Version::VERSION
|
|
42
42
|
def parser_language(dialect) = dialect
|
|
43
|
-
def owner_path(owner) = owner.fetch(
|
|
43
|
+
def owner_path(owner) = owner.fetch("id")
|
|
44
44
|
|
|
45
45
|
def additional_fields = %i[path_name labels conflict_marker_size]
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ module TypeScript
|
|
|
53
53
|
width = Integer(width, 10) if width.is_a?(String)
|
|
54
54
|
unless labels == {} && (width.nil? || (width.is_a?(Integer) && width == 7))
|
|
55
55
|
raise Ast::Merge::TypedCoreProvider::UnsupportedCapabilityError,
|
|
56
|
-
|
|
56
|
+
"Typed TypeScript does not support custom conflict markers or labels"
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
super
|
|
@@ -5,7 +5,7 @@ module TypeScript
|
|
|
5
5
|
# Version namespace for this gem.
|
|
6
6
|
module Version
|
|
7
7
|
# Current gem version.
|
|
8
|
-
VERSION =
|
|
8
|
+
VERSION = "8.0.0"
|
|
9
9
|
end
|
|
10
10
|
# Current gem version exposed at the traditional constant location.
|
|
11
11
|
VERSION = Version::VERSION # Traditional Constant Location
|
data/lib/typescript/merge.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require_relative
|
|
3
|
+
require "tree_haver"
|
|
4
|
+
require "ast/merge"
|
|
5
|
+
require_relative "merge/version"
|
|
6
6
|
|
|
7
7
|
module TypeScript
|
|
8
8
|
module Merge
|
|
9
9
|
module_function
|
|
10
10
|
|
|
11
|
-
PACKAGE_NAME =
|
|
11
|
+
PACKAGE_NAME = "typescript-merge"
|
|
12
12
|
TREE_SITTER_BACKEND = TreeHaver::KREUZBERG_LANGUAGE_PACK_BACKEND
|
|
13
|
-
DESTINATION_WINS_ARRAY_POLICY = {
|
|
13
|
+
DESTINATION_WINS_ARRAY_POLICY = {surface: "array", name: "destination_wins_array"}.freeze
|
|
14
14
|
BACKEND_REGISTRY = Struct.new(:registered, :mutex).new(false, Mutex.new)
|
|
15
15
|
|
|
16
|
-
autoload :NodeWrapper,
|
|
17
|
-
autoload :FileAnalysis,
|
|
18
|
-
autoload :Provider,
|
|
19
|
-
autoload :RustHostProvider,
|
|
16
|
+
autoload :NodeWrapper, "typescript/merge/node_wrapper"
|
|
17
|
+
autoload :FileAnalysis, "typescript/merge/file_analysis"
|
|
18
|
+
autoload :Provider, "typescript/merge/provider"
|
|
19
|
+
autoload :RustHostProvider, "typescript/merge/rust_host_provider"
|
|
20
20
|
|
|
21
21
|
def register_backend!
|
|
22
22
|
BACKEND_REGISTRY.mutex.synchronize do
|
|
@@ -30,7 +30,7 @@ module TypeScript
|
|
|
30
30
|
:tsx,
|
|
31
31
|
backend_module: TreeHaver::Backends::Tslp,
|
|
32
32
|
backend_type: :tslp,
|
|
33
|
-
gem_name:
|
|
33
|
+
gem_name: "tree_sitter_language_pack"
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
BACKEND_REGISTRY.registered = true
|
|
@@ -39,7 +39,7 @@ module TypeScript
|
|
|
39
39
|
|
|
40
40
|
def type_script_feature_profile
|
|
41
41
|
{
|
|
42
|
-
family:
|
|
42
|
+
family: "typescript",
|
|
43
43
|
supported_dialects: %w[typescript tsx],
|
|
44
44
|
supported_policies: [DESTINATION_WINS_ARRAY_POLICY]
|
|
45
45
|
}
|
|
@@ -78,13 +78,13 @@ module TypeScript
|
|
|
78
78
|
|
|
79
79
|
def parse_type_script(source, dialect)
|
|
80
80
|
unless type_script_backend_available_for_analysis?(nil)
|
|
81
|
-
diagnostic_backend = TreeHaver.current_backend_id ||
|
|
81
|
+
diagnostic_backend = TreeHaver.current_backend_id || "tree-sitter"
|
|
82
82
|
return unsupported_feature_result("Unsupported TypeScript backend #{diagnostic_backend}.")
|
|
83
83
|
end
|
|
84
84
|
return analyze_type_script_module(source, dialect: dialect) if %w[typescript tsx].include?(dialect)
|
|
85
85
|
|
|
86
|
-
{
|
|
87
|
-
|
|
86
|
+
{ok: false,
|
|
87
|
+
diagnostics: [{severity: "error", category: "unsupported_feature", message: "Unsupported TypeScript dialect #{dialect}."}], policies: []}
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def type_script_backend_available_for_analysis?(backend_id)
|
|
@@ -103,9 +103,9 @@ module TypeScript
|
|
|
103
103
|
def requested_tree_sitter_backend_id(backend)
|
|
104
104
|
return backend.to_s unless backend.to_s.empty?
|
|
105
105
|
|
|
106
|
-
contextual = TreeHaver.current_backend_id || ENV[
|
|
107
|
-
return TREE_SITTER_BACKEND.id if contextual.to_s.empty? || contextual.to_s ==
|
|
108
|
-
return TREE_SITTER_BACKEND.id if contextual.to_s ==
|
|
106
|
+
contextual = TreeHaver.current_backend_id || ENV["TREE_HAVER_BACKEND"]
|
|
107
|
+
return TREE_SITTER_BACKEND.id if contextual.to_s.empty? || contextual.to_s == "auto"
|
|
108
|
+
return TREE_SITTER_BACKEND.id if contextual.to_s == "rust_tslp"
|
|
109
109
|
|
|
110
110
|
contextual.to_s
|
|
111
111
|
end
|
|
@@ -135,14 +135,14 @@ module TypeScript
|
|
|
135
135
|
|
|
136
136
|
def merge_type_script(template_source, destination_source, dialect)
|
|
137
137
|
template = parse_type_script(template_source, dialect)
|
|
138
|
-
return {
|
|
138
|
+
return {ok: false, diagnostics: template[:diagnostics], policies: []} unless template[:ok]
|
|
139
139
|
|
|
140
140
|
destination = parse_type_script(destination_source, dialect)
|
|
141
141
|
unless destination[:ok]
|
|
142
142
|
return {
|
|
143
143
|
ok: false,
|
|
144
144
|
diagnostics: destination[:diagnostics].map do |diagnostic|
|
|
145
|
-
diagnostic[:category] ==
|
|
145
|
+
(diagnostic[:category] == "parse_error") ? diagnostic.merge(category: "destination_parse_error") : diagnostic
|
|
146
146
|
end,
|
|
147
147
|
policies: []
|
|
148
148
|
}
|
|
@@ -150,18 +150,18 @@ module TypeScript
|
|
|
150
150
|
|
|
151
151
|
destination_declarations = destination.dig(:analysis, :declarations).to_h { |item| [item[:path], item] }
|
|
152
152
|
merged_declaration_texts = destination.dig(:analysis, :declarations).map { |item| item[:text] } +
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
template.dig(:analysis, :declarations).reject do |item|
|
|
154
|
+
destination_declarations[item[:path]]
|
|
155
|
+
end.map { |item| item[:text] }
|
|
156
156
|
import_block = destination.dig(:analysis, :imports).map { |item| item[:text] }.join
|
|
157
157
|
declaration_block = merged_declaration_texts.join("\n").rstrip
|
|
158
158
|
sections = [import_block.rstrip, declaration_block].reject(&:empty?)
|
|
159
159
|
|
|
160
|
-
{
|
|
161
|
-
|
|
160
|
+
{ok: true, diagnostics: [], output: "#{sections.join("\n\n").rstrip}\n",
|
|
161
|
+
policies: [DESTINATION_WINS_ARRAY_POLICY]}
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
def analyze_type_script_module(source, dialect:
|
|
164
|
+
def analyze_type_script_module(source, dialect: "typescript")
|
|
165
165
|
analysis = FileAnalysis.new(source, dialect: dialect)
|
|
166
166
|
raise analysis.errors.first unless analysis.errors.empty?
|
|
167
167
|
|
|
@@ -172,7 +172,7 @@ module TypeScript
|
|
|
172
172
|
if signature.first == :import
|
|
173
173
|
imports << {
|
|
174
174
|
path: "/imports/#{imports.length}",
|
|
175
|
-
owner_kind:
|
|
175
|
+
owner_kind: "import",
|
|
176
176
|
match_key: legacy_import_key(signature),
|
|
177
177
|
text: "#{wrapper.source_text}\n"
|
|
178
178
|
}
|
|
@@ -180,7 +180,7 @@ module TypeScript
|
|
|
180
180
|
name = legacy_declaration_key(signature)
|
|
181
181
|
declarations << {
|
|
182
182
|
path: "/declarations/#{name}",
|
|
183
|
-
owner_kind:
|
|
183
|
+
owner_kind: "declaration",
|
|
184
184
|
match_key: name,
|
|
185
185
|
text: "#{wrapper.source_text}\n"
|
|
186
186
|
}
|
|
@@ -191,7 +191,7 @@ module TypeScript
|
|
|
191
191
|
ok: true,
|
|
192
192
|
diagnostics: [],
|
|
193
193
|
analysis: {
|
|
194
|
-
kind:
|
|
194
|
+
kind: "typescript",
|
|
195
195
|
dialect: dialect,
|
|
196
196
|
imports: imports,
|
|
197
197
|
declarations: declarations,
|
|
@@ -205,9 +205,9 @@ module TypeScript
|
|
|
205
205
|
private_class_method :analyze_type_script_module
|
|
206
206
|
|
|
207
207
|
def legacy_declaration_key(signature)
|
|
208
|
-
nested = signature.first == :export_declaration ? signature.fetch(1) : signature
|
|
208
|
+
nested = (signature.first == :export_declaration) ? signature.fetch(1) : signature
|
|
209
209
|
value = nested.last
|
|
210
|
-
value.is_a?(Array) ? value.join(
|
|
210
|
+
value.is_a?(Array) ? value.join(",") : value
|
|
211
211
|
end
|
|
212
212
|
private_class_method :legacy_declaration_key
|
|
213
213
|
|
|
@@ -218,9 +218,9 @@ module TypeScript
|
|
|
218
218
|
private_class_method :legacy_import_key
|
|
219
219
|
|
|
220
220
|
def parse_failure_result(error)
|
|
221
|
-
{
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
{ok: false,
|
|
222
|
+
diagnostics: [{severity: "error", category: "parse_error", message: error.message}],
|
|
223
|
+
policies: []}
|
|
224
224
|
end
|
|
225
225
|
private_class_method :parse_failure_result
|
|
226
226
|
|
|
@@ -230,7 +230,7 @@ module TypeScript
|
|
|
230
230
|
private_class_method :owner_view
|
|
231
231
|
|
|
232
232
|
def owner_views(items)
|
|
233
|
-
imports, declarations = items.partition { |item| item.fetch(:owner_kind) ==
|
|
233
|
+
imports, declarations = items.partition { |item| item.fetch(:owner_kind) == "import" }
|
|
234
234
|
(imports + declarations.sort_by { |item| item.fetch(:path) }).map { |item| owner_view(item) }
|
|
235
235
|
end
|
|
236
236
|
private_class_method :owner_views
|
|
@@ -238,7 +238,7 @@ module TypeScript
|
|
|
238
238
|
def unsupported_feature_result(message)
|
|
239
239
|
{
|
|
240
240
|
ok: false,
|
|
241
|
-
diagnostics: [{
|
|
241
|
+
diagnostics: [{severity: "error", category: "unsupported_feature", message: message}],
|
|
242
242
|
policies: []
|
|
243
243
|
}
|
|
244
244
|
end
|
data/lib/typescript-merge.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require
|
|
5
|
-
require_relative
|
|
3
|
+
require_relative "typescript/merge"
|
|
4
|
+
require "version_gem"
|
|
5
|
+
require_relative "typescript/merge/version"
|
|
6
6
|
|
|
7
7
|
TypeScript::Merge::Version.class_eval do
|
|
8
8
|
extend VersionGem::Basic
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: typescript-merge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -44,7 +44,7 @@ dependencies:
|
|
|
44
44
|
-
|
|
45
45
|
- "="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 8.0.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -52,7 +52,7 @@ dependencies:
|
|
|
52
52
|
-
|
|
53
53
|
- "="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version:
|
|
55
|
+
version: 8.0.0
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: tree_haver
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -60,7 +60,7 @@ dependencies:
|
|
|
60
60
|
-
|
|
61
61
|
- "="
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version:
|
|
63
|
+
version: 8.0.0
|
|
64
64
|
type: :runtime
|
|
65
65
|
prerelease: false
|
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -68,7 +68,7 @@ dependencies:
|
|
|
68
68
|
-
|
|
69
69
|
- "="
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
|
-
version:
|
|
71
|
+
version: 8.0.0
|
|
72
72
|
- !ruby/object:Gem::Dependency
|
|
73
73
|
name: version_gem
|
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -104,7 +104,7 @@ dependencies:
|
|
|
104
104
|
-
|
|
105
105
|
- ">="
|
|
106
106
|
- !ruby/object:Gem::Version
|
|
107
|
-
version: 3.1.
|
|
107
|
+
version: 3.1.41
|
|
108
108
|
type: :development
|
|
109
109
|
prerelease: false
|
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -116,7 +116,7 @@ dependencies:
|
|
|
116
116
|
-
|
|
117
117
|
- ">="
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: 3.1.
|
|
119
|
+
version: 3.1.41
|
|
120
120
|
- !ruby/object:Gem::Dependency
|
|
121
121
|
name: bundler-audit
|
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -232,7 +232,7 @@ dependencies:
|
|
|
232
232
|
-
|
|
233
233
|
- ">="
|
|
234
234
|
- !ruby/object:Gem::Version
|
|
235
|
-
version: 2.0.
|
|
235
|
+
version: 2.0.32
|
|
236
236
|
type: :development
|
|
237
237
|
prerelease: false
|
|
238
238
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -244,7 +244,7 @@ dependencies:
|
|
|
244
244
|
-
|
|
245
245
|
- ">="
|
|
246
246
|
- !ruby/object:Gem::Version
|
|
247
|
-
version: 2.0.
|
|
247
|
+
version: 2.0.32
|
|
248
248
|
- !ruby/object:Gem::Dependency
|
|
249
249
|
name: turbo_tests2
|
|
250
250
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -352,14 +352,13 @@ files:
|
|
|
352
352
|
- sig/typescript/merge.rbs
|
|
353
353
|
homepage: "https://github.com/structuredmerge/structuredmerge-ruby"
|
|
354
354
|
licenses:
|
|
355
|
-
-
|
|
356
|
-
- PolyForm-Small-Business-1.0.0
|
|
355
|
+
- MIT
|
|
357
356
|
metadata:
|
|
358
357
|
homepage_uri: "https://structuredmerge.org"
|
|
359
|
-
source_code_uri: "https://github.com/structuredmerge/structuredmerge-ruby/tree/
|
|
360
|
-
changelog_uri: "https://github.com/structuredmerge/structuredmerge-ruby/blob/
|
|
358
|
+
source_code_uri: "https://github.com/structuredmerge/structuredmerge-ruby/tree/v8.0.0"
|
|
359
|
+
changelog_uri: "https://github.com/structuredmerge/structuredmerge-ruby/blob/v8.0.0/CHANGELOG.md"
|
|
361
360
|
bug_tracker_uri: "https://github.com/structuredmerge/structuredmerge-ruby/issues"
|
|
362
|
-
documentation_uri: "https://www.rubydoc.info/gems/typescript-merge/
|
|
361
|
+
documentation_uri: "https://www.rubydoc.info/gems/typescript-merge/8.0.0"
|
|
363
362
|
funding_uri: "https://github.com/sponsors/pboling"
|
|
364
363
|
wiki_uri: "https://github.com/structuredmerge/structuredmerge-ruby/wiki"
|
|
365
364
|
news_uri: "https://www.railsbling.com/tags/typescript-merge"
|
metadata.gz.sig
CHANGED
|
Binary file
|