@openrewrite/rewrite 0.18.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.
Files changed (172) hide show
  1. package/CONTRIBUTING.md +22 -0
  2. package/LICENSE +201 -0
  3. package/README.md +13 -0
  4. package/dist/src/core/execution.d.ts +35 -0
  5. package/dist/src/core/execution.d.ts.map +1 -0
  6. package/dist/src/core/execution.js +65 -0
  7. package/dist/src/core/execution.js.map +1 -0
  8. package/dist/src/core/index.d.ts +6 -0
  9. package/dist/src/core/index.d.ts.map +1 -0
  10. package/dist/src/core/index.js +22 -0
  11. package/dist/src/core/index.js.map +1 -0
  12. package/dist/src/core/markers.d.ts +56 -0
  13. package/dist/src/core/markers.d.ts.map +1 -0
  14. package/dist/src/core/markers.js +140 -0
  15. package/dist/src/core/markers.js.map +1 -0
  16. package/dist/src/core/parser.d.ts +34 -0
  17. package/dist/src/core/parser.d.ts.map +1 -0
  18. package/dist/src/core/parser.js +106 -0
  19. package/dist/src/core/parser.js.map +1 -0
  20. package/dist/src/core/tree.d.ts +195 -0
  21. package/dist/src/core/tree.d.ts.map +1 -0
  22. package/dist/src/core/tree.js +455 -0
  23. package/dist/src/core/tree.js.map +1 -0
  24. package/dist/src/core/utils.d.ts +12 -0
  25. package/dist/src/core/utils.d.ts.map +1 -0
  26. package/dist/src/core/utils.js +69 -0
  27. package/dist/src/core/utils.js.map +1 -0
  28. package/dist/src/index.d.ts +2 -0
  29. package/dist/src/index.d.ts.map +1 -0
  30. package/dist/src/index.js +3 -0
  31. package/dist/src/index.js.map +1 -0
  32. package/dist/src/java/extensions.d.ts +7 -0
  33. package/dist/src/java/extensions.d.ts.map +1 -0
  34. package/dist/src/java/extensions.js +53 -0
  35. package/dist/src/java/extensions.js.map +1 -0
  36. package/dist/src/java/index.d.ts +4 -0
  37. package/dist/src/java/index.d.ts.map +1 -0
  38. package/dist/src/java/index.js +20 -0
  39. package/dist/src/java/index.js.map +1 -0
  40. package/dist/src/java/markers.d.ts +20 -0
  41. package/dist/src/java/markers.d.ts.map +1 -0
  42. package/dist/src/java/markers.js +54 -0
  43. package/dist/src/java/markers.js.map +1 -0
  44. package/dist/src/java/tree/extensions.d.ts +6 -0
  45. package/dist/src/java/tree/extensions.d.ts.map +1 -0
  46. package/dist/src/java/tree/extensions.js +36 -0
  47. package/dist/src/java/tree/extensions.js.map +1 -0
  48. package/dist/src/java/tree/index.d.ts +4 -0
  49. package/dist/src/java/tree/index.d.ts.map +1 -0
  50. package/dist/src/java/tree/index.js +20 -0
  51. package/dist/src/java/tree/index.js.map +1 -0
  52. package/dist/src/java/tree/support_types.d.ts +396 -0
  53. package/dist/src/java/tree/support_types.d.ts.map +1 -0
  54. package/dist/src/java/tree/support_types.js +450 -0
  55. package/dist/src/java/tree/support_types.js.map +1 -0
  56. package/dist/src/java/tree/tree.d.ts +3377 -0
  57. package/dist/src/java/tree/tree.d.ts.map +1 -0
  58. package/dist/src/java/tree/tree.js +4613 -0
  59. package/dist/src/java/tree/tree.js.map +1 -0
  60. package/dist/src/java/tree/types.d.ts +80 -0
  61. package/dist/src/java/tree/types.d.ts.map +1 -0
  62. package/dist/src/java/tree/types.js +138 -0
  63. package/dist/src/java/tree/types.js.map +1 -0
  64. package/dist/src/java/visitor.d.ts +82 -0
  65. package/dist/src/java/visitor.d.ts.map +1 -0
  66. package/dist/src/java/visitor.js +872 -0
  67. package/dist/src/java/visitor.js.map +1 -0
  68. package/dist/src/javascript/extensions.d.ts +12 -0
  69. package/dist/src/javascript/extensions.d.ts.map +1 -0
  70. package/dist/src/javascript/extensions.js +60 -0
  71. package/dist/src/javascript/extensions.js.map +1 -0
  72. package/dist/src/javascript/index.d.ts +6 -0
  73. package/dist/src/javascript/index.d.ts.map +1 -0
  74. package/dist/src/javascript/index.js +22 -0
  75. package/dist/src/javascript/index.js.map +1 -0
  76. package/dist/src/javascript/markers.d.ts +2 -0
  77. package/dist/src/javascript/markers.d.ts.map +1 -0
  78. package/dist/src/javascript/markers.js +3 -0
  79. package/dist/src/javascript/markers.js.map +1 -0
  80. package/dist/src/javascript/parser.d.ts +268 -0
  81. package/dist/src/javascript/parser.d.ts.map +1 -0
  82. package/dist/src/javascript/parser.js +1137 -0
  83. package/dist/src/javascript/parser.js.map +1 -0
  84. package/dist/src/javascript/parserUtils.d.ts +7 -0
  85. package/dist/src/javascript/parserUtils.d.ts.map +1 -0
  86. package/dist/src/javascript/parserUtils.js +165 -0
  87. package/dist/src/javascript/parserUtils.js.map +1 -0
  88. package/dist/src/javascript/projectParser.d.ts +25 -0
  89. package/dist/src/javascript/projectParser.d.ts.map +1 -0
  90. package/dist/src/javascript/projectParser.js +149 -0
  91. package/dist/src/javascript/projectParser.js.map +1 -0
  92. package/dist/src/javascript/projectParserMain.d.ts +3 -0
  93. package/dist/src/javascript/projectParserMain.d.ts.map +1 -0
  94. package/dist/src/javascript/projectParserMain.js +59 -0
  95. package/dist/src/javascript/projectParserMain.js.map +1 -0
  96. package/dist/src/javascript/tree/extensions.d.ts +4 -0
  97. package/dist/src/javascript/tree/extensions.d.ts.map +1 -0
  98. package/dist/src/javascript/tree/extensions.js +80 -0
  99. package/dist/src/javascript/tree/extensions.js.map +1 -0
  100. package/dist/src/javascript/tree/index.d.ts +3 -0
  101. package/dist/src/javascript/tree/index.d.ts.map +1 -0
  102. package/dist/src/javascript/tree/index.js +19 -0
  103. package/dist/src/javascript/tree/index.js.map +1 -0
  104. package/dist/src/javascript/tree/support_types.d.ts +184 -0
  105. package/dist/src/javascript/tree/support_types.d.ts.map +1 -0
  106. package/dist/src/javascript/tree/support_types.js +224 -0
  107. package/dist/src/javascript/tree/support_types.js.map +1 -0
  108. package/dist/src/javascript/tree/tree.d.ts +1173 -0
  109. package/dist/src/javascript/tree/tree.d.ts.map +1 -0
  110. package/dist/src/javascript/tree/tree.js +1590 -0
  111. package/dist/src/javascript/tree/tree.js.map +1 -0
  112. package/dist/src/javascript/typeMapping.d.ts +16 -0
  113. package/dist/src/javascript/typeMapping.d.ts.map +1 -0
  114. package/dist/src/javascript/typeMapping.js +120 -0
  115. package/dist/src/javascript/typeMapping.js.map +1 -0
  116. package/dist/src/javascript/visitor.d.ts +41 -0
  117. package/dist/src/javascript/visitor.d.ts.map +1 -0
  118. package/dist/src/javascript/visitor.js +360 -0
  119. package/dist/src/javascript/visitor.js.map +1 -0
  120. package/dist/src/json/extensions.d.ts +6 -0
  121. package/dist/src/json/extensions.d.ts.map +1 -0
  122. package/dist/src/json/extensions.js +11 -0
  123. package/dist/src/json/extensions.js.map +1 -0
  124. package/dist/src/json/index.d.ts +5 -0
  125. package/dist/src/json/index.d.ts.map +1 -0
  126. package/dist/src/json/index.js +21 -0
  127. package/dist/src/json/index.js.map +1 -0
  128. package/dist/src/json/markers.d.ts +2 -0
  129. package/dist/src/json/markers.d.ts.map +1 -0
  130. package/dist/src/json/markers.js +3 -0
  131. package/dist/src/json/markers.js.map +1 -0
  132. package/dist/src/json/support_types.d.ts +19 -0
  133. package/dist/src/json/support_types.d.ts.map +1 -0
  134. package/dist/src/json/support_types.js +47 -0
  135. package/dist/src/json/support_types.js.map +1 -0
  136. package/dist/src/json/tree.d.ts +187 -0
  137. package/dist/src/json/tree.d.ts.map +1 -0
  138. package/dist/src/json/tree.js +393 -0
  139. package/dist/src/json/tree.js.map +1 -0
  140. package/dist/src/json/visitor.d.ts +16 -0
  141. package/dist/src/json/visitor.d.ts.map +1 -0
  142. package/dist/src/json/visitor.js +83 -0
  143. package/dist/src/json/visitor.js.map +1 -0
  144. package/dist/src/yaml/index.d.ts +4 -0
  145. package/dist/src/yaml/index.d.ts.map +1 -0
  146. package/dist/src/yaml/index.js +20 -0
  147. package/dist/src/yaml/index.js.map +1 -0
  148. package/dist/src/yaml/markers.d.ts +2 -0
  149. package/dist/src/yaml/markers.d.ts.map +1 -0
  150. package/dist/src/yaml/markers.js +3 -0
  151. package/dist/src/yaml/markers.js.map +1 -0
  152. package/dist/src/yaml/tree/extensions.d.ts +2 -0
  153. package/dist/src/yaml/tree/extensions.d.ts.map +1 -0
  154. package/dist/src/yaml/tree/extensions.js +3 -0
  155. package/dist/src/yaml/tree/extensions.js.map +1 -0
  156. package/dist/src/yaml/tree/index.d.ts +3 -0
  157. package/dist/src/yaml/tree/index.d.ts.map +1 -0
  158. package/dist/src/yaml/tree/index.js +19 -0
  159. package/dist/src/yaml/tree/index.js.map +1 -0
  160. package/dist/src/yaml/tree/support_types.d.ts +37 -0
  161. package/dist/src/yaml/tree/support_types.d.ts.map +1 -0
  162. package/dist/src/yaml/tree/support_types.js +25 -0
  163. package/dist/src/yaml/tree/support_types.js.map +1 -0
  164. package/dist/src/yaml/tree/tree.d.ts +451 -0
  165. package/dist/src/yaml/tree/tree.d.ts.map +1 -0
  166. package/dist/src/yaml/tree/tree.js +551 -0
  167. package/dist/src/yaml/tree/tree.js.map +1 -0
  168. package/dist/src/yaml/visitor.d.ts +16 -0
  169. package/dist/src/yaml/visitor.d.ts.map +1 -0
  170. package/dist/src/yaml/visitor.js +64 -0
  171. package/dist/src/yaml/visitor.js.map +1 -0
  172. package/package.json +40 -0
