@descryy/adapter-java 0.2.0 → 0.3.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.
- package/LICENSE +8 -0
- package/dist/adapter.d.ts +5 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +80 -95
- package/dist/adapter.js.map +1 -1
- package/dist/client.d.ts +65 -119
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +121 -222
- package/dist/client.js.map +1 -1
- package/dist/extract.d.ts +13 -22
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +189 -288
- package/dist/extract.js.map +1 -1
- package/dist/jpa.d.ts +32 -73
- package/dist/jpa.d.ts.map +1 -1
- package/dist/jpa.js +72 -166
- package/dist/jpa.js.map +1 -1
- package/dist/parse.d.ts +83 -152
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +101 -183
- package/dist/parse.js.map +1 -1
- package/dist/spring.d.ts +24 -58
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +80 -209
- package/dist/spring.js.map +1 -1
- package/package.json +15 -6
package/dist/jpa.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jpa.js","sourceRoot":"","sources":["../src/jpa.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jpa.js","sourceRoot":"","sources":["../src/jpa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAmCH,MAAM,YAAY,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,cAAc,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAE5D;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,IAAc;IACjD,MAAM,QAAQ,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,cAAc,CAAC,CAAC;IACtD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,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I,CAAC,UAAU;YAC1B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;YACpB,MAAM;YACN,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One Java compilation unit, read into the shape the resolver wants.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and
|
|
8
|
-
* extractors are both shaped this way for the same reason.
|
|
4
|
+
* Hand-written rather than tree-sitter queries: a query returns matches, but
|
|
5
|
+
* this needs *containment* (which class a method belongs to, which method a
|
|
6
|
+
* call sits in) — exactly what a match set discards. Same reason the
|
|
7
|
+
* TypeScript and Python extractors are shaped this way.
|
|
9
8
|
*/
|
|
10
9
|
import type { Node } from "@descryy/adapter-treesitter";
|
|
11
10
|
export type TypeKind = "class" | "interface" | "enum" | "record" | "annotation";
|
|
12
11
|
export interface JavaRef {
|
|
13
12
|
/**
|
|
14
|
-
* `call` — a method invocation.
|
|
15
|
-
*
|
|
16
|
-
* `member` — a name reached through a dotted access, `Status.PENDING`.
|
|
13
|
+
* `call` — a method invocation. `type` — a name in type position (field
|
|
14
|
+
* type, parameter, `new`). `member` — a dotted access, `Status.PENDING`.
|
|
17
15
|
*
|
|
18
|
-
* `member` is a *candidate*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* question; the resolver answers it against the declarations it has, and drops
|
|
16
|
+
* `member` is a *candidate* only: `x.y` is a type reference when `x` names
|
|
17
|
+
* a type, a field read when it names a variable, and that's not knowable
|
|
18
|
+
* until the enclosing scope is built. The resolver answers it and drops
|
|
22
19
|
* the reference when the receiver turns out to be a variable.
|
|
23
20
|
*/
|
|
24
21
|
readonly kind: "call" | "type" | "member";
|
|
@@ -34,48 +31,32 @@ export interface JavaRef {
|
|
|
34
31
|
readonly raw: string;
|
|
35
32
|
/**
|
|
36
33
|
* For a call, the first argument **when it is a bare string literal**.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Only the first argument, because every client method this feeds takes the
|
|
46
|
-
* URL first: `getForEntity(url, type)`, `exchange(url, method, …)`,
|
|
47
|
-
* `uri(path)`. A reader that searched all arguments for something
|
|
48
|
-
* path-shaped would find request bodies.
|
|
49
|
-
*
|
|
50
|
-
* Optional rather than `string | undefined`, because a `type` or `member` ref
|
|
51
|
-
* has no arguments at all and writing `firstStringArgument: undefined` on
|
|
52
|
-
* every one of them would assert a question was asked and came back empty.
|
|
34
|
+
* `undefined` covers three cases on purpose (no arguments, non-literal
|
|
35
|
+
* first argument, a literal glued to something else) since the client-call
|
|
36
|
+
* reader treats all three identically: decline. A path assembled at run
|
|
37
|
+
* time is not one this adapter can read (DEC-127). Only the first argument,
|
|
38
|
+
* since every client method this feeds takes the URL first
|
|
39
|
+
* (`getForEntity(url, type)`, `exchange(url, method, …)`, `uri(path)`).
|
|
40
|
+
* Optional, not `string | undefined`, since a `type`/`member` ref never
|
|
41
|
+
* had arguments to ask about at all.
|
|
53
42
|
*/
|
|
54
43
|
readonly firstStringArgument?: string;
|
|
55
44
|
/**
|
|
56
|
-
* The first argument's raw
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* never asked. Unlike `firstStringArgument`, set for every non-literal shape
|
|
62
|
-
* too — the classifier, not this parse, decides what to do with it.
|
|
45
|
+
* The first argument's raw text, captured whether or not it's a literal —
|
|
46
|
+
* DEC-242's `blockedBy`/`refusalClass` needs to see what blocked resolution
|
|
47
|
+
* (`System.getenv("BACKEND_URL")`, a bare parameter name) when
|
|
48
|
+
* {@link firstStringArgument} is absent. Set for every non-literal shape
|
|
49
|
+
* too; the classifier decides what to do with it, not this parse.
|
|
63
50
|
*/
|
|
64
51
|
readonly firstArgumentText?: string;
|
|
65
52
|
}
|
|
66
53
|
/**
|
|
67
|
-
* An annotation as written, retained rather than reduced to a boolean
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* finding.
|
|
74
|
-
*
|
|
75
|
-
* `name` is the simple name. `@GetMapping` and
|
|
76
|
-
* `@org.springframework.web.bind.annotation.GetMapping` are the same annotation
|
|
77
|
-
* written two ways, and the qualified form is kept in `qualified` so provenance
|
|
78
|
-
* can be checked against the import table without re-parsing.
|
|
54
|
+
* An annotation as written, retained rather than reduced to a boolean — a
|
|
55
|
+
* framework extractor needs the annotation's **name** to admit a route and
|
|
56
|
+
* its **arguments** to know the path. `name` is the simple name; the
|
|
57
|
+
* qualified form (`@GetMapping` vs
|
|
58
|
+
* `@org.springframework.web.bind.annotation.GetMapping`) is kept in
|
|
59
|
+
* `qualified` so provenance can be checked against imports without re-parsing.
|
|
79
60
|
*/
|
|
80
61
|
export interface JavaAnnotation {
|
|
81
62
|
/** Simple name: `GetMapping`. */
|
|
@@ -85,30 +66,20 @@ export interface JavaAnnotation {
|
|
|
85
66
|
readonly line: number;
|
|
86
67
|
/**
|
|
87
68
|
* The unnamed argument's string literals — `@GetMapping("/{id}")` gives one.
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* 39% of one corpus with nothing in the output to show for it.
|
|
95
|
-
*
|
|
96
|
-
* Quotes stripped. Empty when the annotation is a marker, or when the argument
|
|
97
|
-
* is not a literal — a constant reference or a concatenation. **A non-literal
|
|
98
|
-
* argument yields nothing rather than its source text**: a path assembled at
|
|
99
|
-
* runtime is not a path this adapter can read, and DEC-127 refuses it rather
|
|
100
|
-
* than guessing.
|
|
69
|
+
* A list, not a single value: the array form (`@GetMapping({"/a", "/b"})`)
|
|
70
|
+
* is common and every element is real — `shopizer` writes 140 of its 356
|
|
71
|
+
* mappings this way, so a single-value reader would lose 39% of one corpus.
|
|
72
|
+
* Quotes stripped; empty for a marker annotation or a non-literal argument
|
|
73
|
+
* (a constant reference, a concatenation) — DEC-127 refuses to guess a
|
|
74
|
+
* runtime-assembled path rather than reporting a fragment.
|
|
101
75
|
*/
|
|
102
76
|
readonly values: readonly string[];
|
|
103
77
|
/**
|
|
104
78
|
* Named arguments whose values are string literals — `path = "/x"`,
|
|
105
|
-
* `value = {"/a", "/b"}`. A list per key
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* access, not a literal. Verbs are read separately by the extractor, which
|
|
110
|
-
* knows the enum, because a parse that special-cased Spring's enum would be a
|
|
111
|
-
* framework leaking into the language layer.
|
|
79
|
+
* `value = {"/a", "/b"}`. A list per key; non-literal values omitted.
|
|
80
|
+
* `method = RequestMethod.GET` is deliberately *not* here — it's a field
|
|
81
|
+
* access, not a literal, and the extractor reads verbs separately so this
|
|
82
|
+
* parse doesn't leak a Spring enum into the language layer.
|
|
112
83
|
*/
|
|
113
84
|
readonly named: ReadonlyMap<string, readonly string[]>;
|
|
114
85
|
/** Every argument's raw source text, for the cases a literal reader must refuse. */
|
|
@@ -124,51 +95,37 @@ export interface JavaMethod {
|
|
|
124
95
|
/** Annotations on the declaration, in source order. See {@link JavaAnnotation}. */
|
|
125
96
|
readonly annotations: JavaAnnotation[];
|
|
126
97
|
/**
|
|
127
|
-
* The declared return type, read
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* did not carry the return type. It does now.
|
|
135
|
-
*
|
|
136
|
-
* `readTypeName` rather than a `string | undefined`: absent (a constructor),
|
|
137
|
-
* `void`, and unreadable are three different facts, and collapsing them into
|
|
138
|
-
* one sentinel is the defect this file already paid 126 wrong columns for.
|
|
98
|
+
* The declared return type, read with the same four answers a field gets.
|
|
99
|
+
* Needed because a bare `@Controller` returns *view names*, so DEC-127
|
|
100
|
+
* refuses its handlers unless `@ResponseBody` opts out or the return type
|
|
101
|
+
* is `ResponseEntity<T>` — a real route needing no such annotation.
|
|
102
|
+
* `readTypeName`, not `string | undefined`: absent (constructor), `void`,
|
|
103
|
+
* and unreadable are three different facts (see {@link TypeRead}, 126
|
|
104
|
+
* wrong columns paid for collapsing them once).
|
|
139
105
|
*/
|
|
140
106
|
readonly returnType: TypeRead;
|
|
141
107
|
readonly refs: JavaRef[];
|
|
142
108
|
/**
|
|
143
|
-
* Local variables and parameters, name -> declared type simple name.
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* `var`. A name whose type is uncertain resolves to nothing at all rather than
|
|
147
|
-
* to the first guess — the whole receiver-typing gain below rests on the
|
|
148
|
-
* declared type being *the* type, so an ambiguous entry must poison itself.
|
|
109
|
+
* Local variables and parameters, name -> declared type simple name. `null`
|
|
110
|
+
* marks a name declared twice with different types, or with `var` — an
|
|
111
|
+
* ambiguous entry must poison itself rather than resolve to a first guess.
|
|
149
112
|
*/
|
|
150
113
|
readonly locals: Map<string, string | null>;
|
|
151
114
|
/**
|
|
152
|
-
* Names
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* state; a local variable might still be assigned from a constant.
|
|
115
|
+
* Names in the method's own parameter list — a subset of {@link locals},
|
|
116
|
+
* kept separately since DEC-242's `varies-per-call` needs *parameter*, not
|
|
117
|
+
* *local*: a bare parameter name is caller-supplied with no fixed value; a
|
|
118
|
+
* local might still be assigned from a constant.
|
|
157
119
|
*/
|
|
158
120
|
readonly parameterNames: Set<string>;
|
|
159
121
|
}
|
|
160
122
|
/**
|
|
161
|
-
* A field declaration, kept alongside the `fields` name→type map.
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* The last one is load-bearing and is DEC-127 §3's named hazard. `long` cannot
|
|
168
|
-
* hold null and `Long` can, so `long totalAmount` is a NOT NULL column with no
|
|
169
|
-
* annotation anywhere to say so. An extractor reading the type as text without
|
|
170
|
-
* knowing the distinction gets golden 06 wrong in the direction that matters —
|
|
171
|
-
* and golden 06 fails an adapter that reports the fields and loses `nullable`.
|
|
123
|
+
* A field declaration, kept alongside the `fields` name→type map. The map
|
|
124
|
+
* answers "what type is this name" for receiver typing; JPA also needs
|
|
125
|
+
* **annotations**, **line**, and whether the type is a **primitive** — the
|
|
126
|
+
* last is DEC-127 §3's named hazard: `long` can't hold null, `Long` can, so
|
|
127
|
+
* `long totalAmount` is a NOT NULL column with no annotation to say so
|
|
128
|
+
* (golden 06 fails an adapter that loses this distinction).
|
|
172
129
|
*/
|
|
173
130
|
export interface JavaField {
|
|
174
131
|
readonly name: string;
|
|
@@ -180,12 +137,9 @@ export interface JavaField {
|
|
|
180
137
|
readonly annotations: JavaAnnotation[];
|
|
181
138
|
/**
|
|
182
139
|
* Keyword modifiers as written: `private`, `static`, `final`, `transient`.
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* `transient` field — `private static final long serialVersionUID = 1L;` is
|
|
187
|
-
* on almost every entity in a real codebase and is not a column. Emitting it
|
|
188
|
-
* is a wrong answer with a plausible name, not a silence.
|
|
140
|
+
* A field's modifiers decide whether it's persistent at all, which
|
|
141
|
+
* annotations alone can't show — JPA persists no `static`/`transient`
|
|
142
|
+
* field, and `serialVersionUID` on almost every entity is not a column.
|
|
189
143
|
*/
|
|
190
144
|
readonly modifiers: readonly string[];
|
|
191
145
|
}
|
|
@@ -213,21 +167,16 @@ export interface JavaUnit {
|
|
|
213
167
|
readonly packageName: string;
|
|
214
168
|
/**
|
|
215
169
|
* The identity scope this unit's symbols hash under: `module/sourceSet/pkg`.
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* repository on disk. See `roots.ts` for why a Java package alone is not
|
|
219
|
-
* enough to identify a Java type.
|
|
170
|
+
* Set by the adapter, not the parse, since deriving it needs the repo on
|
|
171
|
+
* disk — see `roots.ts` for why a package alone isn't enough identity.
|
|
220
172
|
*/
|
|
221
173
|
readonly identityPackage: string;
|
|
222
174
|
/** Simple name -> fully-qualified name, from `import a.b.C;`. */
|
|
223
175
|
readonly singleTypeImports: Map<string, string>;
|
|
224
176
|
/**
|
|
225
|
-
* Member name -> declaring type, from `import static a.b.C.method
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* name in one file bound to a definition declared in another, with no new
|
|
229
|
-
* symbol created in between. It is also how every JUnit assertion is written,
|
|
230
|
-
* so without it a test file's calls are almost entirely unresolvable.
|
|
177
|
+
* Member name -> declaring type, from `import static a.b.C.method;` — how
|
|
178
|
+
* every JUnit assertion is written, so without it a test file's calls are
|
|
179
|
+
* almost entirely unresolvable.
|
|
231
180
|
*/
|
|
232
181
|
readonly staticMemberImports: Map<string, string>;
|
|
233
182
|
/** Package names from `import a.b.*;`. */
|
|
@@ -242,31 +191,19 @@ export interface JavaUnit {
|
|
|
242
191
|
readonly hasError: boolean;
|
|
243
192
|
}
|
|
244
193
|
/**
|
|
245
|
-
* What reading a type node produced — four answers, because there are four
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* "not a primitive". Both readings of the sentinel were defensible and only one
|
|
252
|
-
* was right, which is the signature of a sentinel doing too much work.
|
|
253
|
-
*
|
|
254
|
-
* `bench/lib/README.md` names the rule and the repair: *every negative branch
|
|
255
|
-
* owes two different answers to two different questions — I looked and there is
|
|
256
|
-
* nothing, versus I did not look here. Give them different return values at
|
|
257
|
-
* construction time.* A guard at the one call site that got burned would have
|
|
258
|
-
* closed that call site and left the next reader to make the same inference from
|
|
259
|
-
* the same sentinel, with nothing failing.
|
|
194
|
+
* What reading a type node produced — four answers, because there are four
|
|
195
|
+
* facts. This used to be `string | undefined`, and `undefined` stood for
|
|
196
|
+
* three different things at once — costing 126 of `shopizer`'s 700 columns
|
|
197
|
+
* silently (`jpa.ts` read "not a primitive" from a sentinel that actually
|
|
198
|
+
* meant "not resolved"). `bench/lib/README.md`'s rule: every negative branch
|
|
199
|
+
* owes different return values to different questions.
|
|
260
200
|
*
|
|
261
|
-
* - `named` —
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* at, and nothing missing.
|
|
268
|
-
* - `unreadable` — a type node this reader could not name. A real gap, and the
|
|
269
|
-
* only one of the four that should ever grow.
|
|
201
|
+
* - `named` — has a declaration; the only kind an edge may point at.
|
|
202
|
+
* - `primitive` — one of the eight, or `void`. No declaration by design; not
|
|
203
|
+
* a gap. A primitive column can never be null regardless of annotations.
|
|
204
|
+
* - `absent` — no type node (a constructor's return type). Nothing missing.
|
|
205
|
+
* - `unreadable` — a type node this reader couldn't name. A real gap, and
|
|
206
|
+
* the only one of the four that should ever grow.
|
|
270
207
|
*/
|
|
271
208
|
export type TypeRead = {
|
|
272
209
|
readonly kind: "named";
|
|
@@ -280,17 +217,11 @@ export type TypeRead = {
|
|
|
280
217
|
readonly kind: "unreadable";
|
|
281
218
|
};
|
|
282
219
|
/**
|
|
283
|
-
* Read a type node, stripped of everything that is not identity
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* field of type `Map<String, Owner>` can record a dependency on `Owner` without
|
|
289
|
-
* `Map` and `Owner` being confused for one another.
|
|
290
|
-
*
|
|
291
|
-
* A caller wanting a name for an edge asks for `kind === "named"` and gets the
|
|
292
|
-
* same behaviour it always had. A caller wanting to know *why* there is no name
|
|
293
|
-
* can now find out. See {@link TypeRead}.
|
|
220
|
+
* Read a type node, stripped of everything that is not identity: `List<String>`
|
|
221
|
+
* is a use of `List`, `a.b.C` is a use of `C`. Generic arguments are
|
|
222
|
+
* deliberately not followed here — the caller walks them separately, so
|
|
223
|
+
* `Map<String, Owner>` records a dependency on `Owner` without confusing it
|
|
224
|
+
* with `Map`. See {@link TypeRead}.
|
|
294
225
|
*/
|
|
295
226
|
export declare function readTypeName(node: Node | null): TypeRead;
|
|
296
227
|
export declare function readUnit(root: Node, file: string, hasError: boolean): JavaUnit;
|
package/dist/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAExD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEhF,MAAM,WAAW,OAAO;IACtB;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC1C,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,Q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