@speclynx/apidom-datamodel 1.12.2 → 2.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.
- package/CHANGELOG.md +20 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -2
- package/README.md +151 -19
- package/dist/apidom-datamodel.browser.js +1141 -167
- package/dist/apidom-datamodel.browser.min.js +1 -1
- package/package.json +6 -3
- package/src/KeyValuePair.cjs +0 -7
- package/src/KeyValuePair.mjs +0 -7
- package/src/Namespace.cjs +1 -1
- package/src/Namespace.mjs +1 -1
- package/src/ObjectSlice.cjs +0 -7
- package/src/ObjectSlice.mjs +0 -7
- package/src/clone/errors/CloneError.cjs +22 -0
- package/src/clone/errors/CloneError.mjs +19 -0
- package/src/clone/errors/DeepCloneError.cjs +11 -0
- package/src/clone/errors/DeepCloneError.mjs +6 -0
- package/src/clone/errors/ShallowCloneError.cjs +11 -0
- package/src/clone/errors/ShallowCloneError.mjs +6 -0
- package/src/clone/index.cjs +184 -0
- package/src/clone/index.mjs +174 -0
- package/src/elements/Annotation.cjs +35 -0
- package/src/elements/Annotation.mjs +30 -0
- package/src/elements/Comment.cjs +18 -0
- package/src/elements/Comment.mjs +13 -0
- package/src/elements/LinkElement.cjs +8 -2
- package/src/elements/LinkElement.mjs +8 -2
- package/src/elements/ParseResult.cjs +91 -0
- package/src/elements/ParseResult.mjs +86 -0
- package/src/elements/RefElement.cjs +4 -1
- package/src/elements/RefElement.mjs +4 -1
- package/src/elements/SourceMap.cjs +140 -0
- package/src/elements/SourceMap.mjs +134 -0
- package/src/index.cjs +31 -2
- package/src/index.mjs +7 -3
- package/src/predicates/elements.cjs +46 -0
- package/src/predicates/elements.mjs +35 -0
- package/src/predicates/index.cjs +68 -0
- package/src/predicates/index.mjs +48 -0
- package/src/predicates/primitives.cjs +69 -0
- package/src/predicates/primitives.mjs +56 -0
- package/src/primitives/ArrayElement.cjs +0 -21
- package/src/primitives/ArrayElement.mjs +0 -21
- package/src/primitives/CollectionElement.cjs +5 -19
- package/src/primitives/CollectionElement.mjs +5 -19
- package/src/primitives/Element.cjs +110 -60
- package/src/primitives/Element.mjs +110 -60
- package/src/primitives/MemberElement.cjs +6 -2
- package/src/primitives/MemberElement.mjs +6 -2
- package/src/primitives/ObjectElement.cjs +0 -2
- package/src/primitives/ObjectElement.mjs +0 -2
- package/src/registration.cjs +8 -0
- package/src/registration.mjs +5 -1
- package/src/serialisers/JSONSerialiser.cjs +35 -4
- package/src/serialisers/JSONSerialiser.mjs +34 -8
- package/types/apidom-datamodel.d.ts +347 -51
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import type { ApiDOMErrorOptions } from '@speclynx/apidom-error';
|
|
2
|
+
import { ApiDOMStructuredError } from '@speclynx/apidom-error';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AnnotationElement represents a parsing annotation (warning or error).
|
|
6
|
+
*
|
|
7
|
+
* The annotation's class indicates its severity:
|
|
8
|
+
* - 'warning' - A non-fatal issue
|
|
9
|
+
* - 'error' - A fatal issue
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare class AnnotationElement extends StringElement {
|
|
14
|
+
constructor(content?: string, meta?: Meta, attributes?: Attributes);
|
|
15
|
+
/**
|
|
16
|
+
* The annotation code identifying the type of annotation.
|
|
17
|
+
*/
|
|
18
|
+
get code(): Element_2 | undefined;
|
|
19
|
+
set code(value: unknown);
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
/**
|
|
2
23
|
* ArrayElement represents an array/collection of elements in ApiDOM.
|
|
3
24
|
*
|
|
@@ -5,8 +26,6 @@
|
|
|
5
26
|
* @public
|
|
6
27
|
*/
|
|
7
28
|
export declare class ArrayElement<T extends Element_2 = Element_2> extends CollectionElement<T> {
|
|
8
|
-
static empty<T extends Element_2 = Element_2>(): ArrayElement<T>;
|
|
9
|
-
static 'fantasy-land/empty'<T extends Element_2 = Element_2>(): ArrayElement<T>;
|
|
10
29
|
constructor(content?: unknown[], meta?: Meta, attributes?: Attributes);
|
|
11
30
|
primitive(): string;
|
|
12
31
|
/**
|
|
@@ -58,11 +77,7 @@ export declare class ArrayElement<T extends Element_2 = Element_2> extends Colle
|
|
|
58
77
|
/**
|
|
59
78
|
* Returns an empty array element.
|
|
60
79
|
*/
|
|
61
|
-
empty():
|
|
62
|
-
'fantasy-land/map'(transform: (element: T) => T): ArrayElement<T>;
|
|
63
|
-
'fantasy-land/chain'(transform: (element: T) => ArrayElement<T>): ArrayElement<T>;
|
|
64
|
-
'fantasy-land/filter'(callback: (element: T) => boolean): ArrayElement<T>;
|
|
65
|
-
'fantasy-land/reduce'<U>(transform: (acc: U, element: T) => U, initialValue: U): U;
|
|
80
|
+
empty(): this;
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
/**
|
|
@@ -83,13 +98,41 @@ export declare class BooleanElement extends Element_2 {
|
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
/**
|
|
86
|
-
*
|
|
101
|
+
* Creates a deep clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
|
|
102
|
+
* Handles cycles by memoizing visited objects.
|
|
87
103
|
* @public
|
|
88
104
|
*/
|
|
89
|
-
export declare
|
|
90
|
-
|
|
105
|
+
export declare const cloneDeep: {
|
|
106
|
+
<T extends Element_2 | FinalCloneTypes>(value: T, options?: DeepCloneOptions): T;
|
|
107
|
+
safe<T>(value: T): T;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare class CloneError extends ApiDOMStructuredError {
|
|
114
|
+
readonly value: unknown;
|
|
115
|
+
constructor(message?: string, structuredOptions?: CloneErrorOptions);
|
|
91
116
|
}
|
|
92
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export declare interface CloneErrorOptions extends ApiDOMErrorOptions {
|
|
122
|
+
readonly value: unknown;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Creates a shallow clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
|
|
127
|
+
* The element itself is cloned, but content references are shared (except for
|
|
128
|
+
* meta and attributes which are deep cloned to preserve semantic information).
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export declare const cloneShallow: {
|
|
132
|
+
<T extends Element_2 | FinalCloneTypes>(value: T): T;
|
|
133
|
+
safe<T>(value: T): T;
|
|
134
|
+
};
|
|
135
|
+
|
|
93
136
|
/**
|
|
94
137
|
* CollectionElement is an abstract base class for collection-like elements.
|
|
95
138
|
* Both ArrayElement and ObjectElement extend this class.
|
|
@@ -128,13 +171,9 @@ export declare abstract class CollectionElement<T extends Element_2 = Element_2>
|
|
|
128
171
|
*/
|
|
129
172
|
get last(): T | undefined;
|
|
130
173
|
/**
|
|
131
|
-
* Adds the given
|
|
174
|
+
* Adds the given elements to the end of the collection.
|
|
132
175
|
*/
|
|
133
|
-
push(
|
|
134
|
-
/**
|
|
135
|
-
* Alias for push.
|
|
136
|
-
*/
|
|
137
|
-
add(value: unknown): void;
|
|
176
|
+
push(...values: unknown[]): this;
|
|
138
177
|
/**
|
|
139
178
|
* Removes the first element from the collection.
|
|
140
179
|
*/
|
|
@@ -170,16 +209,36 @@ export declare abstract class CollectionElement<T extends Element_2 = Element_2>
|
|
|
170
209
|
/**
|
|
171
210
|
* Returns an empty collection element.
|
|
172
211
|
*/
|
|
173
|
-
abstract empty():
|
|
174
|
-
'fantasy-land/empty'(): CollectionElement<T>;
|
|
212
|
+
abstract empty(): this;
|
|
175
213
|
/**
|
|
176
214
|
* Concatenates two collection elements.
|
|
177
215
|
*/
|
|
178
|
-
concat(other: CollectionElement<T>):
|
|
179
|
-
'fantasy-land/concat'(other: CollectionElement<T>): CollectionElement<T>;
|
|
216
|
+
concat(other: CollectionElement<T>): this;
|
|
180
217
|
[Symbol.iterator](): IterableIterator<T>;
|
|
181
218
|
}
|
|
182
219
|
|
|
220
|
+
/**
|
|
221
|
+
* CommentElement represents a comment in the source document.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
export declare class CommentElement extends StringElement {
|
|
226
|
+
constructor(content?: string, meta?: Meta, attributes?: Attributes);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
export declare class DeepCloneError extends CloneError {
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
export declare type DeepCloneOptions = {
|
|
239
|
+
visited?: WeakMap<object, object>;
|
|
240
|
+
};
|
|
241
|
+
|
|
183
242
|
/**
|
|
184
243
|
* Tuple of detection test and element class.
|
|
185
244
|
* @public
|
|
@@ -203,7 +262,41 @@ export declare type DetectionTest = (value: unknown) => boolean;
|
|
|
203
262
|
*
|
|
204
263
|
* @public
|
|
205
264
|
*/
|
|
206
|
-
declare class Element_2 implements
|
|
265
|
+
declare class Element_2 implements ToValue, Equatable, Freezable {
|
|
266
|
+
/**
|
|
267
|
+
* Parent element reference (set when tree is frozen).
|
|
268
|
+
*/
|
|
269
|
+
parent?: Element_2;
|
|
270
|
+
/**
|
|
271
|
+
* Starting line number (0-based).
|
|
272
|
+
* Compatible with LSP Position.line.
|
|
273
|
+
*/
|
|
274
|
+
startLine?: number;
|
|
275
|
+
/**
|
|
276
|
+
* Starting character offset within the line (0-based, UTF-16 code units).
|
|
277
|
+
* Compatible with LSP Position.character.
|
|
278
|
+
*/
|
|
279
|
+
startCharacter?: number;
|
|
280
|
+
/**
|
|
281
|
+
* Starting offset from beginning of document (UTF-16 code units).
|
|
282
|
+
* Can be used directly as JavaScript string index.
|
|
283
|
+
*/
|
|
284
|
+
startOffset?: number;
|
|
285
|
+
/**
|
|
286
|
+
* Ending line number (0-based).
|
|
287
|
+
* Compatible with LSP Position.line.
|
|
288
|
+
*/
|
|
289
|
+
endLine?: number;
|
|
290
|
+
/**
|
|
291
|
+
* Ending character offset within the line (0-based, UTF-16 code units).
|
|
292
|
+
* Compatible with LSP Position.character.
|
|
293
|
+
*/
|
|
294
|
+
endCharacter?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Ending offset from beginning of document (UTF-16 code units).
|
|
297
|
+
* Can be used directly as JavaScript string index.
|
|
298
|
+
*/
|
|
299
|
+
endOffset?: number;
|
|
207
300
|
/**
|
|
208
301
|
* The element type identifier.
|
|
209
302
|
* @internal
|
|
@@ -224,10 +317,6 @@ declare class Element_2 implements Cloneable<Element_2>, ToValue, Equatable, Fre
|
|
|
224
317
|
* @internal
|
|
225
318
|
*/
|
|
226
319
|
protected _attributes?: Element_2;
|
|
227
|
-
/**
|
|
228
|
-
* Parent element reference (set when tree is frozen).
|
|
229
|
-
*/
|
|
230
|
-
parent?: Element_2;
|
|
231
320
|
/** @internal ObjectElement constructor for creating meta/attributes */
|
|
232
321
|
ObjectElement: new (content?: Record<string, unknown>) => ObjectElement;
|
|
233
322
|
/** @internal ArrayElement constructor for creating arrays */
|
|
@@ -267,17 +356,11 @@ declare class Element_2 implements Cloneable<Element_2>, ToValue, Equatable, Fre
|
|
|
267
356
|
get id(): Element_2;
|
|
268
357
|
set id(value: Element_2 | string);
|
|
269
358
|
/** CSS-like class names. */
|
|
270
|
-
get classes():
|
|
271
|
-
set classes(value:
|
|
272
|
-
/** Human-readable title. */
|
|
273
|
-
get title(): Element_2;
|
|
274
|
-
set title(value: Element_2 | string);
|
|
275
|
-
/** Human-readable description. */
|
|
276
|
-
get description(): Element_2;
|
|
277
|
-
set description(value: Element_2 | string);
|
|
359
|
+
get classes(): ArrayElement;
|
|
360
|
+
set classes(value: ArrayElement | unknown[]);
|
|
278
361
|
/** Hyperlinks associated with this element. */
|
|
279
|
-
get links():
|
|
280
|
-
set links(value:
|
|
362
|
+
get links(): ArrayElement;
|
|
363
|
+
set links(value: ArrayElement | unknown[]);
|
|
281
364
|
/** Returns direct children of this element. */
|
|
282
365
|
get children(): Element_2[];
|
|
283
366
|
/** Whether this element is frozen (immutable). */
|
|
@@ -287,10 +370,6 @@ declare class Element_2 implements Cloneable<Element_2>, ToValue, Equatable, Fre
|
|
|
287
370
|
* Sets up parent references for tree traversal.
|
|
288
371
|
*/
|
|
289
372
|
freeze(): void;
|
|
290
|
-
/**
|
|
291
|
-
* Creates a deep clone of this element.
|
|
292
|
-
*/
|
|
293
|
-
clone(): Element_2;
|
|
294
373
|
/**
|
|
295
374
|
* Converts the element to its JavaScript value representation.
|
|
296
375
|
*/
|
|
@@ -318,11 +397,35 @@ declare class Element_2 implements Cloneable<Element_2>, ToValue, Equatable, Fre
|
|
|
318
397
|
/**
|
|
319
398
|
* Gets a meta property, creating it with default value if not present.
|
|
320
399
|
*/
|
|
321
|
-
|
|
400
|
+
getMetaProperty(name: string, defaultValue: unknown): Element_2;
|
|
322
401
|
/**
|
|
323
402
|
* Sets a meta property.
|
|
324
403
|
*/
|
|
325
|
-
|
|
404
|
+
setMetaProperty(name: string, value: unknown): void;
|
|
405
|
+
/**
|
|
406
|
+
* Has meta property.
|
|
407
|
+
*/
|
|
408
|
+
hasMetaProperty(name: string): boolean;
|
|
409
|
+
/**
|
|
410
|
+
* Checks if meta is empty.
|
|
411
|
+
*/
|
|
412
|
+
get isMetaEmpty(): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Gets an attribute property, creating it with default value if not present.
|
|
415
|
+
*/
|
|
416
|
+
getAttributesProperty(name: string, defaultValue: unknown): Element_2;
|
|
417
|
+
/**
|
|
418
|
+
* Sets an attributes property.
|
|
419
|
+
*/
|
|
420
|
+
setAttributesProperty(name: string, value: unknown): void;
|
|
421
|
+
/**
|
|
422
|
+
* Has attributes property.
|
|
423
|
+
*/
|
|
424
|
+
hasAttributesProperty(name: string): boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Checks if attributes is empty.
|
|
427
|
+
*/
|
|
428
|
+
get isAttributesEmpty(): boolean;
|
|
326
429
|
}
|
|
327
430
|
export { Element_2 as Element }
|
|
328
431
|
|
|
@@ -355,6 +458,11 @@ export declare interface Equatable {
|
|
|
355
458
|
equals(value: unknown): boolean;
|
|
356
459
|
}
|
|
357
460
|
|
|
461
|
+
/**
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
export declare type FinalCloneTypes = KeyValuePair | ObjectSlice;
|
|
465
|
+
|
|
358
466
|
/**
|
|
359
467
|
* Condition function for finding elements.
|
|
360
468
|
* @public
|
|
@@ -379,6 +487,98 @@ export declare interface Freezable {
|
|
|
379
487
|
readonly isFrozen: boolean;
|
|
380
488
|
}
|
|
381
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Checks if an element has complete source position information.
|
|
492
|
+
* Returns true only if all 6 position properties are numbers.
|
|
493
|
+
* @public
|
|
494
|
+
*/
|
|
495
|
+
export declare const hasElementSourceMap: <T extends Element_2>(element: T) => boolean;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @public
|
|
499
|
+
*/
|
|
500
|
+
export declare const includesClasses: <T extends Element_2>(element: T, classes: string[]) => boolean;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* @public
|
|
504
|
+
*/
|
|
505
|
+
export declare const includesSymbols: <T extends Element_2>(element: T, symbols: string[]) => boolean;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @public
|
|
509
|
+
*/
|
|
510
|
+
export declare const isAnnotationElement: (element: unknown) => element is AnnotationElement;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @public
|
|
514
|
+
*/
|
|
515
|
+
export declare const isArrayElement: (element: unknown) => element is ArrayElement;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* @public
|
|
519
|
+
*/
|
|
520
|
+
export declare const isBooleanElement: (element: unknown) => element is BooleanElement;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @public
|
|
524
|
+
*/
|
|
525
|
+
export declare const isCommentElement: (element: unknown) => element is CommentElement;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @public
|
|
529
|
+
*/
|
|
530
|
+
export declare const isElement: (element: unknown) => element is Element_2;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
export declare const isLinkElement: (element: unknown) => element is LinkElement;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @public
|
|
539
|
+
*/
|
|
540
|
+
export declare const isMemberElement: (element: unknown) => element is MemberElement;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
545
|
+
export declare const isNullElement: (element: unknown) => element is NullElement;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* @public
|
|
549
|
+
*/
|
|
550
|
+
export declare const isNumberElement: (element: unknown) => element is NumberElement;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* @public
|
|
554
|
+
*/
|
|
555
|
+
export declare const isObjectElement: (element: unknown) => element is ObjectElement;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @public
|
|
559
|
+
*/
|
|
560
|
+
export declare const isParseResultElement: (element: unknown) => element is ParseResultElement;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* @public
|
|
564
|
+
*/
|
|
565
|
+
export declare const isPrimitiveElement: (element: unknown) => element is PrimitiveElement;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* @public
|
|
569
|
+
*/
|
|
570
|
+
export declare const isRefElement: (element: unknown) => element is RefElement;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* @public
|
|
574
|
+
*/
|
|
575
|
+
export declare const isSourceMapElement: (element: unknown) => element is SourceMapElement;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @public
|
|
579
|
+
*/
|
|
580
|
+
export declare const isStringElement: (element: unknown) => element is StringElement;
|
|
581
|
+
|
|
382
582
|
/**
|
|
383
583
|
* JSONSerialiser handles serialization and deserialization of ApiDOM elements
|
|
384
584
|
* to and from JSON Refract format.
|
|
@@ -410,14 +610,10 @@ export declare class JSONSerialiser {
|
|
|
410
610
|
* @typeParam V - Value element type
|
|
411
611
|
* @public
|
|
412
612
|
*/
|
|
413
|
-
export declare class KeyValuePair<K extends Element_2 = Element_2, V extends Element_2 = Element_2>
|
|
613
|
+
export declare class KeyValuePair<K extends Element_2 = Element_2, V extends Element_2 = Element_2> {
|
|
414
614
|
key: K | undefined;
|
|
415
615
|
value: V | undefined;
|
|
416
616
|
constructor(key?: K, value?: V);
|
|
417
|
-
/**
|
|
418
|
-
* Creates a deep clone of the KeyValuePair.
|
|
419
|
-
*/
|
|
420
|
-
clone(): KeyValuePair<K, V>;
|
|
421
617
|
/**
|
|
422
618
|
* Converts to a plain JavaScript object representation.
|
|
423
619
|
*/
|
|
@@ -682,7 +878,7 @@ export declare class ObjectElement<K extends Element_2 = Element_2, V extends El
|
|
|
682
878
|
/**
|
|
683
879
|
* Returns an empty object element.
|
|
684
880
|
*/
|
|
685
|
-
empty():
|
|
881
|
+
empty(): this;
|
|
686
882
|
}
|
|
687
883
|
|
|
688
884
|
/**
|
|
@@ -772,10 +968,6 @@ export declare class ObjectSlice {
|
|
|
772
968
|
* @param member - The member element to add
|
|
773
969
|
*/
|
|
774
970
|
push(member: MemberElement): this;
|
|
775
|
-
/**
|
|
776
|
-
* Creates a deep clone of the ObjectSlice.
|
|
777
|
-
*/
|
|
778
|
-
clone(): ObjectSlice;
|
|
779
971
|
/**
|
|
780
972
|
* Determines whether the slice includes a member with the given key value.
|
|
781
973
|
* @param keyValue - The key value to search for
|
|
@@ -800,6 +992,56 @@ export declare type ObjectSliceCallback<U> = (value: Element_2, key: Element_2,
|
|
|
800
992
|
*/
|
|
801
993
|
export declare type ObjectSliceForEachCallback = (value: Element_2, key: Element_2, member: MemberElement, index: number) => void;
|
|
802
994
|
|
|
995
|
+
/**
|
|
996
|
+
* ParseResultElement represents the result of parsing a document.
|
|
997
|
+
*
|
|
998
|
+
* Contains the parsed API element, any result elements, and annotations
|
|
999
|
+
* (warnings and errors) from the parsing process.
|
|
1000
|
+
*
|
|
1001
|
+
* @public
|
|
1002
|
+
*/
|
|
1003
|
+
export declare class ParseResultElement extends ArrayElement {
|
|
1004
|
+
constructor(content?: unknown[], meta?: Meta, attributes?: Attributes);
|
|
1005
|
+
/**
|
|
1006
|
+
* The main API element from the parse result.
|
|
1007
|
+
*/
|
|
1008
|
+
get api(): Element_2 | undefined;
|
|
1009
|
+
/**
|
|
1010
|
+
* All result elements from the parse result.
|
|
1011
|
+
*/
|
|
1012
|
+
get results(): ArrayElement;
|
|
1013
|
+
/**
|
|
1014
|
+
* The first result element.
|
|
1015
|
+
*/
|
|
1016
|
+
get result(): Element_2 | undefined;
|
|
1017
|
+
/**
|
|
1018
|
+
* All annotation elements (warnings and errors).
|
|
1019
|
+
*/
|
|
1020
|
+
get annotations(): ArrayElement;
|
|
1021
|
+
/**
|
|
1022
|
+
* All warning annotations.
|
|
1023
|
+
*/
|
|
1024
|
+
get warnings(): ArrayElement;
|
|
1025
|
+
/**
|
|
1026
|
+
* All error annotations.
|
|
1027
|
+
*/
|
|
1028
|
+
get errors(): ArrayElement;
|
|
1029
|
+
/**
|
|
1030
|
+
* Whether the parse result is empty (contains only annotations).
|
|
1031
|
+
*/
|
|
1032
|
+
get isEmpty(): boolean;
|
|
1033
|
+
/**
|
|
1034
|
+
* Replaces the first result element with the given replacement.
|
|
1035
|
+
* @returns true if replacement was successful, false otherwise
|
|
1036
|
+
*/
|
|
1037
|
+
replaceResult(replacement: Element_2): boolean;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* @public
|
|
1042
|
+
*/
|
|
1043
|
+
export declare type PrimitiveElement = ObjectElement | ArrayElement | BooleanElement | NumberElement | StringElement | NullElement | MemberElement;
|
|
1044
|
+
|
|
803
1045
|
/**
|
|
804
1046
|
* Primitive JavaScript values that can be element content.
|
|
805
1047
|
* @public
|
|
@@ -863,6 +1105,60 @@ export declare interface SerializedKeyValuePair {
|
|
|
863
1105
|
value?: SerializedElement;
|
|
864
1106
|
}
|
|
865
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* @public
|
|
1110
|
+
*/
|
|
1111
|
+
export declare class ShallowCloneError extends CloneError {
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* SourceMapElement stores source position as a compact VLQ-encoded string.
|
|
1116
|
+
*
|
|
1117
|
+
* The encoded string contains 6 values: startLine, startCharacter, startOffset,
|
|
1118
|
+
* endLine, endCharacter, endOffset. All values use UTF-16 code units,
|
|
1119
|
+
* compatible with LSP, TextDocument, and JavaScript string indexing.
|
|
1120
|
+
*
|
|
1121
|
+
* web-tree-sitter automatically provides position data in UTF-16 code units.
|
|
1122
|
+
*
|
|
1123
|
+
* @public
|
|
1124
|
+
*/
|
|
1125
|
+
export declare class SourceMapElement extends StringElement {
|
|
1126
|
+
constructor(content?: string, meta?: Meta, attributes?: Attributes);
|
|
1127
|
+
/**
|
|
1128
|
+
* Transfers source position properties from one object to another.
|
|
1129
|
+
*/
|
|
1130
|
+
static transfer(from: SourceMapShape, to: SourceMapShape): void;
|
|
1131
|
+
/**
|
|
1132
|
+
* Creates a SourceMapElement from source position properties.
|
|
1133
|
+
* Returns undefined if any position property is not a number.
|
|
1134
|
+
* Also assigns position properties to the instance for inspection.
|
|
1135
|
+
*/
|
|
1136
|
+
static from(source: SourceMapShape): SourceMapElement | undefined;
|
|
1137
|
+
/**
|
|
1138
|
+
* Decodes the VLQ string and applies source position properties to the target.
|
|
1139
|
+
*/
|
|
1140
|
+
applyTo(target: SourceMapShape): void;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Shape with optional source position properties.
|
|
1145
|
+
* @public
|
|
1146
|
+
*/
|
|
1147
|
+
export declare interface SourceMapShape {
|
|
1148
|
+
startLine?: number;
|
|
1149
|
+
startCharacter?: number;
|
|
1150
|
+
startOffset?: number;
|
|
1151
|
+
endLine?: number;
|
|
1152
|
+
endCharacter?: number;
|
|
1153
|
+
endOffset?: number;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Span of 6 position values: [startLine, startCharacter, startOffset, endLine, endCharacter, endOffset]
|
|
1158
|
+
* @public
|
|
1159
|
+
*/
|
|
1160
|
+
export declare type Span6 = [number, number, number, number, number, number];
|
|
1161
|
+
|
|
866
1162
|
/**
|
|
867
1163
|
* StringElement represents a string value in ApiDOM.
|
|
868
1164
|
* @public
|