@@ -0,0 +1,22 @@
1
+ ### Development Setup
2
+
3
+ For the time being the setup is unfortunately a bit complicated due to the dependencies between `rewrite-javascript` and `rewrite-remote`.
4
+ To be able to make changes to both these projects and make sure that they work together, we use `npm link`.
5
+
6
+ 1. Start by cloning both `openrewrite/rewrite-javascript` (this repo) and `moderneinc/rewrite-remote`
7
+ 2. For both repos perform the following steps:
8
+ 1. Run the build using `npm run build`
9
+ 2. Run `npm link`. This last step only needs to be done once
10
+ 3. Now `npm link` needs to be run in either project to link it into `node_modules`:
11
+ 1. For `openrewrite/rewrite-javascript` run `npm link @openrewrite/rewrite-remote`
12
+ 2. For `moderneinc/rewrite-remote` run `npm link @openrewrite/rewrite`
13
+ 4. Now you are basically all set. As the tests read the production source files from `dist` instead of `src` it is recommended to have `tsc --watch` running which you can do using `npm run dev`
14
+
15
+ For development it is recommended to open the `openrewrite` subdirectory as a project in WebStorm.
16
+
17
+ ### Running Tests
18
+
19
+ The parser tests typically use LST remoting to print the LST back to text in order to verify the print idempotence.
20
+ In order to get this working the Java remoting server must already be running.
21
+ Start the Java remoting server directly from IntelliJ IDEA (`rewrite-javascript` repo) by running the shared `RemotingServer` configuration.
22
+ Now it should be possible to run the Jest tests from the terminal or from the WebStorm IDE.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ <p align="center" style="margin-top: 3rem;"><img src="https://github.com/openrewrite/rewrite/raw/main/doc/logo-oss.png" width="300px" alt="OpenRewrite Logo"></p>
2
+
3
+ Greetings!
4
+
5
+ The OpenRewrite project is a mass refactoring ecosystem designed to eliminate technical debt across an engineering organization. Full documentation and information is available at [OpenRewrite](https://docs.openrewrite.org/).
6
+
7
+ This project contains the LST models as well as the runtime required to execute OpenRewrite recipes.
8
+
9
+ ### How to install
10
+
11
+ ```
12
+ npm i -D @openrewrite/rewrite
13
+ ```
@@ -0,0 +1,35 @@
1
+ import { PathLike } from 'fs';
2
+ import { Cursor, TreeVisitor } from "./tree";
3
+ export declare class Result {
4
+ static diff(before: string, after: string, path: PathLike): string;
5
+ }
6
+ export interface ExecutionContext {
7
+ getMessage<T>(key: string, defaultValue?: T | null): T;
8
+ putMessage(key: string, value: any): void;
9
+ }
10
+ export declare namespace ExecutionContext {
11
+ const REQUIRE_PRINT_EQUALS_INPUT: string;
12
+ const CHARSET: string;
13
+ }
14
+ export declare class InMemoryExecutionContext implements ExecutionContext {
15
+ private readonly _messages;
16
+ getMessage<T>(key: string, defaultValue?: T | null): T;
17
+ putMessage(key: string, value: any): void;
18
+ }
19
+ export declare class DelegatingExecutionContext implements ExecutionContext {
20
+ private readonly _delegate;
21
+ constructor(_delegate: ExecutionContext);
22
+ getMessage<T>(key: string, defaultValue?: T | null): T;
23
+ putMessage(key: string, value: any): void;
24
+ }
25
+ export declare class Recipe {
26
+ getVisitor(): TreeVisitor<any, ExecutionContext>;
27
+ }
28
+ export declare class RecipeRunException extends Error {
29
+ private readonly _cause;
30
+ private readonly _cursor?;
31
+ constructor(cause: Error, cursor?: Cursor);
32
+ get cause(): Error;
33
+ get cursor(): Cursor | undefined;
34
+ }
35
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/core/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAE3C,qBAAa,MAAM;IACf,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM;CAiBrE;AAED,MAAM,WAAW,gBAAgB;IAC7B,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAEvD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC7C;AAED,yBAAiB,gBAAgB,CAAC;IACvB,MAAM,0BAA0B,EAAE,MAAkD,CAAC;IACrF,MAAM,OAAO,EAAE,MAAyC,CAAC;CACnE;AAGD,qBAAa,wBAAyB,YAAW,gBAAgB;IAE7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IAEzD,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC;IAItD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;CAG5C;AAED,qBAAa,0BAA2B,YAAW,gBAAgB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IAG/D,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC;IAItD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAGrC;AAED,qBAAa,MAAM;IACf,UAAU,IAAI,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC;CAGnD;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;gBAEtB,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM;IAMzC,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;CACJ"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecipeRunException = exports.Recipe = exports.DelegatingExecutionContext = exports.InMemoryExecutionContext = exports.ExecutionContext = exports.Result = void 0;
4
+ const diff_1 = require("diff");
5
+ const tree_1 = require("./tree");
6
+ class Result {
7
+ static diff(before, after, path) {
8
+ const beforeFileName = path.toString();
9
+ const afterFileName = path.toString();
10
+ const patch = (0, diff_1.createTwoFilesPatch)(beforeFileName, afterFileName, before, after, '', '', { context: 3 });
11
+ return patch;
12
+ }
13
+ }
14
+ exports.Result = Result;
15
+ var ExecutionContext;
16
+ (function (ExecutionContext) {
17
+ ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT = "org.openrewrite.requirePrintEqualsInput";
18
+ ExecutionContext.CHARSET = "org.openrewrite.parser.charset";
19
+ })(ExecutionContext || (exports.ExecutionContext = ExecutionContext = {}));
20
+ class InMemoryExecutionContext {
21
+ constructor() {
22
+ this._messages = new Map();
23
+ }
24
+ getMessage(key, defaultValue) {
25
+ var _a;
26
+ return (_a = this._messages.get(key)) !== null && _a !== void 0 ? _a : defaultValue;
27
+ }
28
+ putMessage(key, value) {
29
+ this._messages.set(key, value);
30
+ }
31
+ }
32
+ exports.InMemoryExecutionContext = InMemoryExecutionContext;
33
+ class DelegatingExecutionContext {
34
+ constructor(_delegate) {
35
+ this._delegate = _delegate;
36
+ }
37
+ getMessage(key, defaultValue) {
38
+ return this._delegate.getMessage(key, defaultValue);
39
+ }
40
+ putMessage(key, value) {
41
+ this._delegate.putMessage(key, value);
42
+ }
43
+ }
44
+ exports.DelegatingExecutionContext = DelegatingExecutionContext;
45
+ class Recipe {
46
+ getVisitor() {
47
+ return tree_1.TreeVisitor.noop();
48
+ }
49
+ }
50
+ exports.Recipe = Recipe;
51
+ class RecipeRunException extends Error {
52
+ constructor(cause, cursor) {
53
+ super();
54
+ this._cause = cause;
55
+ this._cursor = cursor;
56
+ }
57
+ get cause() {
58
+ return this._cause;
59
+ }
60
+ get cursor() {
61
+ return this._cursor;
62
+ }
63
+ }
64
+ exports.RecipeRunException = RecipeRunException;
65
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/core/execution.ts"],"names":[],"mappings":";;;AAAA,+BAAyC;AAEzC,iCAA2C;AAE3C,MAAa,MAAM;IACf,MAAM,CAAC,IAAI,CAAC,MAAc,EAAE,KAAa,EAAE,IAAc;QACrD,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAGtC,MAAM,KAAK,GAAG,IAAA,0BAAmB,EAC7B,cAAc,EACd,aAAa,EACb,MAAM,EACN,KAAK,EACL,EAAE,EACF,EAAE,EACF,EAAC,OAAO,EAAE,CAAC,EAAC,CACf,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAlBD,wBAkBC;AAQD,IAAiB,gBAAgB,CAGhC;AAHD,WAAiB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AC,OAAO,CAAC;IACxB,CAAC;CACJ;AAjBD,gDAiBC"}
@@ -0,0 +1,6 @@
1
+ export * from './execution';
2
+ export * from './markers';
3
+ export * from './parser';
4
+ export * from './tree';
5
+ export * from './utils';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./execution"), exports);
18
+ __exportStar(require("./markers"), exports);
19
+ __exportStar(require("./parser"), exports);
20
+ __exportStar(require("./tree"), exports);
21
+ __exportStar(require("./utils"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,2CAAyB;AACzB,yCAAuB;AACvB,0CAAwB"}
@@ -0,0 +1,56 @@
1
+ import { Parser } from "./parser";
2
+ import { UUID } from "./utils";
3
+ import { Tree } from "./tree";
4
+ export declare const MarkerSymbol: unique symbol;
5
+ export interface Marker {
6
+ [MarkerSymbol]: boolean;
7
+ [key: string]: any;
8
+ get id(): UUID;
9
+ withId(id: UUID): Marker;
10
+ }
11
+ export declare function isMarker(tree: any): tree is Marker;
12
+ export declare class Markers {
13
+ static readonly EMPTY: Markers;
14
+ private readonly _id;
15
+ private readonly _markers;
16
+ constructor(id: UUID, markers: Marker[]);
17
+ static build(markers: Marker[]): Markers;
18
+ get id(): UUID;
19
+ withId(id: UUID): Markers;
20
+ get markers(): Marker[];
21
+ withMarkers(markers: Marker[]): Markers;
22
+ findFirst<T extends Marker>(markerType: new (...args: any[]) => T): T | undefined;
23
+ computeByType<M extends Marker>(marker: M, remapping: (m1: M, m2: M) => M): Markers;
24
+ }
25
+ export declare class SearchResult implements Marker {
26
+ [MarkerSymbol]: boolean;
27
+ private readonly _id;
28
+ private readonly _description;
29
+ constructor(id: UUID, description?: string | null);
30
+ static found<T extends Tree>(tree: T | null): T | null;
31
+ get id(): UUID;
32
+ withId(id: UUID): SearchResult;
33
+ get description(): string | null;
34
+ withDescription(description: string): SearchResult;
35
+ }
36
+ export declare class ParseExceptionResult implements Marker {
37
+ [MarkerSymbol]: boolean;
38
+ private readonly _id;
39
+ private readonly _parserType;
40
+ private readonly _exceptionType;
41
+ private readonly _message;
42
+ private readonly _treeType;
43
+ constructor(id: UUID, parserType: string, exceptionType: string, message: string | null, treeType?: string | null);
44
+ static build(parser: Parser, exception: Error): ParseExceptionResult;
45
+ get id(): UUID;
46
+ withId(id: UUID): ParseExceptionResult;
47
+ get parserType(): string;
48
+ withParserType(parserType: string): ParseExceptionResult;
49
+ get exceptionType(): string;
50
+ withExceptionType(exceptionType: string): ParseExceptionResult;
51
+ get message(): string | null;
52
+ withMessage(message: string): ParseExceptionResult;
53
+ get treeType(): string | null;
54
+ withTreeType(treeType: string): ParseExceptionResult;
55
+ }
56
+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AAU,IAAI,MAAM,CAEvB;IAED,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAUxD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,oBAAoB;IAU9D,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IAUlD,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,YAAY,CAAC,QAAQ,EAAE,MAAM;CAShC"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var _a, _b;
9
+ var Markers_1, SearchResult_1, ParseExceptionResult_1;
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ParseExceptionResult = exports.SearchResult = exports.Markers = exports.MarkerSymbol = void 0;
12
+ exports.isMarker = isMarker;
13
+ const utils_1 = require("./utils");
14
+ exports.MarkerSymbol = Symbol('Marker');
15
+ function isMarker(tree) {
16
+ return tree && tree[exports.MarkerSymbol] === true;
17
+ }
18
+ let Markers = Markers_1 = class Markers {
19
+ constructor(id, markers) {
20
+ this._markers = [];
21
+ this._id = id;
22
+ this._markers = markers;
23
+ }
24
+ static build(markers) {
25
+ if (markers.length === 0) {
26
+ return Markers_1.EMPTY;
27
+ }
28
+ return new Markers_1((0, utils_1.randomId)(), markers);
29
+ }
30
+ get id() {
31
+ return this._id;
32
+ }
33
+ withId(id) {
34
+ return this._id === id ? this : new Markers_1(id, this._markers);
35
+ }
36
+ get markers() {
37
+ return this._markers;
38
+ }
39
+ withMarkers(markers) {
40
+ return this._markers === markers ? this : new Markers_1(this._id, markers);
41
+ }
42
+ findFirst(markerType) {
43
+ return this._markers.find((marker) => marker instanceof markerType) || undefined;
44
+ }
45
+ computeByType(marker, remapping) {
46
+ let updated = false;
47
+ let markers = utils_1.ListUtils.map(this._markers, m => {
48
+ if (m.constructor === marker.constructor) {
49
+ updated = true;
50
+ return remapping(m, marker);
51
+ }
52
+ return m;
53
+ });
54
+ return this.withMarkers(!updated ? utils_1.ListUtils.concat(markers, marker) : markers);
55
+ }
56
+ };
57
+ exports.Markers = Markers;
58
+ Markers.EMPTY = new Markers_1((0, utils_1.randomId)(), []);
59
+ exports.Markers = Markers = Markers_1 = __decorate([
60
+ (0, utils_1.LstType)("org.openrewrite.marker.Markers")
61
+ ], Markers);
62
+ let SearchResult = SearchResult_1 = class SearchResult {
63
+ constructor(id, description) {
64
+ this[_a] = true;
65
+ this._id = id;
66
+ this._description = description ? description : null;
67
+ }
68
+ static found(tree) {
69
+ if (!tree) {
70
+ return null;
71
+ }
72
+ return tree.withMarkers(tree.markers.computeByType(new SearchResult_1((0, utils_1.randomId)()), (s1, s2) => s1 == null ? s2 : s1));
73
+ }
74
+ get id() {
75
+ return this._id;
76
+ }
77
+ withId(id) {
78
+ return new SearchResult_1(id, this._description);
79
+ }
80
+ get description() {
81
+ return this._description;
82
+ }
83
+ withDescription(description) {
84
+ return new SearchResult_1(this._id, description);
85
+ }
86
+ };
87
+ exports.SearchResult = SearchResult;
88
+ _a = exports.MarkerSymbol;
89
+ exports.SearchResult = SearchResult = SearchResult_1 = __decorate([
90
+ (0, utils_1.LstType)("org.openrewrite.marker.SearchResult")
91
+ ], SearchResult);
92
+ let ParseExceptionResult = ParseExceptionResult_1 = class ParseExceptionResult {
93
+ constructor(id, parserType, exceptionType, message, treeType) {
94
+ this[_b] = true;
95
+ this._id = id;
96
+ this._parserType = parserType;
97
+ this._exceptionType = exceptionType;
98
+ this._message = message;
99
+ this._treeType = treeType !== null && treeType !== void 0 ? treeType : null;
100
+ }
101
+ static build(parser, exception) {
102
+ return new ParseExceptionResult_1((0, utils_1.randomId)(), parser.constructor.name, exception.constructor.name, exception.stack || exception.message || '');
103
+ }
104
+ get id() {
105
+ return this._id;
106
+ }
107
+ withId(id) {
108
+ return id === this._id ? this : new ParseExceptionResult_1(id, this._parserType, this._exceptionType, this._message, this._treeType);
109
+ }
110
+ get parserType() {
111
+ return this._parserType;
112
+ }
113
+ withParserType(parserType) {
114
+ return parserType === this._parserType ? this : new ParseExceptionResult_1(this._id, parserType, this._exceptionType, this._message, this._treeType);
115
+ }
116
+ get exceptionType() {
117
+ return this._exceptionType;
118
+ }
119
+ withExceptionType(exceptionType) {
120
+ return exceptionType === this._exceptionType ? this : new ParseExceptionResult_1(this._id, this._parserType, exceptionType, this._message, this._treeType);
121
+ }
122
+ get message() {
123
+ return this._message;
124
+ }
125
+ withMessage(message) {
126
+ return message === this._message ? this : new ParseExceptionResult_1(this._id, this._parserType, this._exceptionType, message, this._treeType);
127
+ }
128
+ get treeType() {
129
+ return this._treeType;
130
+ }
131
+ withTreeType(treeType) {
132
+ return treeType === this._treeType ? this : new ParseExceptionResult_1(this._id, this._parserType, this._exceptionType, this._message, treeType);
133
+ }
134
+ };
135
+ exports.ParseExceptionResult = ParseExceptionResult;
136
+ _b = exports.MarkerSymbol;
137
+ exports.ParseExceptionResult = ParseExceptionResult = ParseExceptionResult_1 = __decorate([
138
+ (0, utils_1.LstType)("org.openrewrite.ParseExceptionResult")
139
+ ], ParseExceptionResult);
140
+ //# sourceMappingURL=markers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../src/core/markers.ts"],"names":[],"mappings":";;;;;;;;;;;AAiBA,4BAGC;AAnBD,mCAA2D;AAI9C,QAAA,YAAY,GAAG,MAAM,CAAC,QAAQ,C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AAC;IACN,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,OAAO,QAAQ,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,sBAAoB,CAChE,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,QAAQ,EACb,QAAQ,CACX,CAAC;IACN,CAAC;CACJ,CAAA;AApGY,oDAAoB;KAC5B,oBAAY;+BADJ,oBAAoB;IADhC,IAAA,eAAO,EAAC,sCAAsC,CAAC;GACnC,oBAAoB,CAoGhC"}
@@ -0,0 +1,34 @@
1
+ import { FileAttributes, SourceFile } from './tree';
2
+ import { ExecutionContext } from './execution';
3
+ export declare class ParserInput {
4
+ private readonly _path;
5
+ private readonly _fileAttributes;
6
+ private readonly _synthetic;
7
+ private readonly _source;
8
+ constructor(path: string, fileAttributes: FileAttributes | null, synthetic: boolean, source: () => Buffer);
9
+ get path(): string;
10
+ get fileAttributes(): FileAttributes | null;
11
+ get synthetic(): boolean;
12
+ get source(): () => Buffer;
13
+ }
14
+ export declare abstract class Parser {
15
+ abstract parseInputs(sources: Iterable<ParserInput>, relativeTo: string | null, ctx: ExecutionContext): Iterable<SourceFile>;
16
+ abstract accept(path: string): boolean;
17
+ abstract sourcePathFromSourceText(prefix: string, sourceCode: string): string;
18
+ parse(sourceFilesPaths: Iterable<string>, relativeTo: string | null, ctx: ExecutionContext): Iterable<SourceFile>;
19
+ parseStrings(...sources: string[]): Iterable<SourceFile>;
20
+ private parseStringsWithContext;
21
+ acceptInput(parserInput: ParserInput): boolean;
22
+ acceptedInputs(inputs: Iterable<ParserInput>): Iterable<ParserInput>;
23
+ reset(): this;
24
+ getCharset(ctx: ExecutionContext): string;
25
+ }
26
+ export declare namespace Parser {
27
+ abstract class Builder {
28
+ protected _sourceFileType: any;
29
+ get sourceFileType(): any;
30
+ abstract build(): Parser;
31
+ }
32
+ }
33
+ export declare function requirePrintEqualsInput(parser: Parser, sourceFile: SourceFile, parserInput: ParserInput, relativeTo: string | null, ctx: ExecutionContext): SourceFile;
34
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAc,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAC,gBAAgB,EAAmC,MAAM,aAAa,CAAC;AAE/E,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAGnC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,GAAG,IAAI,EACrC,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,MAAM,MAAM;IAQxB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,cAAc,IAAI,cAAc,GAAG,IAAI,CAE1C;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,MAAM,IAAI,MAAM,MAAM,CAEzB;CACJ;AAED,8BAAsB,MAAM;IACxB,QAAQ,CAAC,WAAW,CAChB,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,GAAG,EAAE,gBAAgB,GACtB,QAAQ,CAAC,UAAU,CAAC;IAEvB,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAEtC,QAAQ,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAE7E,KAAK,CACD,gBAAgB,EAAE,Q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