@idlizer/core 2.1.9-arktscgen-9 → 2.1.10-arktscgen-2
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/build/lib/src/LanguageWriters/ArgConvertors.d.ts +9 -0
- package/build/lib/src/LanguageWriters/ArgConvertors.js +28 -1
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +1 -1
- package/build/lib/src/config.d.ts +66 -0
- package/build/lib/src/config.js +2 -0
- package/build/lib/src/configDescriber.js +1 -1
- package/build/lib/src/diagnosticmessages.d.ts +18 -12
- package/build/lib/src/diagnosticmessages.js +22 -14
- package/build/lib/src/diagnostictypes.d.ts +3 -9
- package/build/lib/src/formatter.d.ts +2 -1
- package/build/lib/src/formatter.js +3 -3
- package/build/lib/src/from-idl/deserialize.js +138 -6
- package/build/lib/src/from-idl/parser.d.ts +99 -0
- package/build/lib/src/from-idl/parser.js +939 -0
- package/build/lib/src/idl.d.ts +12 -1
- package/build/lib/src/idl.js +5 -0
- package/build/lib/src/index.d.ts +1 -0
- package/build/lib/src/index.js +1 -0
- package/build/lib/src/peer-generation/LayoutManager.d.ts +1 -1
- package/build/lib/src/peer-generation/Materialized.d.ts +1 -1
- package/build/lib/src/peer-generation/Materialized.js +4 -4
- package/build/lib/src/peer-generation/PeerClass.d.ts +5 -0
- package/build/lib/src/peer-generation/PeerClass.js +2 -1
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +1 -0
- package/build/lib/src/peer-generation/PeerLibrary.js +8 -2
- package/build/lib/src/peer-generation/PeerMethod.d.ts +8 -2
- package/build/lib/src/peer-generation/PeerMethod.js +22 -4
- package/package.json +10 -3
|
@@ -2,20 +2,27 @@ import { MessageSeverity, DiagnosticMessage, Location, DiagnosticResults } from
|
|
|
2
2
|
/**
|
|
3
3
|
* Template for registering different kinds of messages
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class DiagnosticMessageGroup {
|
|
6
6
|
/**
|
|
7
7
|
* Index for DiagnosticMessageEntry by code
|
|
8
8
|
*/
|
|
9
|
-
static diagnosticMessageByCode: Map<
|
|
9
|
+
static diagnosticMessageByCode: Map<string, DiagnosticMessageGroup>;
|
|
10
|
+
/**
|
|
11
|
+
* Diagnostic results collected up until now
|
|
12
|
+
*/
|
|
10
13
|
static collectedResults: DiagnosticResults;
|
|
14
|
+
/**
|
|
15
|
+
* Generated diagnostic messages belonging to _any_ group
|
|
16
|
+
*/
|
|
17
|
+
static get allGroupsEntries(): DiagnosticMessage[];
|
|
11
18
|
/**
|
|
12
19
|
* Severity of the diagnostic.
|
|
13
20
|
*/
|
|
14
21
|
severity: MessageSeverity;
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
23
|
+
* String representing code of the diagnostic.
|
|
17
24
|
*/
|
|
18
|
-
code:
|
|
25
|
+
code: string;
|
|
19
26
|
/**
|
|
20
27
|
* Description of the diagnostic.
|
|
21
28
|
*/
|
|
@@ -32,14 +39,13 @@ export declare class DiagnosticMessageEntry {
|
|
|
32
39
|
* Template for additional parts
|
|
33
40
|
*/
|
|
34
41
|
additionalMessageTemplate: string;
|
|
35
|
-
constructor(severity: MessageSeverity, code:
|
|
42
|
+
constructor(severity: MessageSeverity, code: string, codeDescription: string, mainMessageTemplate?: string, additionalMessageTemplate?: string);
|
|
36
43
|
generateDiagnosticMessage(locations: Location[], mainMessage?: string, additionalMessage?: string): DiagnosticMessage;
|
|
37
|
-
reportDiagnosticMessage(locations: Location[], mainMessage?: string, additionalMessage?: string):
|
|
38
|
-
throwDiagnosticMessage(locations: Location[], mainMessage?: string, additionalMessage?: string):
|
|
39
|
-
static reportCatched(diagnosticMessage: DiagnosticMessage): void;
|
|
44
|
+
reportDiagnosticMessage(locations: Location[], mainMessage?: string, additionalMessage?: string): DiagnosticMessage;
|
|
45
|
+
throwDiagnosticMessage(locations: Location[], mainMessage?: string, additionalMessage?: string): never;
|
|
40
46
|
}
|
|
41
|
-
export declare const
|
|
42
|
-
export declare const
|
|
43
|
-
export declare const
|
|
44
|
-
export declare const
|
|
47
|
+
export declare const InternalFatal: DiagnosticMessageGroup;
|
|
48
|
+
export declare const LoadingFatal: DiagnosticMessageGroup;
|
|
49
|
+
export declare const ParsingFatal: DiagnosticMessageGroup;
|
|
50
|
+
export declare const ProcessingFatal: DiagnosticMessageGroup;
|
|
45
51
|
//# sourceMappingURL=diagnosticmessages.d.ts.map
|
|
@@ -16,7 +16,13 @@ import { DiagnosticException, DiagnosticResults } from "./diagnostictypes";
|
|
|
16
16
|
/**
|
|
17
17
|
* Template for registering different kinds of messages
|
|
18
18
|
*/
|
|
19
|
-
export class
|
|
19
|
+
export class DiagnosticMessageGroup {
|
|
20
|
+
/**
|
|
21
|
+
* Generated diagnostic messages belonging to _any_ group
|
|
22
|
+
*/
|
|
23
|
+
static get allGroupsEntries() {
|
|
24
|
+
return DiagnosticMessageGroup.collectedResults.entries;
|
|
25
|
+
}
|
|
20
26
|
constructor(severity, code, codeDescription, mainMessageTemplate, additionalMessageTemplate) {
|
|
21
27
|
this.severity = severity;
|
|
22
28
|
this.code = code;
|
|
@@ -24,10 +30,10 @@ export class DiagnosticMessageEntry {
|
|
|
24
30
|
// No cases of codeUri for now, can be embedded into codeDescription later if needed
|
|
25
31
|
this.mainMessageTemplate = mainMessageTemplate !== null && mainMessageTemplate !== void 0 ? mainMessageTemplate : codeDescription;
|
|
26
32
|
this.additionalMessageTemplate = additionalMessageTemplate !== null && additionalMessageTemplate !== void 0 ? additionalMessageTemplate : "See";
|
|
27
|
-
if (
|
|
33
|
+
if (DiagnosticMessageGroup.diagnosticMessageByCode.has(code)) {
|
|
28
34
|
throw new Error(`Duplicate message code ${code}`);
|
|
29
35
|
}
|
|
30
|
-
|
|
36
|
+
DiagnosticMessageGroup.diagnosticMessageByCode.set(code, this);
|
|
31
37
|
}
|
|
32
38
|
generateDiagnosticMessage(locations, mainMessage, additionalMessage) {
|
|
33
39
|
let msg = {
|
|
@@ -45,22 +51,24 @@ export class DiagnosticMessageEntry {
|
|
|
45
51
|
return msg;
|
|
46
52
|
}
|
|
47
53
|
reportDiagnosticMessage(locations, mainMessage, additionalMessage) {
|
|
48
|
-
|
|
54
|
+
const msg = this.generateDiagnosticMessage(locations, mainMessage, additionalMessage);
|
|
55
|
+
DiagnosticMessageGroup.collectedResults.push(msg);
|
|
56
|
+
return msg;
|
|
49
57
|
}
|
|
50
58
|
throwDiagnosticMessage(locations, mainMessage, additionalMessage) {
|
|
51
|
-
throw new DiagnosticException(this.
|
|
52
|
-
}
|
|
53
|
-
static reportCatched(diagnosticMessage) {
|
|
54
|
-
this.collectedResults.push(diagnosticMessage);
|
|
59
|
+
throw new DiagnosticException(this.reportDiagnosticMessage(locations, mainMessage, additionalMessage));
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
58
63
|
* Index for DiagnosticMessageEntry by code
|
|
59
64
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export const
|
|
65
|
+
DiagnosticMessageGroup.diagnosticMessageByCode = new Map();
|
|
66
|
+
/**
|
|
67
|
+
* Diagnostic results collected up until now
|
|
68
|
+
*/
|
|
69
|
+
DiagnosticMessageGroup.collectedResults = new DiagnosticResults();
|
|
70
|
+
export const InternalFatal = new DiagnosticMessageGroup("fatal", "InternalFatal", "Unknown error");
|
|
71
|
+
export const LoadingFatal = new DiagnosticMessageGroup("fatal", "LoadingFatal", "Loading error");
|
|
72
|
+
export const ParsingFatal = new DiagnosticMessageGroup("fatal", "ParsingFatal", "Parsing error");
|
|
73
|
+
export const ProcessingFatal = new DiagnosticMessageGroup("fatal", "ProcessingFatal", "Processing error");
|
|
66
74
|
//# sourceMappingURL=diagnosticmessages.js.map
|
|
@@ -21,9 +21,9 @@ export interface DiagnosticMessage {
|
|
|
21
21
|
*/
|
|
22
22
|
severity: MessageSeverity;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* String representing code of the diagnostic.
|
|
25
25
|
*/
|
|
26
|
-
code:
|
|
26
|
+
code: string;
|
|
27
27
|
/**
|
|
28
28
|
* Description of the diagnostic.
|
|
29
29
|
*/
|
|
@@ -115,16 +115,10 @@ export interface DiagnosticDiffComponent {
|
|
|
115
115
|
*/
|
|
116
116
|
replacement?: string;
|
|
117
117
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Receiver of diagnostic messages.
|
|
120
|
-
*/
|
|
121
|
-
export interface DiagnosticReceiver {
|
|
122
|
-
push(message: DiagnosticMessage): void;
|
|
123
|
-
}
|
|
124
118
|
/**
|
|
125
119
|
* Collection of diagnostic messages with calculated statistics.
|
|
126
120
|
*/
|
|
127
|
-
export declare class DiagnosticResults
|
|
121
|
+
export declare class DiagnosticResults {
|
|
128
122
|
entries: DiagnosticMessage[];
|
|
129
123
|
totals: Record<MessageSeverity, number>;
|
|
130
124
|
push(message: DiagnosticMessage): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { DiagnosticResults } from "./diagnostictypes";
|
|
1
|
+
import { DiagnosticResults, DiagnosticMessage } from "./diagnostictypes";
|
|
2
2
|
export declare function outputDiagnosticResultsFormatted(result: DiagnosticResults): void;
|
|
3
|
+
export declare function outputDiagnosticMessageFormatted(message: DiagnosticMessage): void;
|
|
3
4
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { MessageSeverityList } from "./diagnostictypes";
|
|
16
16
|
export function outputDiagnosticResultsFormatted(result) {
|
|
17
17
|
for (let message of result.entries) {
|
|
18
|
-
|
|
18
|
+
outputDiagnosticMessageFormatted(message);
|
|
19
19
|
}
|
|
20
20
|
outputReadableTotals(result);
|
|
21
21
|
}
|
|
@@ -62,11 +62,11 @@ function formatUnderline(indent, lines, lineNo, range, edgeChar, midChar, messag
|
|
|
62
62
|
}
|
|
63
63
|
return `${indent} | ${midChar.repeat(lines[lineNo - 1].length)}`;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
export function outputDiagnosticMessageFormatted(message) {
|
|
66
66
|
if (message.parts.length == 0) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
console.log(`${message.severity}[
|
|
69
|
+
console.log(`${message.severity}[${message.code}]: ${message.codeDescription}`);
|
|
70
70
|
let digits = lineDigitCount(message);
|
|
71
71
|
let indent = " ".repeat(digits);
|
|
72
72
|
let first = true;
|
|
@@ -20,7 +20,8 @@ import * as idl from "../idl";
|
|
|
20
20
|
import { isDefined, warn } from "../util";
|
|
21
21
|
import { collapseTypes, generateSyntheticUnionName } from "../peer-generation/idl/common";
|
|
22
22
|
import { commonRange } from "../diagnostictypes";
|
|
23
|
-
import {
|
|
23
|
+
import { DiagnosticMessageGroup, LoadingFatal, ParsingFatal, InternalFatal } from "../diagnosticmessages";
|
|
24
|
+
import { FatalParserException, Parser } from "./parser";
|
|
24
25
|
function getTokens(node) {
|
|
25
26
|
return node.tokens;
|
|
26
27
|
}
|
|
@@ -135,10 +136,9 @@ class IDLDeserializer {
|
|
|
135
136
|
}
|
|
136
137
|
const implementations = [];
|
|
137
138
|
node.inheritance.forEach(it => {
|
|
138
|
-
var _a;
|
|
139
139
|
const attributes = it.extAttrs;
|
|
140
140
|
const parentTypeArgs = this.extractTypeArguments(file, attributes !== null && attributes !== void 0 ? attributes : [], idl.IDLExtendedAttributes.TypeArguments);
|
|
141
|
-
const attrs =
|
|
141
|
+
const attrs = this.toExtendedAttributes(attributes !== null && attributes !== void 0 ? attributes : []); // ?.filter(it => it.name !== idl.IDLExtendedAttributes.TypeArguments)
|
|
142
142
|
const ref = idl.createReferenceType(it.inheritance, parentTypeArgs, {
|
|
143
143
|
extendedAttributes: attrs
|
|
144
144
|
});
|
|
@@ -519,8 +519,136 @@ export function toIdlType(fileName, content) {
|
|
|
519
519
|
const deserializer = new IDLDeserializer(lexicalInfo, 'multiple');
|
|
520
520
|
return deserializer.toIDLType(fileName, webidl2.parseType(content, fileName));
|
|
521
521
|
}
|
|
522
|
+
const DifferenceFound = new DiagnosticMessageGroup("error", "DifferenceFound", "Difference found");
|
|
523
|
+
const noCompare = new Set(["parent", "fileName", "nodeLocation", "nameLocation", "valueLocation", "typesValue"]);
|
|
524
|
+
const canContainMoreCompare = new Set(["extendedAttributes", "typeParameters", "typeArguments"]);
|
|
525
|
+
function safeString(value) {
|
|
526
|
+
if (typeof value == "symbol") {
|
|
527
|
+
return String(value);
|
|
528
|
+
}
|
|
529
|
+
return JSON.stringify(value, (k, v) => { return noCompare.has(k) ? undefined : v; });
|
|
530
|
+
}
|
|
531
|
+
function joinPath(left, right) {
|
|
532
|
+
if (!right) {
|
|
533
|
+
return left;
|
|
534
|
+
}
|
|
535
|
+
return `${left}.${right}`;
|
|
536
|
+
}
|
|
537
|
+
function compareDeep(oldData, newData, paths) {
|
|
538
|
+
var _a;
|
|
539
|
+
const location = (newData === null || newData === void 0 ? void 0 : newData.kind) && ((_a = newData === null || newData === void 0 ? void 0 : newData.nameLocation) !== null && _a !== void 0 ? _a : newData === null || newData === void 0 ? void 0 : newData.nodeLocation);
|
|
540
|
+
const diffs = [];
|
|
541
|
+
if (typeof oldData != typeof newData) {
|
|
542
|
+
diffs.push({ path: "", oldValue: safeString(oldData), newValue: safeString(newData) });
|
|
543
|
+
}
|
|
544
|
+
else if (Array.isArray(oldData) && Array.isArray(newData)) {
|
|
545
|
+
const len = Math.max(oldData.length, newData.length);
|
|
546
|
+
if (oldData.length != newData.length) {
|
|
547
|
+
diffs.push({ path: "", oldValue: `(length=${oldData.length})`, newValue: `(length=${newData.length})` });
|
|
548
|
+
}
|
|
549
|
+
for (let i = 0; i < len; ++i) {
|
|
550
|
+
const deeperDiffs = compareDeep(oldData[i], newData[i], paths);
|
|
551
|
+
if (deeperDiffs.length > 0) {
|
|
552
|
+
diffs.push(...deeperDiffs.map(x => { x.path = joinPath("" + i, x.path); return x; }));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
else if (typeof newData == "object") {
|
|
557
|
+
const keys = [...new Set([...Object.getOwnPropertyNames(oldData), ...Object.getOwnPropertyNames(newData)])].filter(x => !noCompare.has(x));
|
|
558
|
+
for (const k of keys) {
|
|
559
|
+
let oldValue = oldData[k];
|
|
560
|
+
let newValue = newData[k];
|
|
561
|
+
if (canContainMoreCompare.has(k)) {
|
|
562
|
+
if (newValue == null && Array.isArray(oldValue) && oldValue.length == 0) {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
if (oldValue == null && Array.isArray(newValue)) {
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
569
|
+
if (newValue.length > oldValue.length) {
|
|
570
|
+
// Cases when old parser takes attributes from outer declaration and ignores the right ones
|
|
571
|
+
newValue = newValue.slice(newValue.length - oldValue.length);
|
|
572
|
+
}
|
|
573
|
+
else if (oldValue.length > newValue.length) {
|
|
574
|
+
// Cases when types in parentheses have own attributes, but old parser adds attributes from outer declaration
|
|
575
|
+
oldValue = oldValue.slice(0, newValue.length);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const deeperDiffs = compareDeep(oldValue, newValue, paths);
|
|
580
|
+
if (deeperDiffs.length > 0) {
|
|
581
|
+
diffs.push(...deeperDiffs.map(x => { x.path = joinPath(k, x.path); return x; }));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
if (oldData != newData) {
|
|
587
|
+
diffs.push({ path: "", oldValue: safeString(oldData), newValue: safeString(newData) });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (!location) {
|
|
591
|
+
return diffs;
|
|
592
|
+
}
|
|
593
|
+
for (const diff of diffs) {
|
|
594
|
+
paths.add(diff.path);
|
|
595
|
+
DifferenceFound.reportDiagnosticMessage([location], `path: ${diff.path} oldValue: ${diff.oldValue} newValue: ${diff.newValue}`);
|
|
596
|
+
}
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
function compareParsingResults(oldFile, newFile) {
|
|
600
|
+
const paths = new Set();
|
|
601
|
+
compareDeep(oldFile, newFile, paths);
|
|
602
|
+
if (paths.size > 0) {
|
|
603
|
+
DifferenceFound.reportDiagnosticMessage([newFile.nodeLocation], "Differences found in those paths:\n" + [...paths].join("\n"));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
function parseIdlNew(fileName, content, registerSynthetics) {
|
|
607
|
+
let file = new Parser(fileName, content).parseIDL();
|
|
608
|
+
const ancestors = [];
|
|
609
|
+
const namespaces = [];
|
|
610
|
+
// Mimic old parser and deserialize.ts behavior:
|
|
611
|
+
// 1. Add `fileName`.
|
|
612
|
+
// 2. Add `parent`.
|
|
613
|
+
// 3. Possibly register node with `addSyntheticType` if "Synthetic" is in attributes
|
|
614
|
+
idl.forEachChild(file, (node) => {
|
|
615
|
+
var _a;
|
|
616
|
+
if (idl.isPrimitiveType(node)) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
node.fileName = fileName;
|
|
620
|
+
if (registerSynthetics && idl.isEntry(node) && ((_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.some(it => it.name === "Synthetic"))) {
|
|
621
|
+
const fqName = file.packageClause.concat(namespaces).concat([node.name]).join('.');
|
|
622
|
+
addSyntheticType(fqName, node);
|
|
623
|
+
}
|
|
624
|
+
if (ancestors.length) {
|
|
625
|
+
node.parent = ancestors[ancestors.length - 1];
|
|
626
|
+
}
|
|
627
|
+
if (idl.isNamespace(node)) {
|
|
628
|
+
namespaces.push(node.name);
|
|
629
|
+
}
|
|
630
|
+
ancestors.push(node);
|
|
631
|
+
}, (node) => {
|
|
632
|
+
if (idl.isPrimitiveType(node)) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (idl.isNamespace(node)) {
|
|
636
|
+
namespaces.pop();
|
|
637
|
+
}
|
|
638
|
+
ancestors.pop();
|
|
639
|
+
});
|
|
640
|
+
return file;
|
|
641
|
+
}
|
|
522
642
|
export function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
|
|
523
643
|
var _a, _b, _c;
|
|
644
|
+
let newFile;
|
|
645
|
+
const mode = process.env.IDLPARSE;
|
|
646
|
+
if (mode == "compare" || mode == "new") {
|
|
647
|
+
newFile = parseIdlNew(fileName, content, mode == "new");
|
|
648
|
+
if (mode == "new") {
|
|
649
|
+
return [newFile, new Map()];
|
|
650
|
+
}
|
|
651
|
+
}
|
|
524
652
|
const lexicalInfo = new Map();
|
|
525
653
|
const deserializer = new IDLDeserializer(lexicalInfo, inheritanceMode);
|
|
526
654
|
if (undefined === content) {
|
|
@@ -529,7 +657,7 @@ export function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } =
|
|
|
529
657
|
}
|
|
530
658
|
catch (e) {
|
|
531
659
|
content = "";
|
|
532
|
-
|
|
660
|
+
throw new FatalParserException([LoadingFatal.reportDiagnosticMessage([{ documentPath: fileName }], (_a = e.message) !== null && _a !== void 0 ? _a : "")]);
|
|
533
661
|
}
|
|
534
662
|
}
|
|
535
663
|
let lines = (_b = content.match(/[^\r\n]*(\n|\r\n)?/g)) !== null && _b !== void 0 ? _b : [];
|
|
@@ -545,9 +673,9 @@ export function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } =
|
|
|
545
673
|
if (e.name == "WebIDLParseError") {
|
|
546
674
|
let tokens = e.tokens;
|
|
547
675
|
let range = tokens.length > 0 ? rangeForToken(offsets, tokens[0]) : undefined;
|
|
548
|
-
|
|
676
|
+
throw new FatalParserException([ParsingFatal.reportDiagnosticMessage([{ documentPath: fileName, range, lines }], e.bareMessage)]);
|
|
549
677
|
}
|
|
550
|
-
|
|
678
|
+
throw new FatalParserException([InternalFatal.reportDiagnosticMessage([{ documentPath: fileName, lines }], (_c = e.message) !== null && _c !== void 0 ? _c : "")]);
|
|
551
679
|
}
|
|
552
680
|
const entries = rawParsingResults
|
|
553
681
|
.filter(it => {
|
|
@@ -571,6 +699,10 @@ export function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } =
|
|
|
571
699
|
node.nameLocation = nameLocation;
|
|
572
700
|
}
|
|
573
701
|
});
|
|
702
|
+
if (mode == "compare") {
|
|
703
|
+
compareParsingResults(file, newFile);
|
|
704
|
+
return [newFile, new Map()];
|
|
705
|
+
}
|
|
574
706
|
return [file, lexicalInfo];
|
|
575
707
|
}
|
|
576
708
|
function prepareOffsets(lines) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as idl from "../idl";
|
|
2
|
+
import { DiagnosticMessage, Location } from "../diagnostictypes";
|
|
3
|
+
export declare class FatalParserException extends Error {
|
|
4
|
+
diagnosticMessages?: DiagnosticMessage[];
|
|
5
|
+
constructor(diagnosticMessages?: DiagnosticMessage[]);
|
|
6
|
+
}
|
|
7
|
+
declare enum TokenKind {
|
|
8
|
+
Words = "Words",
|
|
9
|
+
Literal = "Literal",
|
|
10
|
+
Symbol = "Symbol",
|
|
11
|
+
Comment = "Comment",
|
|
12
|
+
Whitespace = "Space",
|
|
13
|
+
End = "End"
|
|
14
|
+
}
|
|
15
|
+
interface Token {
|
|
16
|
+
kind: TokenKind;
|
|
17
|
+
value: string;
|
|
18
|
+
location: Location;
|
|
19
|
+
}
|
|
20
|
+
type ModifierToken = "static" | "readonly" | "async";
|
|
21
|
+
type ModifiersContainer = {
|
|
22
|
+
[Key in ModifierToken]?: Token;
|
|
23
|
+
};
|
|
24
|
+
export declare class Parser {
|
|
25
|
+
fileName: string;
|
|
26
|
+
content: string;
|
|
27
|
+
lines: string[];
|
|
28
|
+
offsets: number[];
|
|
29
|
+
constructor(fileName: string, content?: string);
|
|
30
|
+
parseIDL(): idl.IDLFile;
|
|
31
|
+
_curOffset: number;
|
|
32
|
+
_curLine: number;
|
|
33
|
+
_curToken: Token;
|
|
34
|
+
_prevToken: Token;
|
|
35
|
+
_generics: string[][];
|
|
36
|
+
_enableInLiteralParsing: boolean;
|
|
37
|
+
_match(re: RegExp, kind: TokenKind): Token | undefined;
|
|
38
|
+
_reDecimal: RegExp;
|
|
39
|
+
_reInteger: RegExp;
|
|
40
|
+
_reString: RegExp;
|
|
41
|
+
_reWords: RegExp;
|
|
42
|
+
_reSymbol: RegExp;
|
|
43
|
+
_reWhitespace: RegExp;
|
|
44
|
+
_reComment: RegExp;
|
|
45
|
+
_reIsDocComment: RegExp;
|
|
46
|
+
_matchComment(): Token | undefined;
|
|
47
|
+
_lexerNext(): void;
|
|
48
|
+
get curToken(): Token;
|
|
49
|
+
get curKind(): TokenKind;
|
|
50
|
+
get curValue(): string;
|
|
51
|
+
get curLocation(): Location;
|
|
52
|
+
see(tok: string): boolean;
|
|
53
|
+
seeAndSkip(tok: string): boolean;
|
|
54
|
+
seeEof(): boolean;
|
|
55
|
+
skip(tok: string): void;
|
|
56
|
+
skipToAfter(tok: string): void;
|
|
57
|
+
trackLocation(): () => Location;
|
|
58
|
+
_internalCurrentExtended: idl.IDLExtendedAttribute[] | undefined;
|
|
59
|
+
consumeCurrentExtended(): idl.IDLExtendedAttribute[] | undefined;
|
|
60
|
+
currentModifiers: ModifiersContainer;
|
|
61
|
+
assertPossibleModifiers(...mods: ModifierToken[]): void;
|
|
62
|
+
precedingComment: Token | undefined;
|
|
63
|
+
currentPackage: string | undefined;
|
|
64
|
+
parseSingleIdentifier(): Token;
|
|
65
|
+
parseFullIdentifier(): Token;
|
|
66
|
+
parseFullIdentifierOrLiteral(): Token;
|
|
67
|
+
parseLiteral(): Token;
|
|
68
|
+
parseAndPushGenerics(ext?: idl.IDLExtendedAttribute[]): string[] | undefined;
|
|
69
|
+
hasGeneric(name: string): boolean;
|
|
70
|
+
parseFile(): idl.IDLFile;
|
|
71
|
+
parseDeclaration(scopeKind: idl.IDLKind): idl.IDLEntry | undefined;
|
|
72
|
+
parseDeclarationUnsafe(scopeKind: idl.IDLKind): idl.IDLEntry | undefined;
|
|
73
|
+
parseNamespace(): idl.IDLNamespace;
|
|
74
|
+
parseInterface(): idl.IDLInterface;
|
|
75
|
+
parseExtendedAttributes(): idl.IDLExtendedAttribute[] | undefined;
|
|
76
|
+
parseTypeList(): idl.IDLType[];
|
|
77
|
+
parseType(outerExt?: idl.IDLExtendedAttribute[]): idl.IDLType;
|
|
78
|
+
parseReferenceType(): idl.IDLReferenceType;
|
|
79
|
+
parsePrimitiveType(): idl.IDLPrimitiveType;
|
|
80
|
+
parseArgTuple(): idl.IDLParameter[];
|
|
81
|
+
parseArg(): idl.IDLParameter;
|
|
82
|
+
parseOperation(): idl.IDLCallable | idl.IDLMethod;
|
|
83
|
+
parseConstructor(): idl.IDLConstructor;
|
|
84
|
+
parseConst(): idl.IDLConstant;
|
|
85
|
+
parseAttribute(): idl.IDLProperty;
|
|
86
|
+
parseTypedef(): idl.IDLTypedef;
|
|
87
|
+
parseCallback(): idl.IDLCallback;
|
|
88
|
+
parseEnum(): idl.IDLEnum;
|
|
89
|
+
parseDictionary(): idl.IDLEnum;
|
|
90
|
+
parseDictionaryEntry(): idl.IDLEnumMember;
|
|
91
|
+
parsePackage(): {
|
|
92
|
+
location: Location;
|
|
93
|
+
name: string;
|
|
94
|
+
};
|
|
95
|
+
parseImport(): idl.IDLImport;
|
|
96
|
+
parseVersion(): idl.IDLVersion;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=parser.d.ts.map
|