brighterscript 0.72.0 → 0.72.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/bsconfig.schema.json +62 -0
- package/dist/BsConfig.d.ts +56 -1
- package/dist/CommentFlagProcessor.d.ts +16 -12
- package/dist/CommentFlagProcessor.js +141 -59
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +27 -1
- package/dist/DiagnosticMessages.js +32 -2
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/Program.d.ts +4 -0
- package/dist/Program.js +2 -0
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +1 -8
- package/dist/ProgramBuilder.js +31 -11
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +38 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +257 -14
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +360 -10
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +13 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +215 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +51 -1
- package/dist/diagnosticUtils.js +222 -1
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/files/BrsFile.js +4 -2
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +191 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.js +2 -1
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +50 -0
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/interfaces.d.ts +15 -1
- package/dist/lexer/TokenKind.d.ts +8 -0
- package/dist/lexer/TokenKind.js +21 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/lsp/LspProject.d.ts +19 -0
- package/dist/lsp/Project.d.ts +14 -0
- package/dist/lsp/Project.js +9 -1
- package/dist/lsp/Project.js.map +1 -1
- package/dist/lsp/ProjectManager.js +15 -1
- package/dist/lsp/ProjectManager.js.map +1 -1
- package/dist/lsp/ProjectManager.spec.js +36 -0
- package/dist/lsp/ProjectManager.spec.js.map +1 -1
- package/dist/lsp/worker/WorkerThreadProject.d.ts +14 -0
- package/dist/lsp/worker/WorkerThreadProject.js +7 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
- package/dist/parser/Parser.d.ts +13 -1
- package/dist/parser/Parser.js +40 -14
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +128 -0
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +47 -0
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +37 -0
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +49 -0
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/util.js +20 -9
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
package/bsconfig.schema.json
CHANGED
|
@@ -8,6 +8,53 @@
|
|
|
8
8
|
"password"
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
|
+
"definitions": {
|
|
12
|
+
"diagnosticReporterValue": {
|
|
13
|
+
"oneOf": [
|
|
14
|
+
{
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Either a preset name ('detailed' or 'github-actions') or a custom template string containing at least one known placeholder."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["type"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"type": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["detailed"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"additionalProperties": false
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "object",
|
|
31
|
+
"required": ["type"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"type": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["github-actions"]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"additionalProperties": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "object",
|
|
42
|
+
"required": ["type", "format"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"type": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"enum": ["custom"]
|
|
47
|
+
},
|
|
48
|
+
"format": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Template string. Supported placeholders: {file}, {line}, {col}, {endLine}, {endCol}, {severity}, {severityCode}, {code}, {message}, {source}."
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"additionalProperties": false
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
11
58
|
"properties": {
|
|
12
59
|
"extends": {
|
|
13
60
|
"description": "Relative or absolute path to another bsconfig.json file that this file should use as a base and then override. Prefix with a question mark (?) to prevent throwing an exception if the file does not exist.",
|
|
@@ -300,6 +347,21 @@
|
|
|
300
347
|
"error"
|
|
301
348
|
]
|
|
302
349
|
},
|
|
350
|
+
"diagnosticReporters": {
|
|
351
|
+
"description": "Specify how diagnostics are reported to the console. Accepts a single value or an array; each diagnostic is rendered once per entry. Each value is either a preset name ('detailed', 'github-actions'), a custom template string containing at least one known placeholder ({file}, {line}, {col}, {endLine}, {endCol}, {severity}, {severityCode}, {code}, {message}, {source}), or an object with explicit `type`. Defaults to 'detailed'.",
|
|
352
|
+
"default": "detailed",
|
|
353
|
+
"oneOf": [
|
|
354
|
+
{
|
|
355
|
+
"$ref": "#/definitions/diagnosticReporterValue"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"type": "array",
|
|
359
|
+
"items": {
|
|
360
|
+
"$ref": "#/definitions/diagnosticReporterValue"
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
},
|
|
303
365
|
"allowBrighterScriptInBrightScript": {
|
|
304
366
|
"description": "Allow brighterscript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled.",
|
|
305
367
|
"type": "boolean",
|
package/dist/BsConfig.d.ts
CHANGED
|
@@ -129,6 +129,28 @@ export interface BsConfig {
|
|
|
129
129
|
* Specify what diagnostic types should be printed to the console. Defaults to 'warn'
|
|
130
130
|
*/
|
|
131
131
|
diagnosticLevel?: 'info' | 'hint' | 'warn' | 'error';
|
|
132
|
+
/**
|
|
133
|
+
* Specify how diagnostics should be reported to the console.
|
|
134
|
+
* Accepts a single value or an array. When given an array, each diagnostic is rendered
|
|
135
|
+
* once per entry (so you can, for example, get both detailed terminal output and
|
|
136
|
+
* github-actions PR annotations from a single run).
|
|
137
|
+
*
|
|
138
|
+
* Each value may be a preset name ('detailed', 'github-actions'), a custom template string
|
|
139
|
+
* (any string containing a `{` placeholder), or an object with explicit `type`.
|
|
140
|
+
*
|
|
141
|
+
* Custom templates support the following placeholders, replaced per diagnostic:
|
|
142
|
+
* {file}, {line}, {col}, {endLine}, {endCol}, {severity}, {code}, {message}, {source}
|
|
143
|
+
*
|
|
144
|
+
* Examples:
|
|
145
|
+
* "detailed"
|
|
146
|
+
* "github-actions"
|
|
147
|
+
* "{file}:{line}:{col} {severity} {code}: {message}"
|
|
148
|
+
* { type: "custom", format: "{file}:{line}: {message}" }
|
|
149
|
+
* ["detailed", "github-actions"]
|
|
150
|
+
*
|
|
151
|
+
* @default "detailed"
|
|
152
|
+
*/
|
|
153
|
+
diagnosticReporters?: DiagnosticReporter | DiagnosticReporter[];
|
|
132
154
|
/**
|
|
133
155
|
* A list of scripts or modules to add extra diagnostics or transform the AST
|
|
134
156
|
*/
|
|
@@ -221,7 +243,40 @@ export interface BsConfig {
|
|
|
221
243
|
* Should be a semver-compatible string (e.g. "11.0.0").
|
|
222
244
|
*/
|
|
223
245
|
minFirmwareVersion?: string;
|
|
246
|
+
/**
|
|
247
|
+
* When set to false, validation is skipped entirely. This can speed up builds when diagnostics
|
|
248
|
+
* are not needed (e.g. when using the VSCode extension which already surfaces diagnostics in the
|
|
249
|
+
* editor). Note that skipping validation may cause transpilation to fail or produce incorrect
|
|
250
|
+
* output if the project contains errors that would normally be caught during validation.
|
|
251
|
+
* @default true
|
|
252
|
+
*/
|
|
253
|
+
validate?: boolean;
|
|
224
254
|
}
|
|
225
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Discriminated union describing how diagnostics are rendered to the console.
|
|
257
|
+
* - String shorthand: a preset name ('detailed' | 'github-actions') or a template string
|
|
258
|
+
* (any string containing a `{` is treated as a custom template).
|
|
259
|
+
* - Object form: explicit `type` so config files can stay strictly typed.
|
|
260
|
+
*/
|
|
261
|
+
export declare type DiagnosticReporter = 'detailed' | 'github-actions' | (string & {}) | {
|
|
262
|
+
type: 'detailed';
|
|
263
|
+
} | {
|
|
264
|
+
type: 'github-actions';
|
|
265
|
+
} | {
|
|
266
|
+
type: 'custom';
|
|
267
|
+
format: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Object form of `DiagnosticReporter` after string shorthand has been resolved.
|
|
271
|
+
*/
|
|
272
|
+
export declare type NormalizedDiagnosticReporter = {
|
|
273
|
+
type: 'detailed';
|
|
274
|
+
} | {
|
|
275
|
+
type: 'github-actions';
|
|
276
|
+
} | {
|
|
277
|
+
type: 'custom';
|
|
278
|
+
format: string;
|
|
279
|
+
};
|
|
280
|
+
declare type OptionalBsConfigFields = '_ancestors' | 'sourceRoot' | 'project' | 'manifest' | 'noProject' | 'extends' | 'host' | 'password' | 'require' | 'stagingFolderPath' | 'diagnosticLevel' | 'rootDir' | 'stagingDir' | 'minFirmwareVersion' | 'diagnosticReporters';
|
|
226
281
|
export declare type FinalizedBsConfig = Omit<Required<BsConfig>, OptionalBsConfigFields> & Pick<BsConfig, OptionalBsConfigFields>;
|
|
227
282
|
export {};
|
|
@@ -13,10 +13,6 @@ export declare class CommentFlagProcessor {
|
|
|
13
13
|
* Valid diagnostic codes. Codes NOT in this list will be flagged
|
|
14
14
|
*/
|
|
15
15
|
diagnosticCodes: DiagnosticCode[];
|
|
16
|
-
/**
|
|
17
|
-
* Diagnostic codes to never filter (these codes will always be flagged)
|
|
18
|
-
*/
|
|
19
|
-
ignoreDiagnosticCodes: DiagnosticCode[];
|
|
20
16
|
constructor(
|
|
21
17
|
/**
|
|
22
18
|
* The file this processor applies to
|
|
@@ -29,11 +25,7 @@ export declare class CommentFlagProcessor {
|
|
|
29
25
|
/**
|
|
30
26
|
* Valid diagnostic codes. Codes NOT in this list will be flagged
|
|
31
27
|
*/
|
|
32
|
-
diagnosticCodes?: DiagnosticCode[]
|
|
33
|
-
/**
|
|
34
|
-
* Diagnostic codes to never filter (these codes will always be flagged)
|
|
35
|
-
*/
|
|
36
|
-
ignoreDiagnosticCodes?: DiagnosticCode[]);
|
|
28
|
+
diagnosticCodes?: DiagnosticCode[]);
|
|
37
29
|
/**
|
|
38
30
|
* List of comment flags generated during processing
|
|
39
31
|
*/
|
|
@@ -43,12 +35,24 @@ export declare class CommentFlagProcessor {
|
|
|
43
35
|
*/
|
|
44
36
|
diagnostics: BsDiagnostic[];
|
|
45
37
|
/**
|
|
46
|
-
*
|
|
38
|
+
* Block-level `bs:disable` / `bs:enable` directives, recorded in source order
|
|
39
|
+
* by `tryAdd` and resolved into `CommentFlag`s by `finalize()`.
|
|
47
40
|
*/
|
|
48
|
-
|
|
41
|
+
private blockDirectives;
|
|
49
42
|
tryAdd(text: string, range: Range): void;
|
|
50
43
|
/**
|
|
51
|
-
*
|
|
44
|
+
* Resolve any pending `bs:disable` / `bs:enable` block directives into `CommentFlag`s.
|
|
45
|
+
* Must be called after the file's comment tokens have been fed through `tryAdd`.
|
|
46
|
+
*/
|
|
47
|
+
finalize(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a list of `{ code, range }` tokens into validated diagnostic codes.
|
|
50
|
+
* Pushes diagnostics for any unknown numeric codes. Returns `null` when no codes were specified
|
|
51
|
+
* (i.e. a bare `bs:disable` / `bs:enable`), and an array otherwise.
|
|
52
|
+
*/
|
|
53
|
+
private collectCodes;
|
|
54
|
+
/**
|
|
55
|
+
* Small tokenizer for `bs:` directive comments.
|
|
52
56
|
*/
|
|
53
57
|
private tokenize;
|
|
54
58
|
/**
|
|
@@ -16,15 +16,10 @@ class CommentFlagProcessor {
|
|
|
16
16
|
/**
|
|
17
17
|
* Valid diagnostic codes. Codes NOT in this list will be flagged
|
|
18
18
|
*/
|
|
19
|
-
diagnosticCodes = []
|
|
20
|
-
/**
|
|
21
|
-
* Diagnostic codes to never filter (these codes will always be flagged)
|
|
22
|
-
*/
|
|
23
|
-
ignoreDiagnosticCodes = []) {
|
|
19
|
+
diagnosticCodes = []) {
|
|
24
20
|
this.file = file;
|
|
25
21
|
this.commentStarters = commentStarters;
|
|
26
22
|
this.diagnosticCodes = diagnosticCodes;
|
|
27
|
-
this.ignoreDiagnosticCodes = ignoreDiagnosticCodes;
|
|
28
23
|
/**
|
|
29
24
|
* List of comment flags generated during processing
|
|
30
25
|
*/
|
|
@@ -33,73 +28,149 @@ class CommentFlagProcessor {
|
|
|
33
28
|
* List of diagnostics generated during processing
|
|
34
29
|
*/
|
|
35
30
|
this.diagnostics = [];
|
|
36
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Block-level `bs:disable` / `bs:enable` directives, recorded in source order
|
|
33
|
+
* by `tryAdd` and resolved into `CommentFlag`s by `finalize()`.
|
|
34
|
+
*/
|
|
35
|
+
this.blockDirectives = [];
|
|
37
36
|
}
|
|
38
37
|
tryAdd(text, range) {
|
|
39
|
-
var _a, _b;
|
|
40
38
|
const tokenized = this.tokenize(text, range);
|
|
41
39
|
if (!tokenized) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
if (tokenized.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
//queue block directives with their raw code tokens; finalize() validates and resolves them
|
|
43
|
+
if (tokenized.directive === 'disable' || tokenized.directive === 'enable') {
|
|
44
|
+
this.blockDirectives.push({
|
|
45
|
+
kind: tokenized.directive,
|
|
46
|
+
rawCodes: tokenized.codes,
|
|
47
|
+
range: range
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
//line-level directives emit a flag inline
|
|
52
|
+
const affectedRange = tokenized.directive === 'line'
|
|
53
|
+
? util_1.util.createRange(range.start.line, 0, range.start.line, range.start.character)
|
|
54
|
+
: util_1.util.createRange(range.start.line + 1, 0, range.start.line + 1, Number.MAX_SAFE_INTEGER);
|
|
54
55
|
if (tokenized.codes.length === 0) {
|
|
55
|
-
|
|
56
|
+
//bare `bs:disable-line` / `bs:disable-next-line` suppresses everything
|
|
57
|
+
this.commentFlags.push({
|
|
56
58
|
file: this.file,
|
|
57
|
-
//null means all codes
|
|
58
59
|
codes: null,
|
|
59
60
|
range: range,
|
|
60
61
|
affectedRange: affectedRange
|
|
61
|
-
};
|
|
62
|
-
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
const codes = this.collectCodes(tokenized.codes);
|
|
66
|
+
if (codes && codes.length > 0) {
|
|
67
|
+
this.commentFlags.push({
|
|
68
|
+
file: this.file,
|
|
69
|
+
codes: codes,
|
|
70
|
+
range: range,
|
|
71
|
+
affectedRange: affectedRange
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolve any pending `bs:disable` / `bs:enable` block directives into `CommentFlag`s.
|
|
77
|
+
* Must be called after the file's comment tokens have been fed through `tryAdd`.
|
|
78
|
+
*/
|
|
79
|
+
finalize() {
|
|
80
|
+
if (this.blockDirectives.length === 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
//state across the file: which codes are suppressed within the current block
|
|
84
|
+
let allSuppressed = false;
|
|
85
|
+
const carveOuts = new Set();
|
|
86
|
+
for (let i = 0; i < this.blockDirectives.length; i++) {
|
|
87
|
+
const directive = this.blockDirectives[i];
|
|
88
|
+
const codes = this.collectCodes(directive.rawCodes);
|
|
89
|
+
//apply this directive to the running state
|
|
90
|
+
if (codes === null) {
|
|
91
|
+
//bare `bs:disable` / `bs:enable` resets state
|
|
92
|
+
allSuppressed = directive.kind === 'disable';
|
|
93
|
+
carveOuts.clear();
|
|
94
|
+
}
|
|
95
|
+
else if (directive.kind === 'disable') {
|
|
96
|
+
//in disable-all mode, "disable: X" cancels a prior carve-out for X
|
|
97
|
+
//in enable-all mode, "disable: X" adds X to the suppressed set
|
|
98
|
+
for (const code of codes) {
|
|
99
|
+
if (allSuppressed) {
|
|
100
|
+
carveOuts.delete(code);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
carveOuts.add(code);
|
|
104
|
+
}
|
|
76
105
|
}
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
//'enable' with specific codes does the opposite of the disable branch above
|
|
109
|
+
for (const code of codes) {
|
|
110
|
+
if (allSuppressed) {
|
|
111
|
+
carveOuts.add(code);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
carveOuts.delete(code);
|
|
115
|
+
}
|
|
79
116
|
}
|
|
80
117
|
}
|
|
81
|
-
|
|
82
|
-
|
|
118
|
+
//affectedRange runs from the line after this directive to just before the next block directive (or EOF)
|
|
119
|
+
const next = this.blockDirectives[i + 1];
|
|
120
|
+
const startLine = directive.range.start.line + 1;
|
|
121
|
+
const endLine = next ? next.range.start.line - 1 : Number.MAX_SAFE_INTEGER;
|
|
122
|
+
if (endLine < startLine) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const affectedRange = util_1.util.createRange(startLine, 0, endLine, Number.MAX_SAFE_INTEGER);
|
|
126
|
+
//emit a flag only when the current state actually suppresses something
|
|
127
|
+
if (allSuppressed) {
|
|
128
|
+
this.commentFlags.push({
|
|
83
129
|
file: this.file,
|
|
84
|
-
codes:
|
|
85
|
-
|
|
130
|
+
codes: null,
|
|
131
|
+
enableCodes: carveOuts.size > 0 ? [...carveOuts] : undefined,
|
|
132
|
+
range: directive.range,
|
|
86
133
|
affectedRange: affectedRange
|
|
87
|
-
};
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else if (carveOuts.size > 0) {
|
|
137
|
+
this.commentFlags.push({
|
|
138
|
+
file: this.file,
|
|
139
|
+
codes: [...carveOuts],
|
|
140
|
+
range: directive.range,
|
|
141
|
+
affectedRange: affectedRange
|
|
142
|
+
});
|
|
88
143
|
}
|
|
89
144
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve a list of `{ code, range }` tokens into validated diagnostic codes.
|
|
148
|
+
* Pushes diagnostics for any unknown numeric codes. Returns `null` when no codes were specified
|
|
149
|
+
* (i.e. a bare `bs:disable` / `bs:enable`), and an array otherwise.
|
|
150
|
+
*/
|
|
151
|
+
collectCodes(rawCodes) {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
if (rawCodes.length === 0) {
|
|
154
|
+
return null;
|
|
99
155
|
}
|
|
156
|
+
const codes = [];
|
|
157
|
+
for (const codeToken of rawCodes) {
|
|
158
|
+
const codeInt = parseInt(codeToken.code);
|
|
159
|
+
if (isNaN(codeInt)) {
|
|
160
|
+
//plugin-contributed or non-numeric code
|
|
161
|
+
codes.push((_b = (_a = codeToken.code) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.toLowerCase());
|
|
162
|
+
}
|
|
163
|
+
else if (this.diagnosticCodes.includes(codeInt)) {
|
|
164
|
+
codes.push(codeInt);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownDiagnosticCode(codeInt)), { file: this.file, range: codeToken.range }));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return codes;
|
|
100
171
|
}
|
|
101
172
|
/**
|
|
102
|
-
* Small tokenizer for bs
|
|
173
|
+
* Small tokenizer for `bs:` directive comments.
|
|
103
174
|
*/
|
|
104
175
|
tokenize(text, range) {
|
|
105
176
|
let lowerText = text.toLowerCase();
|
|
@@ -113,20 +184,31 @@ class CommentFlagProcessor {
|
|
|
113
184
|
break;
|
|
114
185
|
}
|
|
115
186
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let len = lowerText.length;
|
|
187
|
+
//trim leading whitespace
|
|
188
|
+
const len = lowerText.length;
|
|
119
189
|
lowerText = lowerText.trimLeft();
|
|
120
190
|
offset += len - lowerText.length;
|
|
191
|
+
//match longest-prefix first so `bs:disable-line` doesn't get parsed as `bs:disable`
|
|
192
|
+
let directive;
|
|
121
193
|
if (lowerText.startsWith('bs:disable-line')) {
|
|
122
194
|
lowerText = lowerText.substring('bs:disable-line'.length);
|
|
123
195
|
offset += 'bs:disable-line'.length;
|
|
124
|
-
|
|
196
|
+
directive = 'line';
|
|
125
197
|
}
|
|
126
198
|
else if (lowerText.startsWith('bs:disable-next-line')) {
|
|
127
199
|
lowerText = lowerText.substring('bs:disable-next-line'.length);
|
|
128
200
|
offset += 'bs:disable-next-line'.length;
|
|
129
|
-
|
|
201
|
+
directive = 'next-line';
|
|
202
|
+
}
|
|
203
|
+
else if (lowerText.startsWith('bs:disable')) {
|
|
204
|
+
lowerText = lowerText.substring('bs:disable'.length);
|
|
205
|
+
offset += 'bs:disable'.length;
|
|
206
|
+
directive = 'disable';
|
|
207
|
+
}
|
|
208
|
+
else if (lowerText.startsWith('bs:enable')) {
|
|
209
|
+
lowerText = lowerText.substring('bs:enable'.length);
|
|
210
|
+
offset += 'bs:enable'.length;
|
|
211
|
+
directive = 'enable';
|
|
130
212
|
}
|
|
131
213
|
else {
|
|
132
214
|
return null;
|
|
@@ -136,9 +218,9 @@ class CommentFlagProcessor {
|
|
|
136
218
|
lowerText = lowerText.substring(1);
|
|
137
219
|
offset += 1;
|
|
138
220
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for (
|
|
221
|
+
const items = this.tokenizeByWhitespace(lowerText);
|
|
222
|
+
const codes = [];
|
|
223
|
+
for (const item of items) {
|
|
142
224
|
codes.push({
|
|
143
225
|
code: item.text,
|
|
144
226
|
range: util_1.util.createRange(range.start.line, range.start.character + offset + item.startIndex, range.start.line, range.start.character + offset + item.startIndex + item.text.length)
|
|
@@ -146,7 +228,7 @@ class CommentFlagProcessor {
|
|
|
146
228
|
}
|
|
147
229
|
return {
|
|
148
230
|
commentTokenText: commentTokenText,
|
|
149
|
-
|
|
231
|
+
directive: directive,
|
|
150
232
|
codes: codes
|
|
151
233
|
};
|
|
152
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentFlagProcessor.js","sourceRoot":"","sources":["../src/CommentFlagProcessor.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAE1D,iCAA8B;AAE9B,MAAa,oBAAoB;IAC7B;IACI;;OAEG;IACI,IAAa;IACpB;;OAEG;IACI,kBAAkB,EAAc;IACvC;;OAEG;IACI,kBAAkB,EAAsB;
|
|
1
|
+
{"version":3,"file":"CommentFlagPro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AiB,IAAI,CAAC;QAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,sBAAsB;YACtB,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,EAAE;gBAC/B,IAAI,YAAY,EAAE;oBACd,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;oBAC1B,YAAY,GAAG,IAAI,CAAC;iBACvB;gBAED,uBAAuB;aAC1B;iBAAM;gBACH,IAAI,CAAC,YAAY,EAAE;oBACf,YAAY,GAAG;wBACX,UAAU,EAAE,CAAC;wBACb,IAAI,EAAE,EAAE;qBACX,CAAC;iBACL;gBACD,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC;aAC7B;SACJ;QACD,IAAI,YAAY,EAAE;YACd,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxRD,oDAwRC"}
|
|
@@ -762,8 +762,27 @@ export declare let DiagnosticMessages: {
|
|
|
762
762
|
code: number;
|
|
763
763
|
severity: 1;
|
|
764
764
|
};
|
|
765
|
+
reservedBuiltinUsedAsValue: (name: string) => {
|
|
766
|
+
message: string;
|
|
767
|
+
code: number;
|
|
768
|
+
severity: 1;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Emitted when a block recovers from a wrong terminator (e.g. `while ... next` or `for ... end while`).
|
|
772
|
+
* `expected` lists the legal terminators in preferred-first order; `found` is the actual text.
|
|
773
|
+
* Quick fixes consume the structured `data` to build "Convert '<found>' to '<expected[i]>'" actions.
|
|
774
|
+
*/
|
|
775
|
+
mismatchedEndingToken: (expected?: string[], found?: string) => {
|
|
776
|
+
message: string;
|
|
777
|
+
code: number;
|
|
778
|
+
data: {
|
|
779
|
+
expected: string[];
|
|
780
|
+
found: string;
|
|
781
|
+
};
|
|
782
|
+
severity: 1;
|
|
783
|
+
};
|
|
765
784
|
};
|
|
766
|
-
export declare const DiagnosticCodeMap: Record<"genericParserMessage" | "cannotFindName" | "mismatchArgumentCount" | "duplicateFunctionImplementation" | "referencedFileDoesNotExist" | "xmlComponentMissingComponentDeclaration" | "xmlComponentMissingNameAttribute" | "xmlComponentMissingExtendsAttribute" | "xmlGenericParseError" | "unnecessaryScriptImportInChildFromParent" | "overridesAncestorFunction" | "localVarFunctionShadowsParentFunction" | "scriptImportCaseMismatch" | "fileNotReferencedByAnyOtherFile" | "unknownDiagnosticCode" | "scriptSrcCannotBeEmpty" | "expectedIdentifierAfterKeyword" | "missingCallableKeyword" | "expectedValidTypeToFollowAsKeyword" | "bsFeatureNotSupportedInBrsFiles" | "brsConfigJsonIsDeprecated" | "bsConfigJsonHasSyntaxErrors" | "namespacedClassCannotShareNamewithNonNamespacedClass" | "cannotUseOverrideKeywordOnConstructorFunction" | "importStatementMustBeDeclaredAtTopOfFile" | "methodDoesNotExistOnType" | "duplicateIdentifier" | "missingOverrideKeyword" | "duplicateClassDeclaration" | "classCouldNotBeFound" | "expectedClassFieldIdentifier" | "expressionIsNotConstructable" | "expectedKeyword" | "expectedLeftParenAfterCallable" | "expectedNameAfterCallableKeyword" | "expectedLeftParenAfterCallableName" | "tooManyCallableParameters" | "invalidFunctionReturnType" | "requiredParameterMayNotFollowOptionalParameter" | "expectedNewlineOrColon" | "functionNameCannotEndWithTypeDesignator" | "callableBlockMissingEndKeyword" | "mismatchedEndCallableKeyword" | "expectedParameterNameButFound" | "functionParameterTypeIsInvalid" | "cannotUseReservedWordAsIdentifier" | "expectedOperatorAfterIdentifier" | "expectedInlineIfStatement" | "expectedFinalNewline" | "couldNotFindMatchingEndKeyword" | "expectedCatchBlockInTryCatch" | "expectedEndForOrNextToTerminateForLoop" | "expectedInAfterForEach" | "expectedExpressionAfterForEachIn" | "unexpectedColonBeforeIfStatement" | "expectedStringLiteralAfterKeyword" | "keywordMustBeDeclaredAtRootLevel" | "libraryStatementMustBeDeclaredAtTopOfFile" | "expectedEndIfElseIfOrElseToTerminateThenBlock" | "expectedEndTryToTerminateTryCatch" | "expectedEndIfToCloseIfStatement" | "expectedStatementToFollowConditionalCondition" | "expectedStatementToFollowElse" | "consecutiveIncrementDecrementOperatorsAreNotAllowed" | "incrementDecrementOperatorsAreNotAllowedAsResultOfFunctionCall" | "xmlUnexpectedTag" | "expectedStatementOrFunctionCallButReceivedExpression" | "xmlFunctionNotFound" | "xmlInvalidFieldType" | "xmlUnexpectedChildren" | "xmlTagMissingAttribute" | "expectedLabelIdentifierAfterGotoKeyword" | "expectedRightSquareBraceAfterArrayOrObjectIndex" | "expectedPropertyNameAfterPeriod" | "tooManyCallableArguments" | "expectedRightParenAfterFunctionCallArguments" | "unmatchedLeftParenAfterExpression" | "unmatchedLeftSquareBraceAfterArrayLiteral" | "unexpectedAAKey" | "expectedColonBetweenAAKeyAndvalue" | "unmatchedLeftCurlyAfterAALiteral" | "unexpectedToken" | "unexpectedCharacter" | "unterminatedStringAtEndOfLine" | "unterminatedStringAtEndOfFile" | "fractionalHexLiteralsAreNotSupported" | "unexpectedConditionalCompilationString" | "duplicateConstDeclaration" | "constAliasDoesNotExist" | "invalidHashConstValue" | "referencedConstDoesNotExist" | "invalidHashIfValue" | "hashError" | "expectedEqualAfterConstName" | "expectedHashElseIfToCloseHashIf" | "constNameCannotBeReservedWord" | "expectedIdentifier" | "expectedAttributeNameAfterAtSymbol" | "childFieldTypeNotAssignableToBaseProperty" | "classChildMemberDifferentMemberTypeThanAncestor" | "classConstructorMissingSuperCall" | "classConstructorIllegalUseOfMBeforeSuperCall" | "classFieldCannotBeOverridden" | "unusedAnnotation" | "localVarShadowedByScopedFunction" | "scopeFunctionShadowedByBuiltInFunction" | "localVarSameNameAsClass" | "unnecessaryCodebehindScriptImport" | "expectedOpenParenToFollowCallfuncIdentifier" | "expectedToken" | "parameterMayNotHaveSameNameAsNamespace" | "variableMayNotHaveSameNameAsNamespace" | "unterminatedTemplateStringAtEndOfFile" | "unterminatedTemplateExpression" | "duplicateComponentName" | "functionCannotHaveSameNameAsClass" | "missingExceptionVarToFollowCatch" | "missingExceptionExpressionAfterThrowKeyword" | "missingLeftSquareBracketAfterDimIdentifier" | "missingRightSquareBracketAfterDimIdentifier" | "missingExpressionsInDimStatement" | "mismatchedOverriddenMemberVisibility" | "cannotFindType" | "enumValueMustBeType" | "enumValueIsRequired" | "unknownEnumValue" | "duplicateEnumDeclaration" | "unknownRoSGNode" | "unknownBrightScriptComponent" | "mismatchCreateObjectArgumentCount" | "deprecatedBrightScriptComponent" | "circularReferenceDetected" | "unexpectedStatementOutsideFunction" | "detectedTooDeepFileSource" | "illegalContinueStatement" | "keywordMustBeDeclaredAtNamespaceLevel" | "itemCannotBeUsedAsVariable" | "callfuncHasToManyArgs" | "noOptionalChainingInLeftHandSideOfAssignment" | "cannotFindFunction" | "voidFunctionMayNotReturnValue" | "nonVoidFunctionMustReturnValue" | "propAccessNotPermittedAfterFunctionCallInExpressionStatement" | "computedPropertyKeyMustBeConstantExpression" | "computedAAKeyMustBeStringExpression" | "featureRequiresMinFirmwareVersion", number>;
|
|
785
|
+
export declare const DiagnosticCodeMap: Record<"genericParserMessage" | "cannotFindName" | "mismatchArgumentCount" | "duplicateFunctionImplementation" | "referencedFileDoesNotExist" | "xmlComponentMissingComponentDeclaration" | "xmlComponentMissingNameAttribute" | "xmlComponentMissingExtendsAttribute" | "xmlGenericParseError" | "unnecessaryScriptImportInChildFromParent" | "overridesAncestorFunction" | "localVarFunctionShadowsParentFunction" | "scriptImportCaseMismatch" | "fileNotReferencedByAnyOtherFile" | "unknownDiagnosticCode" | "scriptSrcCannotBeEmpty" | "expectedIdentifierAfterKeyword" | "missingCallableKeyword" | "expectedValidTypeToFollowAsKeyword" | "bsFeatureNotSupportedInBrsFiles" | "brsConfigJsonIsDeprecated" | "bsConfigJsonHasSyntaxErrors" | "namespacedClassCannotShareNamewithNonNamespacedClass" | "cannotUseOverrideKeywordOnConstructorFunction" | "importStatementMustBeDeclaredAtTopOfFile" | "methodDoesNotExistOnType" | "duplicateIdentifier" | "missingOverrideKeyword" | "duplicateClassDeclaration" | "classCouldNotBeFound" | "expectedClassFieldIdentifier" | "expressionIsNotConstructable" | "expectedKeyword" | "expectedLeftParenAfterCallable" | "expectedNameAfterCallableKeyword" | "expectedLeftParenAfterCallableName" | "tooManyCallableParameters" | "invalidFunctionReturnType" | "requiredParameterMayNotFollowOptionalParameter" | "expectedNewlineOrColon" | "functionNameCannotEndWithTypeDesignator" | "callableBlockMissingEndKeyword" | "mismatchedEndCallableKeyword" | "expectedParameterNameButFound" | "functionParameterTypeIsInvalid" | "cannotUseReservedWordAsIdentifier" | "expectedOperatorAfterIdentifier" | "expectedInlineIfStatement" | "expectedFinalNewline" | "couldNotFindMatchingEndKeyword" | "expectedCatchBlockInTryCatch" | "expectedEndForOrNextToTerminateForLoop" | "expectedInAfterForEach" | "expectedExpressionAfterForEachIn" | "unexpectedColonBeforeIfStatement" | "expectedStringLiteralAfterKeyword" | "keywordMustBeDeclaredAtRootLevel" | "libraryStatementMustBeDeclaredAtTopOfFile" | "expectedEndIfElseIfOrElseToTerminateThenBlock" | "expectedEndTryToTerminateTryCatch" | "expectedEndIfToCloseIfStatement" | "expectedStatementToFollowConditionalCondition" | "expectedStatementToFollowElse" | "consecutiveIncrementDecrementOperatorsAreNotAllowed" | "incrementDecrementOperatorsAreNotAllowedAsResultOfFunctionCall" | "xmlUnexpectedTag" | "expectedStatementOrFunctionCallButReceivedExpression" | "xmlFunctionNotFound" | "xmlInvalidFieldType" | "xmlUnexpectedChildren" | "xmlTagMissingAttribute" | "expectedLabelIdentifierAfterGotoKeyword" | "expectedRightSquareBraceAfterArrayOrObjectIndex" | "expectedPropertyNameAfterPeriod" | "tooManyCallableArguments" | "expectedRightParenAfterFunctionCallArguments" | "unmatchedLeftParenAfterExpression" | "unmatchedLeftSquareBraceAfterArrayLiteral" | "unexpectedAAKey" | "expectedColonBetweenAAKeyAndvalue" | "unmatchedLeftCurlyAfterAALiteral" | "unexpectedToken" | "unexpectedCharacter" | "unterminatedStringAtEndOfLine" | "unterminatedStringAtEndOfFile" | "fractionalHexLiteralsAreNotSupported" | "unexpectedConditionalCompilationString" | "duplicateConstDeclaration" | "constAliasDoesNotExist" | "invalidHashConstValue" | "referencedConstDoesNotExist" | "invalidHashIfValue" | "hashError" | "expectedEqualAfterConstName" | "expectedHashElseIfToCloseHashIf" | "constNameCannotBeReservedWord" | "expectedIdentifier" | "expectedAttributeNameAfterAtSymbol" | "childFieldTypeNotAssignableToBaseProperty" | "classChildMemberDifferentMemberTypeThanAncestor" | "classConstructorMissingSuperCall" | "classConstructorIllegalUseOfMBeforeSuperCall" | "classFieldCannotBeOverridden" | "unusedAnnotation" | "localVarShadowedByScopedFunction" | "scopeFunctionShadowedByBuiltInFunction" | "localVarSameNameAsClass" | "unnecessaryCodebehindScriptImport" | "expectedOpenParenToFollowCallfuncIdentifier" | "expectedToken" | "parameterMayNotHaveSameNameAsNamespace" | "variableMayNotHaveSameNameAsNamespace" | "unterminatedTemplateStringAtEndOfFile" | "unterminatedTemplateExpression" | "duplicateComponentName" | "functionCannotHaveSameNameAsClass" | "missingExceptionVarToFollowCatch" | "missingExceptionExpressionAfterThrowKeyword" | "missingLeftSquareBracketAfterDimIdentifier" | "missingRightSquareBracketAfterDimIdentifier" | "missingExpressionsInDimStatement" | "mismatchedOverriddenMemberVisibility" | "cannotFindType" | "enumValueMustBeType" | "enumValueIsRequired" | "unknownEnumValue" | "duplicateEnumDeclaration" | "unknownRoSGNode" | "unknownBrightScriptComponent" | "mismatchCreateObjectArgumentCount" | "deprecatedBrightScriptComponent" | "circularReferenceDetected" | "unexpectedStatementOutsideFunction" | "detectedTooDeepFileSource" | "illegalContinueStatement" | "keywordMustBeDeclaredAtNamespaceLevel" | "itemCannotBeUsedAsVariable" | "callfuncHasToManyArgs" | "noOptionalChainingInLeftHandSideOfAssignment" | "cannotFindFunction" | "voidFunctionMayNotReturnValue" | "nonVoidFunctionMustReturnValue" | "propAccessNotPermittedAfterFunctionCallInExpressionStatement" | "computedPropertyKeyMustBeConstantExpression" | "computedAAKeyMustBeStringExpression" | "featureRequiresMinFirmwareVersion" | "reservedBuiltinUsedAsValue" | "mismatchedEndingToken", number>;
|
|
767
786
|
export declare let diagnosticCodes: number[];
|
|
768
787
|
export interface DiagnosticInfo {
|
|
769
788
|
message: string;
|
|
@@ -776,3 +795,10 @@ export interface DiagnosticInfo {
|
|
|
776
795
|
* DiagnosticMessages-like object in order to get the same type support
|
|
777
796
|
*/
|
|
778
797
|
export declare type DiagnosticMessageType<K extends keyof D, D extends Record<string, (...args: any) => any> = typeof DiagnosticMessages> = ReturnType<D[K]> & Pick<BsDiagnostic, 'range' | 'file' | 'relatedInformation' | 'tags'>;
|
|
798
|
+
/**
|
|
799
|
+
* Refines a diagnostic to its concrete `DiagnosticMessageType<K>` shape (including the typed `data`
|
|
800
|
+
* payload) when its code matches `DiagnosticCodeMap[key]`.
|
|
801
|
+
*/
|
|
802
|
+
export declare function isDiagnosticOfType<K extends keyof typeof DiagnosticMessages>(diagnostic: {
|
|
803
|
+
code?: number | string;
|
|
804
|
+
}, key: K): diagnostic is DiagnosticMessageType<K>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diagnosticCodes = exports.DiagnosticCodeMap = exports.DiagnosticMessages = void 0;
|
|
3
|
+
exports.isDiagnosticOfType = exports.diagnosticCodes = exports.DiagnosticCodeMap = exports.DiagnosticMessages = void 0;
|
|
4
4
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
5
|
/**
|
|
6
6
|
* An object that keeps track of all possible error messages.
|
|
@@ -769,7 +769,29 @@ exports.DiagnosticMessages = {
|
|
|
769
769
|
message: `'${featureName}' requires Roku firmware version ${minimumVersion} or higher (current target is ${configuredVersion})`,
|
|
770
770
|
code: 1146,
|
|
771
771
|
severity: vscode_languageserver_1.DiagnosticSeverity.Error
|
|
772
|
-
})
|
|
772
|
+
}),
|
|
773
|
+
reservedBuiltinUsedAsValue: (name) => ({
|
|
774
|
+
message: `'${name}' is a reserved builtin and can only be used as a function call (e.g. '${name}(...)')`,
|
|
775
|
+
code: 1147,
|
|
776
|
+
severity: vscode_languageserver_1.DiagnosticSeverity.Error
|
|
777
|
+
}),
|
|
778
|
+
/**
|
|
779
|
+
* Emitted when a block recovers from a wrong terminator (e.g. `while ... next` or `for ... end while`).
|
|
780
|
+
* `expected` lists the legal terminators in preferred-first order; `found` is the actual text.
|
|
781
|
+
* Quick fixes consume the structured `data` to build "Convert '<found>' to '<expected[i]>'" actions.
|
|
782
|
+
*/
|
|
783
|
+
mismatchedEndingToken: (expected = [], found = '') => {
|
|
784
|
+
const expectedList = Array.isArray(expected) ? expected : [];
|
|
785
|
+
return {
|
|
786
|
+
message: `Expected ${expectedList.map(text => `'${text}'`).join(' or ')} but found '${found}'`,
|
|
787
|
+
code: 1148,
|
|
788
|
+
data: {
|
|
789
|
+
expected: expectedList,
|
|
790
|
+
found: found
|
|
791
|
+
},
|
|
792
|
+
severity: vscode_languageserver_1.DiagnosticSeverity.Error
|
|
793
|
+
};
|
|
794
|
+
}
|
|
773
795
|
};
|
|
774
796
|
exports.DiagnosticCodeMap = {};
|
|
775
797
|
exports.diagnosticCodes = [];
|
|
@@ -777,4 +799,12 @@ for (let key in exports.DiagnosticMessages) {
|
|
|
777
799
|
exports.diagnosticCodes.push(exports.DiagnosticMessages[key]().code);
|
|
778
800
|
exports.DiagnosticCodeMap[key] = exports.DiagnosticMessages[key]().code;
|
|
779
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Refines a diagnostic to its concrete `DiagnosticMessageType<K>` shape (including the typed `data`
|
|
804
|
+
* payload) when its code matches `DiagnosticCodeMap[key]`.
|
|
805
|
+
*/
|
|
806
|
+
function isDiagnosticOfType(diagnostic, key) {
|
|
807
|
+
return diagnostic.code === exports.DiagnosticCodeMap[key];
|
|
808
|
+
}
|
|
809
|
+
exports.isDiagnosticOfType = isDiagnosticOfType;
|
|
780
810
|
//# sourceMappingURL=DiagnosticMessages.js.map
|