@noldova/context.diagnostics 0.0.0-stage → 0.0.1
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 +21 -0
- package/api/index.d.ts +428 -0
- package/api/index.js +17 -0
- package/api/index.js.map +1 -0
- package/enums/diagnostic-category.js +15 -0
- package/enums/diagnostic-category.js.map +1 -0
- package/enums/diagnostic-tag.js +13 -0
- package/enums/diagnostic-tag.js.map +1 -0
- package/models/diagnostic-authority.js +17 -0
- package/models/diagnostic-authority.js.map +1 -0
- package/models/diagnostic-code.js +24 -0
- package/models/diagnostic-code.js.map +1 -0
- package/models/diagnostic-location.js +36 -0
- package/models/diagnostic-location.js.map +1 -0
- package/models/diagnostic-message.js +23 -0
- package/models/diagnostic-message.js.map +1 -0
- package/models/diagnostic-related-information.js +16 -0
- package/models/diagnostic-related-information.js.map +1 -0
- package/models/diagnostic-template.js +32 -0
- package/models/diagnostic-template.js.map +1 -0
- package/models/diagnostic.js +29 -0
- package/models/diagnostic.js.map +1 -0
- package/package.json +23 -4
- package/resources.js +22 -0
- package/resources.js.map +1 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import "@noldova/context.core";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The semantic category of a diagnostic. Category is part of diagnostic
|
|
13
|
+
* identity; no formatter, consumer, or later phase may rewrite it.
|
|
14
|
+
* The producer selects it from its catalog, not from display preferences.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum DiagnosticCategory {
|
|
17
|
+
/**
|
|
18
|
+
* A condition that prevents the requested operation from succeeding.
|
|
19
|
+
*/
|
|
20
|
+
Error = "Error",
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A condition that deserves attention but does not prevent success.
|
|
24
|
+
*/
|
|
25
|
+
Warning = "Warning",
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A non-failing recommendation for improving the source.
|
|
29
|
+
*/
|
|
30
|
+
Suggestion = "Suggestion",
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Informational diagnostic output without an error or warning condition.
|
|
34
|
+
*/
|
|
35
|
+
Message = "Message",
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* One diagnostic-code namespace and the prefix used to display its codes.
|
|
40
|
+
* Authorities are closed canonical identities rather than arbitrary strings.
|
|
41
|
+
* Use the shared instances; callers cannot construct or register an authority.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* DiagnosticAuthority.context.codePrefix; // "CTX"
|
|
46
|
+
* DiagnosticAuthority.typeScript.codePrefix; // "TS"
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class DiagnosticAuthority {
|
|
50
|
+
/**
|
|
51
|
+
* The shared CONTEXT-owned diagnostic-code namespace, displayed with `CTX`.
|
|
52
|
+
*/
|
|
53
|
+
public static readonly context: DiagnosticAuthority;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The shared upstream TypeScript diagnostic-code namespace, displayed with `TS`.
|
|
57
|
+
*/
|
|
58
|
+
public static readonly typeScript: DiagnosticAuthority;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The canonical prefix placed before a numeric code in display text. It is
|
|
62
|
+
* presentation data owned by the authority, not a separately registered identity.
|
|
63
|
+
*/
|
|
64
|
+
public readonly codePrefix: string;
|
|
65
|
+
|
|
66
|
+
private constructor(codePrefix: string);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* An immutable code pairing a canonical authority with a positive safe integer.
|
|
71
|
+
* The producer supplies the exact upstream TypeScript number or a registered
|
|
72
|
+
* CONTEXT number from its allocated range. Construction validates the numeric
|
|
73
|
+
* value only; it does not allocate codes or check catalog membership or uniqueness.
|
|
74
|
+
*/
|
|
75
|
+
export declare class DiagnosticCode {
|
|
76
|
+
/**
|
|
77
|
+
* The namespace that owns the numeric code.
|
|
78
|
+
*/
|
|
79
|
+
public readonly authority: DiagnosticAuthority;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The display form: the authority prefix followed by the value, such as
|
|
83
|
+
* `TS2304` or `CTX1001`.
|
|
84
|
+
*/
|
|
85
|
+
public readonly displayText: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The positive safe integer assigned by the owning authority.
|
|
89
|
+
*/
|
|
90
|
+
public readonly value: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Creates a code in the supplied authority's namespace.
|
|
94
|
+
*
|
|
95
|
+
* @param authority The canonical namespace that owns the numeric code.
|
|
96
|
+
* @param value The assigned integer, from 1 through `Number.MAX_SAFE_INTEGER`
|
|
97
|
+
* inclusive. Zero is not a valid code or an absence marker.
|
|
98
|
+
* @throws {ArgumentOutOfRangeException} If `value` is nonpositive, fractional,
|
|
99
|
+
* non-finite, or outside the safe integer range. The exception identifies
|
|
100
|
+
* `value` and retains the rejected number as `actualValue`.
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { DiagnosticAuthority, DiagnosticCode } from "@noldova/context.diagnostics";
|
|
104
|
+
*
|
|
105
|
+
* const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2304);
|
|
106
|
+
* code.displayText; // "TS2304"
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
public constructor(authority: DiagnosticAuthority, value: number);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* One diagnostic location: an optional canonical source identity and one exact
|
|
114
|
+
* UTF-16 span. The span is half-open: `[start, start + length)`. Zero-length
|
|
115
|
+
* spans, including an end-of-file span, are valid. Line and character
|
|
116
|
+
* coordinates are derived presentation and are never stored here.
|
|
117
|
+
*/
|
|
118
|
+
export declare class DiagnosticLocation {
|
|
119
|
+
/**
|
|
120
|
+
* The caller-supplied canonical logical source identity, preserved verbatim.
|
|
121
|
+
* `undefined` represents anonymous input; no path or synthetic name is inferred.
|
|
122
|
+
*/
|
|
123
|
+
public readonly sourceIdentity: string | undefined;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The zero-based UTF-16 offset at which the span begins.
|
|
127
|
+
*/
|
|
128
|
+
public readonly start: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The number of UTF-16 code units in the span.
|
|
132
|
+
*/
|
|
133
|
+
public readonly length: number;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates a source span, optionally checking it against a known source length.
|
|
137
|
+
*
|
|
138
|
+
* @param sourceIdentity The canonical logical identity supplied by the input
|
|
139
|
+
* owner, or `undefined` for anonymous text. A supplied identity must be nonblank;
|
|
140
|
+
* it is not trimmed, resolved as a path, or otherwise canonicalized here.
|
|
141
|
+
* @param start The zero-based UTF-16 code-unit offset. It must be a non-negative
|
|
142
|
+
* safe integer, and `start + length` must also be a safe integer.
|
|
143
|
+
* @param length The number of UTF-16 code units covered, as a non-negative safe
|
|
144
|
+
* integer. Zero describes a position without covering a character, including EOF.
|
|
145
|
+
* @param sourceLength The source snapshot's UTF-16 length, as a non-negative
|
|
146
|
+
* safe integer. When supplied, the span end must not exceed it. It is used only
|
|
147
|
+
* for validation and is not retained; omission leaves the upper bound unchecked.
|
|
148
|
+
* @throws {ArgumentException} If a supplied source identity is empty or whitespace-only.
|
|
149
|
+
* @throws {ArgumentOutOfRangeException} If a numeric argument is negative,
|
|
150
|
+
* fractional, non-finite, or unsafe, the span end is unsafe, or the span exceeds
|
|
151
|
+
* `sourceLength`. Span-end failures identify `length`; individual numeric
|
|
152
|
+
* failures identify the offending argument and retain its value.
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const text = "A\u{1F600}B";
|
|
156
|
+
* const character = new DiagnosticLocation(undefined, 1, 2, text.length);
|
|
157
|
+
* text.slice(character.start, character.start + character.length); // "\u{1F600}"
|
|
158
|
+
* const end = new DiagnosticLocation("sample.ts", text.length, 0, text.length);
|
|
159
|
+
* end.length; // 0: an end-of-file position.
|
|
160
|
+
* const empty = new DiagnosticLocation(undefined, 0, 0, 0);
|
|
161
|
+
* empty.sourceIdentity; // undefined: an empty anonymous source.
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
public constructor(sourceIdentity: string | undefined, start: number, length: number, sourceLength?: number);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* A structured marker applicable to a diagnostic. A tag is complete at
|
|
169
|
+
* creation and is never inferred later from message wording.
|
|
170
|
+
* Tags do not replace or change {@link DiagnosticCategory}.
|
|
171
|
+
*/
|
|
172
|
+
export declare enum DiagnosticTag {
|
|
173
|
+
/**
|
|
174
|
+
* The diagnosed source is unnecessary.
|
|
175
|
+
*/
|
|
176
|
+
Unnecessary = "Unnecessary",
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The diagnosed source refers to a deprecated API or construct.
|
|
180
|
+
*/
|
|
181
|
+
Deprecated = "Deprecated",
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* One canonical message node: its code, category, canonical English text,
|
|
186
|
+
* and ordered children. A nested message chain is a tree of these nodes;
|
|
187
|
+
* child order is preserved exactly. Flattening the chain into one string is
|
|
188
|
+
* a presentation concern and never a substitute for this structure.
|
|
189
|
+
*/
|
|
190
|
+
export declare class DiagnosticMessage {
|
|
191
|
+
/**
|
|
192
|
+
* The diagnostic code carried by this message node.
|
|
193
|
+
*/
|
|
194
|
+
public readonly code: DiagnosticCode;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The semantic category carried by this message node.
|
|
198
|
+
*/
|
|
199
|
+
public readonly category: DiagnosticCategory;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The complete nonblank canonical English text of this node, preserved
|
|
203
|
+
* verbatim. It is not a deferred template or a flattened message chain.
|
|
204
|
+
*/
|
|
205
|
+
public readonly text: string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A shallow snapshot of the ordered child sequence. Child instances are
|
|
209
|
+
* shared, not cloned; neither duplicate entries nor their order are changed.
|
|
210
|
+
*/
|
|
211
|
+
public readonly children: readonly DiagnosticMessage[];
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Creates one node in a structured message chain.
|
|
215
|
+
*
|
|
216
|
+
* @param code The code for this node, which may differ from its parent's code.
|
|
217
|
+
* @param category This node's category; it is not inherited from a parent.
|
|
218
|
+
* @param text The already formatted canonical text. It must contain at least
|
|
219
|
+
* one non-whitespace character and is stored without trimming or reformatting.
|
|
220
|
+
* @param children The ordered detail nodes, or an empty array for a leaf.
|
|
221
|
+
* The array is copied; the child objects and their nested chains are retained.
|
|
222
|
+
* @throws {ArgumentException} If `text` is empty or whitespace-only.
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2322);
|
|
226
|
+
* const detail = new DiagnosticMessage(code, DiagnosticCategory.Error,
|
|
227
|
+
* "Type 'string' is not assignable to type 'number'.", []);
|
|
228
|
+
* const message = new DiagnosticMessage(code, DiagnosticCategory.Error,
|
|
229
|
+
* "The assignment is invalid.", [detail]);
|
|
230
|
+
* message.children[0] === detail; // true: the array is copied, not the detail.
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
public constructor(code: DiagnosticCode, category: DiagnosticCategory, text: string, children: readonly DiagnosticMessage[]);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* One related record of a diagnostic, preserved independently: its message
|
|
238
|
+
* node and its optional location. The code and category are those of the
|
|
239
|
+
* message node. Related information is never appended to the primary
|
|
240
|
+
* message and never discarded by a formatter that does not display it.
|
|
241
|
+
*/
|
|
242
|
+
export declare class DiagnosticRelatedInformation {
|
|
243
|
+
/**
|
|
244
|
+
* The retained related message, including its independent code, category,
|
|
245
|
+
* and any nested details.
|
|
246
|
+
*/
|
|
247
|
+
public readonly message: DiagnosticMessage;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The related source location, when the information is source-bound.
|
|
251
|
+
*/
|
|
252
|
+
public readonly location: DiagnosticLocation | undefined;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Pairs a related message with its optional source location.
|
|
256
|
+
*
|
|
257
|
+
* @param message The complete related message, not text to append to the
|
|
258
|
+
* primary diagnostic. Its identity and message chain are retained unchanged.
|
|
259
|
+
* @param location The related span, or `undefined` for information that is
|
|
260
|
+
* not source-bound. It need not use the primary diagnostic's source identity.
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2728);
|
|
264
|
+
* const message = new DiagnosticMessage(code, DiagnosticCategory.Error,
|
|
265
|
+
* "'value' is declared here.", []);
|
|
266
|
+
* const related = new DiagnosticRelatedInformation(message,
|
|
267
|
+
* new DiagnosticLocation("sample.ts", 3, 4));
|
|
268
|
+
* related.message === message; // true
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
public constructor(message: DiagnosticMessage, location: DiagnosticLocation | undefined);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* One complete reported diagnostic occurrence. A constructor establishes a
|
|
276
|
+
* completely valid object; no consumer attaches, repairs, or replaces
|
|
277
|
+
* fields after creation. The code and category are derived from the primary
|
|
278
|
+
* message node, so one authority exists by construction.
|
|
279
|
+
*/
|
|
280
|
+
export declare class Diagnostic {
|
|
281
|
+
/**
|
|
282
|
+
* The primary message node of this occurrence.
|
|
283
|
+
*/
|
|
284
|
+
public readonly message: DiagnosticMessage;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The code of the primary message node.
|
|
288
|
+
*/
|
|
289
|
+
public readonly code: DiagnosticCode;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The category of the primary message node.
|
|
293
|
+
*/
|
|
294
|
+
public readonly category: DiagnosticCategory;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The primary source location, when the occurrence is source-bound.
|
|
298
|
+
*/
|
|
299
|
+
public readonly location: DiagnosticLocation | undefined;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* A shallow snapshot of related records in their canonical order. The
|
|
303
|
+
* records themselves are shared; repeated records are preserved.
|
|
304
|
+
*/
|
|
305
|
+
public readonly relatedInformation: readonly DiagnosticRelatedInformation[];
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* A snapshot of the supplied tags in order, with no duplicates. These tags
|
|
309
|
+
* do not change the occurrence's code or category.
|
|
310
|
+
*/
|
|
311
|
+
public readonly tags: readonly DiagnosticTag[];
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Publishes one complete occurrence from a primary message and its context.
|
|
315
|
+
*
|
|
316
|
+
* @param message The complete primary message or message-chain root. Its code
|
|
317
|
+
* and category also become the occurrence's code and category; it is not cloned.
|
|
318
|
+
* @param location The primary source span, or `undefined` for a global or
|
|
319
|
+
* non-text diagnostic. An anonymous source still supplies a location with an
|
|
320
|
+
* undefined source identity, rather than discarding its span.
|
|
321
|
+
* @param relatedInformation Ordered related records, or an empty array.
|
|
322
|
+
* The array is copied, retaining its elements, order, and repeated entries.
|
|
323
|
+
* @param tags The final ordered tags, or an empty array. The array is copied;
|
|
324
|
+
* every tag must occur at most once. No tags are inferred from the message.
|
|
325
|
+
* @throws {ArgumentException} If `tags` contains a duplicate.
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2304);
|
|
329
|
+
* const message = new DiagnosticMessage(code, DiagnosticCategory.Error,
|
|
330
|
+
* "Cannot find name 'value'.", []);
|
|
331
|
+
* const diagnostic = new Diagnostic(message,
|
|
332
|
+
* new DiagnosticLocation(undefined, 12, 5), [], []);
|
|
333
|
+
* diagnostic.code === message.code; // true
|
|
334
|
+
* diagnostic.location?.sourceIdentity; // undefined: anonymous, not unlocated.
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
public constructor(
|
|
338
|
+
message: DiagnosticMessage,
|
|
339
|
+
location: DiagnosticLocation | undefined,
|
|
340
|
+
relatedInformation: readonly DiagnosticRelatedInformation[],
|
|
341
|
+
tags: readonly DiagnosticTag[]);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* One reusable, immutable diagnostic template owned by a producer catalog.
|
|
346
|
+
* A template is not itself a reported diagnostic, and an occurrence cannot
|
|
347
|
+
* be reused as a template.
|
|
348
|
+
*/
|
|
349
|
+
export declare class DiagnosticTemplate {
|
|
350
|
+
/**
|
|
351
|
+
* The code assigned to every occurrence created from this template.
|
|
352
|
+
*/
|
|
353
|
+
public readonly code: DiagnosticCode;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* The category assigned to every occurrence created from this template.
|
|
357
|
+
*/
|
|
358
|
+
public readonly category: DiagnosticCategory;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* The nonblank canonical positional template, using Core's
|
|
362
|
+
* {@link StringConstructor.format} placeholder convention.
|
|
363
|
+
*/
|
|
364
|
+
public readonly messageTemplate: string;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* A snapshot of the default tags, applied in this order before occurrence
|
|
368
|
+
* tags. The array contains no duplicates and is unchanged by creating occurrences.
|
|
369
|
+
*/
|
|
370
|
+
public readonly defaultTags: readonly DiagnosticTag[];
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Creates a reusable catalog definition without reporting a diagnostic.
|
|
374
|
+
*
|
|
375
|
+
* @param code The producer-assigned code shared by all created occurrences.
|
|
376
|
+
* Catalog membership and allocation are the producer's responsibility.
|
|
377
|
+
* @param category The category applied to every occurrence without reinterpretation.
|
|
378
|
+
* @param messageTemplate Nonblank canonical English text with zero-based
|
|
379
|
+
* placeholders such as `{0}`. Catalogs and their generators validate placeholder
|
|
380
|
+
* correctness; this constructor neither parses nor caches placeholder structure.
|
|
381
|
+
* @param defaultTags Tags applied to every occurrence, in order. Omission or
|
|
382
|
+
* `undefined` uses an empty sequence. The input array is copied and must contain
|
|
383
|
+
* no duplicates.
|
|
384
|
+
* @throws {ArgumentException} If `messageTemplate` is empty or whitespace-only,
|
|
385
|
+
* or `defaultTags` contains a duplicate.
|
|
386
|
+
* @example
|
|
387
|
+
* See {@link DiagnosticTemplate.create} for a reusable template and its occurrences.
|
|
388
|
+
*/
|
|
389
|
+
public constructor(code: DiagnosticCode, category: DiagnosticCategory, messageTemplate: string, defaultTags?: readonly DiagnosticTag[]);
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Creates one immutable occurrence, formatting its primary message exactly
|
|
393
|
+
* once through {@link StringConstructor.format}. To publish a nested chain,
|
|
394
|
+
* construct {@link DiagnosticMessage} nodes and a {@link Diagnostic} directly.
|
|
395
|
+
*
|
|
396
|
+
* @param location The primary span, or `undefined` for a diagnostic without a
|
|
397
|
+
* source location. Anonymous text can use a {@link DiagnosticLocation} without
|
|
398
|
+
* a source identity.
|
|
399
|
+
* @param messageArguments String and number substitutions, indexed from zero.
|
|
400
|
+
* Omission or `undefined` supplies none. Unavailable or unrecognized placeholders
|
|
401
|
+
* remain unchanged; the producer must supply arguments matching its catalog.
|
|
402
|
+
* @param relatedInformation Ordered related records. Omission or `undefined`
|
|
403
|
+
* uses an empty sequence. The occurrence copies the array and retains its elements.
|
|
404
|
+
* @param tags Occurrence-specific tags appended after {@link DiagnosticTemplate.defaultTags}.
|
|
405
|
+
* Omission or `undefined` supplies none. The combined sequence must have no duplicates.
|
|
406
|
+
* @returns A new occurrence and primary message node, with the template's code
|
|
407
|
+
* and category and no message children. Formatting arguments are not retained;
|
|
408
|
+
* the template is unchanged and can create further independent occurrences.
|
|
409
|
+
* @throws {ArgumentException} If the formatted message is empty or whitespace-only,
|
|
410
|
+
* or a tag repeats within the occurrence tags or overlaps a default tag. A valid
|
|
411
|
+
* template such as `"{0}"` can still produce invalid blank text after substitution.
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2304);
|
|
415
|
+
* const template = new DiagnosticTemplate(code, DiagnosticCategory.Error, "Cannot find name '{0}'.");
|
|
416
|
+
* const first = template.create(undefined, ["value"]);
|
|
417
|
+
* const second = template.create(undefined, ["other"]);
|
|
418
|
+
* first.message.text; // "Cannot find name 'value'."
|
|
419
|
+
* second.message.text; // "Cannot find name 'other'."
|
|
420
|
+
* first !== second; // true
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
public create(
|
|
424
|
+
location: DiagnosticLocation | undefined,
|
|
425
|
+
messageArguments?: readonly (string | number)[],
|
|
426
|
+
relatedInformation?: readonly DiagnosticRelatedInformation[],
|
|
427
|
+
tags?: readonly DiagnosticTag[]): Diagnostic;
|
|
428
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { DiagnosticCategory } from "../enums/diagnostic-category.js";
|
|
9
|
+
export { DiagnosticTag } from "../enums/diagnostic-tag.js";
|
|
10
|
+
export { DiagnosticAuthority } from "../models/diagnostic-authority.js";
|
|
11
|
+
export { DiagnosticCode } from "../models/diagnostic-code.js";
|
|
12
|
+
export { DiagnosticLocation } from "../models/diagnostic-location.js";
|
|
13
|
+
export { DiagnosticMessage } from "../models/diagnostic-message.js";
|
|
14
|
+
export { DiagnosticRelatedInformation } from "../models/diagnostic-related-information.js";
|
|
15
|
+
export { DiagnosticTemplate } from "../models/diagnostic-template.js";
|
|
16
|
+
export { Diagnostic } from "../models/diagnostic.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var DiagnosticCategory;
|
|
9
|
+
(function (DiagnosticCategory) {
|
|
10
|
+
DiagnosticCategory["Error"] = "Error";
|
|
11
|
+
DiagnosticCategory["Warning"] = "Warning";
|
|
12
|
+
DiagnosticCategory["Suggestion"] = "Suggestion";
|
|
13
|
+
DiagnosticCategory["Message"] = "Message";
|
|
14
|
+
})(DiagnosticCategory || (DiagnosticCategory = {}));
|
|
15
|
+
//# sourceMappingURL=diagnostic-category.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-category.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/enums/diagnostic-category.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,yCAAmB,CAAA;IACnB,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;AACrB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var DiagnosticTag;
|
|
9
|
+
(function (DiagnosticTag) {
|
|
10
|
+
DiagnosticTag["Unnecessary"] = "Unnecessary";
|
|
11
|
+
DiagnosticTag["Deprecated"] = "Deprecated";
|
|
12
|
+
})(DiagnosticTag || (DiagnosticTag = {}));
|
|
13
|
+
//# sourceMappingURL=diagnostic-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-tag.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/enums/diagnostic-tag.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,0CAAyB,CAAA;AAC3B,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { Resources } from "../resources.js";
|
|
9
|
+
export class DiagnosticAuthority {
|
|
10
|
+
static context = new DiagnosticAuthority(Resources.contextCodePrefix);
|
|
11
|
+
static typeScript = new DiagnosticAuthority(Resources.typeScriptCodePrefix);
|
|
12
|
+
codePrefix;
|
|
13
|
+
constructor(codePrefix) {
|
|
14
|
+
this.codePrefix = codePrefix;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=diagnostic-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-authority.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-authority.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAU,OAAO,GAAwB,IAAI,mBAAmB,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACpG,MAAM,CAAU,UAAU,GAAwB,IAAI,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAEjG,UAAU,CAAS;IAEnC,YAAoB,UAAkB;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { nameof } from "@noldova/context.core";
|
|
9
|
+
import { ArgumentOutOfRangeException } from "@noldova/context.exceptions";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
import { DiagnosticAuthority } from "./diagnostic-authority.js";
|
|
12
|
+
export class DiagnosticCode {
|
|
13
|
+
authority;
|
|
14
|
+
displayText;
|
|
15
|
+
value;
|
|
16
|
+
constructor(authority, value) {
|
|
17
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
18
|
+
throw new ArgumentOutOfRangeException(nameof(t => t.value), value, Resources.codeValueInvalid);
|
|
19
|
+
this.authority = authority;
|
|
20
|
+
this.displayText = `${authority.codePrefix}${value}`;
|
|
21
|
+
this.value = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=diagnostic-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-code.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,OAAO,cAAc;IACT,SAAS,CAAsB;IAC/B,WAAW,CAAS;IACpB,KAAK,CAAS;IAE9B,YAAmB,SAA8B,EAAE,KAAa;QAC9D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;YAC3C,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAEjH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,GAAG,SAAS,CAAC,UAAU,GAAG,KAAK,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { nameof } from "@noldova/context.core";
|
|
9
|
+
import { ArgumentException, ArgumentOutOfRangeException } from "@noldova/context.exceptions";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
export class DiagnosticLocation {
|
|
12
|
+
sourceIdentity;
|
|
13
|
+
start;
|
|
14
|
+
length;
|
|
15
|
+
constructor(sourceIdentity, start, length, sourceLength) {
|
|
16
|
+
if (!Object.isUndefined(sourceIdentity))
|
|
17
|
+
ArgumentException.throwIfNullOrWhitespace(sourceIdentity, nameof(t => t.sourceIdentity));
|
|
18
|
+
if (!Number.isSafeInteger(start) || start < 0)
|
|
19
|
+
throw new ArgumentOutOfRangeException(nameof(t => t.start), start, Resources.startInvalid);
|
|
20
|
+
if (!Number.isSafeInteger(length) || length < 0)
|
|
21
|
+
throw new ArgumentOutOfRangeException(nameof(t => t.length), length, Resources.lengthInvalid);
|
|
22
|
+
const end = start + length;
|
|
23
|
+
if (!Number.isSafeInteger(end))
|
|
24
|
+
throw new ArgumentOutOfRangeException(nameof(t => t.length), length, Resources.spanEndInvalid);
|
|
25
|
+
if (!Object.isUndefined(sourceLength)) {
|
|
26
|
+
if (!Number.isSafeInteger(sourceLength) || sourceLength < 0)
|
|
27
|
+
throw new ArgumentOutOfRangeException(Resources.sourceLengthParameterName, sourceLength, Resources.sourceLengthInvalid);
|
|
28
|
+
if (end > sourceLength)
|
|
29
|
+
throw new ArgumentOutOfRangeException(nameof(t => t.length), length, Resources.spanBeyondSource(end, sourceLength));
|
|
30
|
+
}
|
|
31
|
+
this.sourceIdentity = sourceIdentity;
|
|
32
|
+
this.start = start;
|
|
33
|
+
this.length = length;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=diagnostic-location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-location.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-location.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE7F,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,kBAAkB;IACb,cAAc,CAAqB;IACnC,KAAK,CAAS;IACd,MAAM,CAAS;IAE/B,YAAmB,cAAkC,EAAE,KAAa,EAAE,MAAc,EAAE,YAAqB;QACzG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC;YACrC,iBAAiB,CAAC,uBAAuB,CAAC,cAAc,EAAE,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;QAE/G,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;YAC3C,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAEjH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;YAC7C,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;QAEpH,MAAM,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC;YAC5B,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;QAErH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC;gBACzD,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,yBAAyB,EAAE,YAAY,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;YAE1H,IAAI,GAAG,GAAG,YAAY;gBACpB,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;QAC5I,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { nameof } from "@noldova/context.core";
|
|
9
|
+
import { ArgumentException } from "@noldova/context.exceptions";
|
|
10
|
+
export class DiagnosticMessage {
|
|
11
|
+
code;
|
|
12
|
+
category;
|
|
13
|
+
text;
|
|
14
|
+
children;
|
|
15
|
+
constructor(code, category, text, children) {
|
|
16
|
+
ArgumentException.throwIfNullOrWhitespace(text, nameof(t => t.text));
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.category = category;
|
|
19
|
+
this.text = text;
|
|
20
|
+
this.children = [...children];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=diagnostic-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-message.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAKhE,MAAM,OAAO,iBAAiB;IACZ,IAAI,CAAiB;IACrB,QAAQ,CAAqB;IAC7B,IAAI,CAAS;IACb,QAAQ,CAA+B;IAEvD,YAAmB,IAAoB,EAAE,QAA4B,EAAE,IAAY,EAAE,QAAsC;QACzH,iBAAiB,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAExF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class DiagnosticRelatedInformation {
|
|
9
|
+
message;
|
|
10
|
+
location;
|
|
11
|
+
constructor(message, location) {
|
|
12
|
+
this.message = message;
|
|
13
|
+
this.location = location;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=diagnostic-related-information.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-related-information.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-related-information.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,OAAO,4BAA4B;IACvB,OAAO,CAAoB;IAC3B,QAAQ,CAAiC;IAEzD,YAAmB,OAA0B,EAAE,QAAwC;QACrF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { nameof } from "@noldova/context.core";
|
|
9
|
+
import { ArgumentException } from "@noldova/context.exceptions";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
import { DiagnosticMessage } from "./diagnostic-message.js";
|
|
12
|
+
import { Diagnostic } from "./diagnostic.js";
|
|
13
|
+
export class DiagnosticTemplate {
|
|
14
|
+
code;
|
|
15
|
+
category;
|
|
16
|
+
messageTemplate;
|
|
17
|
+
defaultTags;
|
|
18
|
+
constructor(code, category, messageTemplate, defaultTags = []) {
|
|
19
|
+
ArgumentException.throwIfNullOrWhitespace(messageTemplate, nameof(t => t.messageTemplate));
|
|
20
|
+
if (new Set(defaultTags).size !== defaultTags.length)
|
|
21
|
+
throw new ArgumentException(Resources.duplicateTag, nameof(t => t.defaultTags));
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.category = category;
|
|
24
|
+
this.messageTemplate = messageTemplate;
|
|
25
|
+
this.defaultTags = [...defaultTags];
|
|
26
|
+
}
|
|
27
|
+
create(location, messageArguments = [], relatedInformation = [], tags = []) {
|
|
28
|
+
const message = new DiagnosticMessage(this.code, this.category, String.format(this.messageTemplate, ...messageArguments), []);
|
|
29
|
+
return new Diagnostic(message, location, relatedInformation, [...this.defaultTags, ...tags]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=diagnostic-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-template.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,OAAO,kBAAkB;IACb,IAAI,CAAiB;IACrB,QAAQ,CAAqB;IAC7B,eAAe,CAAS;IACxB,WAAW,CAA2B;IAEtD,YAAmB,IAAoB,EAAE,QAA4B,EAAE,eAAuB,EAAE,WAAW,GAA6B,EAAE;QACxI,iBAAiB,CAAC,uBAAuB,CAAC,eAAe,EAAE,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;QAE/G,IAAI,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM;YAClD,MAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAEtG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;IACtC,CAAC;IAEM,MAAM,CACX,QAAwC,EACxC,gBAAgB,GAAiC,EAAE,EACnD,kBAAkB,GAA4C,EAAE,EAChE,IAAI,GAA6B,EAAE;QACnC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;QAE9H,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { nameof } from "@noldova/context.core";
|
|
9
|
+
import { ArgumentException } from "@noldova/context.exceptions";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
export class Diagnostic {
|
|
12
|
+
message;
|
|
13
|
+
code;
|
|
14
|
+
category;
|
|
15
|
+
location;
|
|
16
|
+
relatedInformation;
|
|
17
|
+
tags;
|
|
18
|
+
constructor(message, location, relatedInformation, tags) {
|
|
19
|
+
if (new Set(tags).size !== tags.length)
|
|
20
|
+
throw new ArgumentException(Resources.duplicateTag, nameof(t => t.tags));
|
|
21
|
+
this.message = message;
|
|
22
|
+
this.code = this.message.code;
|
|
23
|
+
this.category = this.message.category;
|
|
24
|
+
this.location = location;
|
|
25
|
+
this.relatedInformation = [...relatedInformation];
|
|
26
|
+
this.tags = [...tags];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=diagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../../../src/noldova.context.diagnostics/src/models/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,MAAM,OAAO,UAAU;IACL,OAAO,CAAoB;IAC3B,IAAI,CAAiB;IACrB,QAAQ,CAAqB;IAC7B,QAAQ,CAAiC;IACzC,kBAAkB,CAA0C;IAC5D,IAAI,CAA2B;IAE/C,YACE,OAA0B,EAC1B,QAAwC,EACxC,kBAA2D,EAC3D,IAA8B;QAC9B,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM;YACpC,MAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,CAAC,GAAG,kBAAkB,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACxB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/context.diagnostics",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "api/index.js",
|
|
6
|
+
"types": "api/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/noldova-com/context.git",
|
|
11
|
+
"directory": "src/noldova.context.diagnostics"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/noldova-com/context#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/noldova-com/context/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@noldova/context.core": "0.0.1",
|
|
23
|
+
"@noldova/context.exceptions": "0.0.1"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/resources.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class Resources {
|
|
9
|
+
static codeValueInvalid = "The code value must be a positive safe integer.";
|
|
10
|
+
static contextCodePrefix = "CTX";
|
|
11
|
+
static duplicateTag = "The tags must not contain a duplicate.";
|
|
12
|
+
static lengthInvalid = "The length must be a non-negative safe integer.";
|
|
13
|
+
static sourceLengthInvalid = "The source length must be a non-negative safe integer.";
|
|
14
|
+
static sourceLengthParameterName = "sourceLength";
|
|
15
|
+
static spanEndInvalid = "The span end must be a non-negative safe integer.";
|
|
16
|
+
static startInvalid = "The start must be a non-negative safe integer.";
|
|
17
|
+
static typeScriptCodePrefix = "TS";
|
|
18
|
+
static spanBeyondSource(end, sourceLength) {
|
|
19
|
+
return `The span ending at ${end} exceeds the source length ${sourceLength}.`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=resources.js.map
|
package/resources.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/noldova.context.diagnostics/src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACb,MAAM,CAAU,gBAAgB,GAAW,iDAAiD,CAAC;IAC7F,MAAM,CAAU,iBAAiB,GAAW,KAAK,CAAC;IAClD,MAAM,CAAU,YAAY,GAAW,wCAAwC,CAAC;IAChF,MAAM,CAAU,aAAa,GAAW,iDAAiD,CAAC;IAC1F,MAAM,CAAU,mBAAmB,GAAW,wDAAwD,CAAC;IACvG,MAAM,CAAU,yBAAyB,GAAW,cAAc,CAAC;IACnE,MAAM,CAAU,cAAc,GAAW,mDAAmD,CAAC;IAC7F,MAAM,CAAU,YAAY,GAAW,gDAAgD,CAAC;IACxF,MAAM,CAAU,oBAAoB,GAAW,IAAI,CAAC;IAEpD,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,YAAoB;QAC9D,OAAO,sBAAsB,GAAG,8BAA8B,YAAY,GAAG,CAAC;IAChF,CAAC;CACF"}
|
package/README.md
DELETED