brighterscript 1.0.0-alpha.28 → 1.0.0-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/AstValidationSegmenter.d.ts +11 -1
- package/dist/AstValidationSegmenter.js +72 -14
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/DependencyGraph.d.ts +4 -0
- package/dist/DependencyGraph.js +19 -0
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/Program.d.ts +18 -14
- package/dist/Program.js +143 -82
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +22 -2
- package/dist/Scope.js +162 -91
- package/dist/Scope.js.map +1 -1
- package/dist/Stopwatch.d.ts +4 -0
- package/dist/Stopwatch.js +7 -0
- package/dist/Stopwatch.js.map +1 -1
- package/dist/SymbolTable.d.ts +1 -0
- package/dist/SymbolTable.js +26 -0
- package/dist/SymbolTable.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +3 -2
- package/dist/astUtils/reflection.js +8 -3
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +6 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +5 -2
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileAfterValidatior.d.ts +7 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidatior.js +18 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidatior.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +16 -4
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +11 -2
- package/dist/bscPlugin/validation/ScopeValidator.js +114 -63
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +2 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +11 -3
- package/dist/files/BrsFile.js +125 -13
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +216 -91
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/BscFile.d.ts +2 -1
- package/dist/files/BscFile.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -2
- package/dist/files/XmlFile.js +1 -1
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/interfaces.d.ts +2 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/parser/Expression.d.ts +6 -0
- package/dist/parser/Expression.js +7 -1
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.js +0 -3
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/TranspileState.js +3 -2
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +8 -0
- package/dist/types/ReferenceType.js +45 -1
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/ReferenceType.spec.js +15 -0
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/util.d.ts +5 -1
- package/dist/util.js +19 -3
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [1.0.0-alpha.29](https://github.com/rokucommunity/brighterscript/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) - 2024-03-28
|
|
10
|
+
### Fixed
|
|
11
|
+
- transpile crash when token has no text ([#1109](https://github.com/rokucommunity/brighterscript/pull/1109))
|
|
12
|
+
- array type in const ([#1111](https://github.com/rokucommunity/brighterscript/pull/1111))
|
|
13
|
+
- more validation performance ([#1110](https://github.com/rokucommunity/brighterscript/pull/1110))
|
|
14
|
+
- significant validation improvement ([#1119](https://github.com/rokucommunity/brighterscript/pull/1119))
|
|
15
|
+
- fix bug in range and position caching ([#1126](https://github.com/rokucommunity/brighterscript/pull/1126))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
9
19
|
## [1.0.0-alpha.28](https://github.com/rokucommunity/brighterscript/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) - 2024-03-13
|
|
10
20
|
### Added
|
|
11
21
|
- type to const hovers and adds hover for for-each loop vars ([#1092](https://github.com/rokucommunity/brighterscript/pull/1092))
|
|
@@ -2,6 +2,7 @@ import type { DottedGetExpression, TypeExpression, VariableExpression } from './
|
|
|
2
2
|
import type { TypeChainEntry } from './interfaces';
|
|
3
3
|
import type { AstNode } from './parser/AstNode';
|
|
4
4
|
import { SymbolTypeFlag } from './SymbolTypeFlag';
|
|
5
|
+
import type { Token } from './lexer/Token';
|
|
5
6
|
export declare const InsideSegmentWalkMode: number;
|
|
6
7
|
export interface UnresolvedSymbol {
|
|
7
8
|
typeChain: TypeChainEntry[];
|
|
@@ -9,17 +10,26 @@ export interface UnresolvedSymbol {
|
|
|
9
10
|
endChainFlags: SymbolTypeFlag;
|
|
10
11
|
containingNamespaces: string[];
|
|
11
12
|
}
|
|
13
|
+
export interface AssignedSymbol {
|
|
14
|
+
token: Token;
|
|
15
|
+
node: AstNode;
|
|
16
|
+
}
|
|
12
17
|
export declare class AstValidationSegmenter {
|
|
13
18
|
validatedSegments: Map<AstNode, boolean>;
|
|
14
19
|
segmentsForValidation: AstNode[];
|
|
15
20
|
singleValidationSegments: Set<AstNode>;
|
|
16
21
|
unresolvedSegmentsSymbols: Map<AstNode, Set<UnresolvedSymbol>>;
|
|
22
|
+
assignedTokensInSegment: Map<AstNode, Set<AssignedSymbol>>;
|
|
17
23
|
ast: AstNode;
|
|
18
24
|
reset(): void;
|
|
19
25
|
processTree(ast: AstNode): void;
|
|
20
|
-
checkExpressionForUnresolved(segment: AstNode, expression: VariableExpression | DottedGetExpression | TypeExpression,
|
|
26
|
+
checkExpressionForUnresolved(segment: AstNode, expression: VariableExpression | DottedGetExpression | TypeExpression, assignedSymbolsNames?: Set<string>): boolean;
|
|
21
27
|
private currentNamespaceStatement;
|
|
22
28
|
checkSegmentWalk(segment: AstNode): void;
|
|
23
29
|
getSegments(changedSymbols: Map<SymbolTypeFlag, Set<string>>): AstNode[];
|
|
24
30
|
markSegmentAsValidated(segment: AstNode): void;
|
|
31
|
+
unValidateAllSegments(): void;
|
|
32
|
+
hasUnvalidatedSegments(): boolean;
|
|
33
|
+
checkIfSegmentNeedRevalidation(segment: AstNode): boolean;
|
|
34
|
+
markSegmentsInvalidatedBySymbol(symbolName: string, flag: SymbolTypeFlag): void;
|
|
25
35
|
}
|
|
@@ -12,6 +12,7 @@ class AstValidationSegmenter {
|
|
|
12
12
|
this.segmentsForValidation = new Array();
|
|
13
13
|
this.singleValidationSegments = new Set();
|
|
14
14
|
this.unresolvedSegmentsSymbols = new Map();
|
|
15
|
+
this.assignedTokensInSegment = new Map();
|
|
15
16
|
}
|
|
16
17
|
reset() {
|
|
17
18
|
this.validatedSegments.clear();
|
|
@@ -27,7 +28,7 @@ class AstValidationSegmenter {
|
|
|
27
28
|
walkMode: visitors_1.WalkMode.visitStatements
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
checkExpressionForUnresolved(segment, expression,
|
|
31
|
+
checkExpressionForUnresolved(segment, expression, assignedSymbolsNames) {
|
|
31
32
|
var _a, _b;
|
|
32
33
|
if (!expression) {
|
|
33
34
|
return false;
|
|
@@ -41,7 +42,7 @@ class AstValidationSegmenter {
|
|
|
41
42
|
const nodeType = expression.getType(options);
|
|
42
43
|
if (!(nodeType === null || nodeType === void 0 ? void 0 : nodeType.isResolvable())) {
|
|
43
44
|
let symbolsSet;
|
|
44
|
-
if (!(
|
|
45
|
+
if (!(assignedSymbolsNames === null || assignedSymbolsNames === void 0 ? void 0 : assignedSymbolsNames.has(typeChain[0].name.toLowerCase()))) {
|
|
45
46
|
if (!this.unresolvedSegmentsSymbols.has(segment)) {
|
|
46
47
|
symbolsSet = new Set();
|
|
47
48
|
this.unresolvedSegmentsSymbols.set(segment, symbolsSet);
|
|
@@ -49,6 +50,7 @@ class AstValidationSegmenter {
|
|
|
49
50
|
else {
|
|
50
51
|
symbolsSet = this.unresolvedSegmentsSymbols.get(segment);
|
|
51
52
|
}
|
|
53
|
+
this.validatedSegments.set(segment, false);
|
|
52
54
|
symbolsSet.add({ typeChain: typeChain, flags: typeChain[0].data.flags, endChainFlags: flag, containingNamespaces: (_b = (_a = this.currentNamespaceStatement) === null || _a === void 0 ? void 0 : _a.getNameParts()) === null || _b === void 0 ? void 0 : _b.map(t => t.text) });
|
|
53
55
|
}
|
|
54
56
|
return true;
|
|
@@ -86,28 +88,35 @@ class AstValidationSegmenter {
|
|
|
86
88
|
let foundUnresolvedInSegment = false;
|
|
87
89
|
const skipper = new visitors_1.ChildrenSkipper();
|
|
88
90
|
const assignedSymbols = new Set();
|
|
91
|
+
const assignedSymbolsNames = new Set();
|
|
89
92
|
this.currentNamespaceStatement = segment.findAncestor(reflection_1.isNamespaceStatement);
|
|
90
93
|
segment.walk((0, visitors_1.createVisitor)({
|
|
91
94
|
AssignmentStatement: (stmt) => {
|
|
92
|
-
assignedSymbols.add(stmt.tokens.name
|
|
95
|
+
assignedSymbols.add({ token: stmt.tokens.name, node: stmt });
|
|
96
|
+
assignedSymbolsNames.add(stmt.tokens.name.text.toLowerCase());
|
|
93
97
|
},
|
|
94
98
|
FunctionParameterExpression: (expr) => {
|
|
95
|
-
assignedSymbols.add(expr.tokens.name
|
|
99
|
+
assignedSymbols.add({ token: expr.tokens.name, node: expr });
|
|
100
|
+
assignedSymbolsNames.add(expr.tokens.name.text.toLowerCase());
|
|
101
|
+
},
|
|
102
|
+
ForEachStatement: (stmt) => {
|
|
103
|
+
assignedSymbols.add({ token: stmt.tokens.item, node: stmt });
|
|
104
|
+
assignedSymbolsNames.add(stmt.tokens.item.text.toLowerCase());
|
|
96
105
|
},
|
|
97
106
|
VariableExpression: (expr) => {
|
|
98
|
-
if (!
|
|
99
|
-
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr,
|
|
107
|
+
if (!assignedSymbolsNames.has(expr.tokens.name.text.toLowerCase())) {
|
|
108
|
+
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr, assignedSymbolsNames);
|
|
100
109
|
foundUnresolvedInSegment = expressionIsUnresolved || foundUnresolvedInSegment;
|
|
101
110
|
}
|
|
102
111
|
skipper.skip();
|
|
103
112
|
},
|
|
104
113
|
DottedGetExpression: (expr) => {
|
|
105
|
-
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr,
|
|
114
|
+
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr, assignedSymbolsNames);
|
|
106
115
|
foundUnresolvedInSegment = expressionIsUnresolved || foundUnresolvedInSegment;
|
|
107
116
|
skipper.skip();
|
|
108
117
|
},
|
|
109
118
|
TypeExpression: (expr) => {
|
|
110
|
-
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr,
|
|
119
|
+
const expressionIsUnresolved = this.checkExpressionForUnresolved(segment, expr, assignedSymbolsNames);
|
|
111
120
|
foundUnresolvedInSegment = expressionIsUnresolved || foundUnresolvedInSegment;
|
|
112
121
|
skipper.skip();
|
|
113
122
|
}
|
|
@@ -115,12 +124,15 @@ class AstValidationSegmenter {
|
|
|
115
124
|
walkMode: exports.InsideSegmentWalkMode,
|
|
116
125
|
skipChildren: skipper
|
|
117
126
|
});
|
|
127
|
+
this.assignedTokensInSegment.set(segment, assignedSymbols);
|
|
118
128
|
if (!foundUnresolvedInSegment) {
|
|
119
129
|
this.singleValidationSegments.add(segment);
|
|
120
130
|
}
|
|
121
131
|
}
|
|
122
132
|
getSegments(changedSymbols) {
|
|
133
|
+
var _a, _b, _c;
|
|
123
134
|
const segmentsToWalkForValidation = [];
|
|
135
|
+
const allChangedSymbolNames = [...changedSymbols.get(1 /* SymbolTypeFlag.runtime */), ...changedSymbols.get(2 /* SymbolTypeFlag.typetime */)];
|
|
124
136
|
for (const segment of this.segmentsForValidation) {
|
|
125
137
|
const symbolsRequired = this.unresolvedSegmentsSymbols.get(segment);
|
|
126
138
|
const isSingleValidationSegment = this.singleValidationSegments.has(segment);
|
|
@@ -128,24 +140,70 @@ class AstValidationSegmenter {
|
|
|
128
140
|
let segmentNeedsRevalidation = !singleValidationSegmentAlreadyValidated;
|
|
129
141
|
if (symbolsRequired) {
|
|
130
142
|
for (const requiredSymbol of symbolsRequired.values()) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
for (const flagType of [1 /* SymbolTypeFlag.runtime */, 2 /* SymbolTypeFlag.typetime */]) {
|
|
144
|
+
// eslint-disable-next-line no-bitwise
|
|
145
|
+
const runTimeOrTypeTimeSymbolFlag = requiredSymbol.flags & flagType;
|
|
146
|
+
const changeSymbolSetForFlag = changedSymbols.get(runTimeOrTypeTimeSymbolFlag);
|
|
147
|
+
if (!changeSymbolSetForFlag) {
|
|
148
|
+
// This symbol has no flag - it is of unknown usage
|
|
149
|
+
// This can happen when testing if a function exists
|
|
150
|
+
}
|
|
151
|
+
else if (util_1.util.setContainsUnresolvedSymbol(changeSymbolSetForFlag, requiredSymbol)) {
|
|
152
|
+
segmentsToWalkForValidation.push(segment);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
137
155
|
}
|
|
138
156
|
}
|
|
139
157
|
}
|
|
140
158
|
else if (segmentNeedsRevalidation) {
|
|
141
159
|
segmentsToWalkForValidation.push(segment);
|
|
142
160
|
}
|
|
161
|
+
else {
|
|
162
|
+
for (let assignedToken of (_c = (_b = (_a = this.assignedTokensInSegment) === null || _a === void 0 ? void 0 : _a.get(segment)) === null || _b === void 0 ? void 0 : _b.values()) !== null && _c !== void 0 ? _c : []) {
|
|
163
|
+
if (allChangedSymbolNames.includes(assignedToken.token.text.toLowerCase())) {
|
|
164
|
+
segmentsToWalkForValidation.push(segment);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
143
169
|
}
|
|
144
170
|
return segmentsToWalkForValidation;
|
|
145
171
|
}
|
|
146
172
|
markSegmentAsValidated(segment) {
|
|
147
173
|
this.validatedSegments.set(segment, true);
|
|
148
174
|
}
|
|
175
|
+
unValidateAllSegments() {
|
|
176
|
+
for (const segment of this.validatedSegments.keys()) {
|
|
177
|
+
this.validatedSegments.set(segment, false);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
hasUnvalidatedSegments() {
|
|
181
|
+
return Array.from(this.validatedSegments.values()).includes(false);
|
|
182
|
+
}
|
|
183
|
+
checkIfSegmentNeedRevalidation(segment) {
|
|
184
|
+
if (!this.validatedSegments.get(segment)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
const unresolved = this.unresolvedSegmentsSymbols.get(segment);
|
|
188
|
+
if ((unresolved === null || unresolved === void 0 ? void 0 : unresolved.size) > 0) {
|
|
189
|
+
return true;
|
|
190
|
+
} /*
|
|
191
|
+
const assignedTokens = this.assignedTokensInSegment.get(segment);
|
|
192
|
+
if (assignedTokens?.size > 0) {
|
|
193
|
+
return true;
|
|
194
|
+
}*/
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
markSegmentsInvalidatedBySymbol(symbolName, flag) {
|
|
198
|
+
for (let [segment, unresolvedSet] of this.unresolvedSegmentsSymbols) {
|
|
199
|
+
for (let unresolvedSymbol of unresolvedSet.values()) {
|
|
200
|
+
if (unresolvedSymbol.typeChain.join('.').toLowerCase() === symbolName) {
|
|
201
|
+
this.validatedSegments.set(segment, false);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
149
207
|
}
|
|
150
208
|
exports.AstValidationSegmenter = AstValidationSegmenter;
|
|
151
209
|
//# sourceMappingURL=AstValidationSegmenter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AstValidationSegmenter.js","sourceRoot":"","sources":["../src/AstValidationSegmenter.ts"],"names":[],"mappings":";;;AACA,sDAAmI;AACnI,kDAA+E;AAG/E,iCAA8B;
|
|
1
|
+
{"version":3,"file":"AstValidationSegmenter.js","sourceRoot":"","sources":["../src/AstValidationSegmenter.ts"],"names":[],"mappings":";;;AACA,sDAAmI;AACnI,kDAA+E;AAG/E,iCAA8B;AAK9B,sCAAsC;AACzB,QAAA,qBAAqB,GAAG,mBAAQ,CAAC,eAAe,GAAG,mBAAQ,CAAC,gBAAgB,GAAG,mBAAQ,CAAC,qBAAqB,CAAC;AAc3H,MAAa,sBAAsB;IAAnC;QAEW,sBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;QAChD,0BAAqB,GAAG,IAAI,KAAK,EAAW,CAAC;QAC7C,6BAAwB,GAAG,IAAI,GAAG,EAAW,CAAC;QAC9C,8BAAyB,GAAG,IAAI,GAAG,EAAkC,CAAC;QACtE,4BAAuB,GAAG,IAAI,GAAG,EAAgC,CAAC;IA+M7E,CAAC;IA5MG,KAAK;QACD,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QACtC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,GAAY;QACpB,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YAClB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACnC,C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AAO,CAAC,EAAE;YACtC,OAAO,IAAI,CAAC;SACf;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,IAAG,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC;SACf,CAAC;;;;YAIE;QACJ,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,+BAA+B,CAAC,UAAkB,EAAE,IAAoB;QACpE,KAAK,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,IAAI,CAAC,yBAAyB,EAAE;YACjE,KAAK,IAAI,gBAAgB,IAAI,aAAa,CAAC,MAAM,EAAE,EAAE;gBACjD,IAAI,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE;oBACnE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;oBAC3C,MAAM;iBACT;aACJ;SACJ;IACL,CAAC;CACJ;AArND,wDAqNC"}
|
|
@@ -31,6 +31,10 @@ export declare class DependencyGraph {
|
|
|
31
31
|
* @param exclude a list of keys to exclude from traversal. Anytime one of these nodes is encountered, it is skipped.
|
|
32
32
|
*/
|
|
33
33
|
getAllDependencies(keys: string | string[], exclude?: string[]): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Get a list of the immediate dependencies for the given key.
|
|
36
|
+
*/
|
|
37
|
+
getImmediateDependencies(keys: string | string[], exclude?: string[]): string[];
|
|
34
38
|
/**
|
|
35
39
|
* Remove the item. This will emit an onchange event for all dependent nodes
|
|
36
40
|
*/
|
package/dist/DependencyGraph.js
CHANGED
|
@@ -79,6 +79,25 @@ class DependencyGraph {
|
|
|
79
79
|
return [...set];
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a list of the immediate dependencies for the given key.
|
|
84
|
+
*/
|
|
85
|
+
getImmediateDependencies(keys, exclude) {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
if (typeof keys === 'string') {
|
|
88
|
+
return (_b = (_a = this.nodes[keys]) === null || _a === void 0 ? void 0 : _a.dependencies) !== null && _b !== void 0 ? _b : [];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const set = new Set();
|
|
92
|
+
for (const key of keys) {
|
|
93
|
+
const dependencies = this.getImmediateDependencies(key, exclude);
|
|
94
|
+
for (const dependency of dependencies) {
|
|
95
|
+
set.add(dependency);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [...set];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
82
101
|
/**
|
|
83
102
|
* Remove the item. This will emit an onchange event for all dependent nodes
|
|
84
103
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyGraph.js","sourceRoot":"","sources":["../src/DependencyGraph.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C;;;GAGG;AACH,MAAa,eAAe;IAA5B;QACI;;WAEG;QACI,UAAK,GAAG,EAA0B,CAAC;QAE1C;;WAEG;QACK,oBAAe,GAAG,IAAI,4BAAY,EAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"DependencyGraph.js","sourceRoot":"","sources":["../src/DependencyGraph.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C;;;GAGG;AACH,MAAa,eAAe;IAA5B;QACI;;WAEG;QACI,UAAK,GAAG,EAA0B,CAAC;QAE1C;;WAEG;QACK,oBAAe,GAAG,IAAI,4BAAY,EAAkC,CAAC;IA0HjF,CAAC;IAxHG;;OAEG;IACI,YAAY,CAAC,GAAW,EAAE,YAAuB;;QACpD,uBAAuB;QACvB,YAAY,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,EAAE,mCAAI,EAAE,CAAC;QAE1C,2BAA2B;QAC3B,MAAA,IAAI,CAAC,KA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SACjB;IACL,CAAC;CACJ;AApDD,oBAoDC"}
|
package/dist/Program.d.ts
CHANGED
|
@@ -18,6 +18,20 @@ export interface SignatureInfoObj {
|
|
|
18
18
|
key: string;
|
|
19
19
|
signature: SignatureInformation;
|
|
20
20
|
}
|
|
21
|
+
export interface ProgramValidationInfo {
|
|
22
|
+
symbolsNotDefinedInEveryScope: {
|
|
23
|
+
symbol: UnresolvedSymbol;
|
|
24
|
+
scope: Scope;
|
|
25
|
+
}[];
|
|
26
|
+
duplicateSymbolsInSameScope: {
|
|
27
|
+
symbol: UnresolvedSymbol;
|
|
28
|
+
scope: Scope;
|
|
29
|
+
}[];
|
|
30
|
+
symbolsNotConsistentAcrossScopes: {
|
|
31
|
+
symbol: UnresolvedSymbol;
|
|
32
|
+
scopes: Scope[];
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
21
35
|
export declare class Program {
|
|
22
36
|
constructor(
|
|
23
37
|
/**
|
|
@@ -220,24 +234,14 @@ export declare class Program {
|
|
|
220
234
|
* @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
|
|
221
235
|
*/
|
|
222
236
|
removeFile(filePath: string, normalizePath?: boolean, keepSymbolInformation?: boolean): void;
|
|
223
|
-
lastValidationInfo: Map<string,
|
|
224
|
-
|
|
225
|
-
symbol: UnresolvedSymbol;
|
|
226
|
-
scope: Scope;
|
|
227
|
-
}[];
|
|
228
|
-
duplicateSymbolsInSameScope: {
|
|
229
|
-
symbol: UnresolvedSymbol;
|
|
230
|
-
scope: Scope;
|
|
231
|
-
}[];
|
|
232
|
-
symbolsNotConsistentAcrossScopes: {
|
|
233
|
-
symbol: UnresolvedSymbol;
|
|
234
|
-
scopes: Scope[];
|
|
235
|
-
}[];
|
|
236
|
-
}>;
|
|
237
|
+
lastValidationInfo: Map<string, ProgramValidationInfo>;
|
|
238
|
+
private isFirstValidation;
|
|
237
239
|
/**
|
|
238
240
|
* Traverse the entire project, and validate all scopes
|
|
239
241
|
*/
|
|
240
242
|
validate(): void;
|
|
243
|
+
private updateLastValidationFileInfo;
|
|
244
|
+
private logValidationMetrics;
|
|
241
245
|
private detectIncompatibleSymbolsAcrossScopes;
|
|
242
246
|
/**
|
|
243
247
|
* Flag all duplicate component names
|
package/dist/Program.js
CHANGED
|
@@ -41,6 +41,7 @@ const ComponentType_1 = require("./types/ComponentType");
|
|
|
41
41
|
const InterfaceType_1 = require("./types/InterfaceType");
|
|
42
42
|
const BuiltInInterfaceAdder_1 = require("./types/BuiltInInterfaceAdder");
|
|
43
43
|
const visitors_1 = require("./astUtils/visitors");
|
|
44
|
+
const Stopwatch_1 = require("./Stopwatch");
|
|
44
45
|
const bslibNonAliasedRokuModulesPkgPath = (0, util_1.standardizePath) `source/roku_modules/rokucommunity_bslib/bslib.brs`;
|
|
45
46
|
const bslibAliasedRokuModulesPkgPath = (0, util_1.standardizePath) `source/roku_modules/bslib/bslib.brs`;
|
|
46
47
|
class Program {
|
|
@@ -100,6 +101,7 @@ class Program {
|
|
|
100
101
|
*/
|
|
101
102
|
this.componentSymbolsToUpdate = new Set();
|
|
102
103
|
this.lastValidationInfo = new Map();
|
|
104
|
+
this.isFirstValidation = true;
|
|
103
105
|
this.getTranspiledFileContentsPipeline = new ActionPipeline_1.ActionPipeline();
|
|
104
106
|
this.buildPipeline = new ActionPipeline_1.ActionPipeline();
|
|
105
107
|
this.options = util_1.util.normalizeConfig(options);
|
|
@@ -683,100 +685,65 @@ class Program {
|
|
|
683
685
|
*/
|
|
684
686
|
validate() {
|
|
685
687
|
this.logger.time(Logger_1.LogLevel.log, ['Validating project'], () => {
|
|
686
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
687
688
|
this.diagnostics = [];
|
|
688
689
|
const programValidateEvent = {
|
|
689
690
|
program: this
|
|
690
691
|
};
|
|
691
692
|
this.plugins.emit('beforeProgramValidate', programValidateEvent);
|
|
692
693
|
this.plugins.emit('onProgramValidate', programValidateEvent);
|
|
694
|
+
const metrics = {
|
|
695
|
+
filesValidated: 0,
|
|
696
|
+
fileValidationTime: '',
|
|
697
|
+
fileInfoGenerationTime: '',
|
|
698
|
+
programValidationTime: '',
|
|
699
|
+
scopesValidated: 0,
|
|
700
|
+
totalLinkTime: '',
|
|
701
|
+
totalScopeValidationTime: '',
|
|
702
|
+
componentValidationTime: ''
|
|
703
|
+
};
|
|
704
|
+
const validationStopwatch = new Stopwatch_1.Stopwatch();
|
|
693
705
|
//validate every file
|
|
694
706
|
const brsFilesValidated = [];
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
707
|
+
const afterValidateFiles = [];
|
|
708
|
+
metrics.fileValidationTime = validationStopwatch.getDurationTextFor(() => {
|
|
709
|
+
for (const file of Object.values(this.files)) {
|
|
710
|
+
//for every unvalidated file, validate it
|
|
711
|
+
if (!file.isValidated) {
|
|
712
|
+
const validateFileEvent = {
|
|
713
|
+
program: this,
|
|
714
|
+
file: file
|
|
715
|
+
};
|
|
716
|
+
this.plugins.emit('beforeFileValidate', validateFileEvent);
|
|
717
|
+
//emit an event to allow plugins to contribute to the file validation process
|
|
718
|
+
this.plugins.emit('onFileValidate', validateFileEvent);
|
|
719
|
+
file.isValidated = true;
|
|
720
|
+
if ((0, reflection_1.isBrsFile)(file)) {
|
|
721
|
+
brsFilesValidated.push(file);
|
|
722
|
+
}
|
|
723
|
+
afterValidateFiles.push(file);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
// AfterFileValidate is after all files have been validated
|
|
727
|
+
for (const file of afterValidateFiles) {
|
|
698
728
|
const validateFileEvent = {
|
|
699
729
|
program: this,
|
|
700
730
|
file: file
|
|
701
731
|
};
|
|
702
|
-
this.plugins.emit('beforeFileValidate', validateFileEvent);
|
|
703
|
-
//emit an event to allow plugins to contribute to the file validation process
|
|
704
|
-
this.plugins.emit('onFileValidate', validateFileEvent);
|
|
705
|
-
file.isValidated = true;
|
|
706
|
-
if ((0, reflection_1.isBrsFile)(file)) {
|
|
707
|
-
brsFilesValidated.push(file);
|
|
708
|
-
}
|
|
709
732
|
this.plugins.emit('afterFileValidate', validateFileEvent);
|
|
710
733
|
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
let scopesAreInconsistent = false;
|
|
725
|
-
for (const scope of scopesToCheckForConsistency) {
|
|
726
|
-
let symbolFoundInScope = false;
|
|
727
|
-
for (const scopeFile of scope.getAllFiles()) {
|
|
728
|
-
if (!(0, reflection_1.isBrsFile)(scopeFile) || scopeFile.isTypedef || scopeFile.hasTypedef) {
|
|
729
|
-
continue;
|
|
730
|
-
}
|
|
731
|
-
const lowerFirstSymbolName = (_b = (_a = symbol.typeChain) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name.toLowerCase();
|
|
732
|
-
let symbolInThisScope = (_d = (_c = scopeFile.providedSymbols.symbolMap) === null || _c === void 0 ? void 0 : _c.get(symbol.flags)) === null || _d === void 0 ? void 0 : _d.get(lowerFirstSymbolName);
|
|
733
|
-
if (!symbolInThisScope && ((_e = symbol.containingNamespaces) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
734
|
-
const fullNameWithNamespaces = (symbol.containingNamespaces.join('.') + '.' + lowerFirstSymbolName).toLowerCase();
|
|
735
|
-
symbolInThisScope = (_g = (_f = scopeFile.providedSymbols.symbolMap) === null || _f === void 0 ? void 0 : _f.get(symbol.flags)) === null || _g === void 0 ? void 0 : _g.get(fullNameWithNamespaces);
|
|
736
|
-
}
|
|
737
|
-
if (symbolInThisScope) {
|
|
738
|
-
if (symbolFoundInScope) {
|
|
739
|
-
// this is duplicately defined!
|
|
740
|
-
fileInfo.duplicateSymbolsInSameScope.push({ symbol: symbol, scope: scope });
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
symbolFoundInScope = true;
|
|
744
|
-
scopesDefiningSymbol.push(scope);
|
|
745
|
-
//check for consistency across scopes
|
|
746
|
-
if (!providedSymbolType) {
|
|
747
|
-
providedSymbolType = symbolInThisScope.type;
|
|
748
|
-
}
|
|
749
|
-
else {
|
|
750
|
-
//get more general type
|
|
751
|
-
if (providedSymbolType.isEqual(symbolInThisScope.type)) {
|
|
752
|
-
//type in this scope is the same as one we're already checking
|
|
753
|
-
}
|
|
754
|
-
else if (providedSymbolType.isTypeCompatible(symbolInThisScope.type)) {
|
|
755
|
-
//type in this scope is compatible with one we're storing. use most generic
|
|
756
|
-
providedSymbolType = symbolInThisScope.type;
|
|
757
|
-
}
|
|
758
|
-
else if (symbolInThisScope.type.isTypeCompatible(providedSymbolType)) {
|
|
759
|
-
// type we're storing is more generic that the type in this scope
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
// type in this scope is not compatible with other types for this symbol
|
|
763
|
-
scopesAreInconsistent = true;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
if (!symbolFoundInScope) {
|
|
770
|
-
fileInfo.symbolsNotDefinedInEveryScope.push({ symbol: symbol, scope: scope });
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
if (scopesAreInconsistent) {
|
|
774
|
-
fileInfo.symbolsNotConsistentAcrossScopes.push({ symbol: symbol, scopes: scopesDefiningSymbol });
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
this.lastValidationInfo.set(file.srcPath.toLowerCase(), fileInfo);
|
|
778
|
-
}
|
|
779
|
-
this.detectIncompatibleSymbolsAcrossScopes();
|
|
734
|
+
}).durationText;
|
|
735
|
+
metrics.filesValidated = afterValidateFiles.length;
|
|
736
|
+
metrics.fileInfoGenerationTime = validationStopwatch.getDurationTextFor(() => {
|
|
737
|
+
// build list of all changed symbols in each file that changed
|
|
738
|
+
this.updateLastValidationFileInfo(brsFilesValidated);
|
|
739
|
+
}).durationText;
|
|
740
|
+
validationStopwatch.stop();
|
|
741
|
+
metrics.fileInfoGenerationTime = validationStopwatch.getDurationText();
|
|
742
|
+
validationStopwatch.reset();
|
|
743
|
+
validationStopwatch.start();
|
|
744
|
+
metrics.programValidationTime = validationStopwatch.getDurationTextFor(() => {
|
|
745
|
+
this.detectIncompatibleSymbolsAcrossScopes();
|
|
746
|
+
}).durationText;
|
|
780
747
|
// Build component types for any component that changes
|
|
781
748
|
this.logger.time(Logger_1.LogLevel.info, ['Build component types'], () => {
|
|
782
749
|
for (let { componentKey, componentName } of this.componentSymbolsToUpdate) {
|
|
@@ -795,16 +762,110 @@ class Program {
|
|
|
795
762
|
const changedSymbolsSetArr = changedSymbolsMapArr.map(symMap => symMap.get(flag));
|
|
796
763
|
changedSymbols.set(flag, new Set(...changedSymbolsSetArr));
|
|
797
764
|
}
|
|
765
|
+
let linkTime = 0;
|
|
766
|
+
let validationTime = 0;
|
|
767
|
+
let scopesValidated = 0;
|
|
798
768
|
this.logger.time(Logger_1.LogLevel.info, ['Validate all scopes'], () => {
|
|
799
769
|
for (let scopeName in this.scopes) {
|
|
800
770
|
let scope = this.scopes[scopeName];
|
|
801
|
-
scope.validate({ changedFiles:
|
|
771
|
+
const scopeValidated = scope.validate({ changedFiles: afterValidateFiles, changedSymbols: changedSymbols, initialValidation: this.isFirstValidation });
|
|
772
|
+
if (scopeValidated) {
|
|
773
|
+
scopesValidated++;
|
|
774
|
+
}
|
|
775
|
+
linkTime += scope.validationMetrics.linkTime;
|
|
776
|
+
validationTime += scope.validationMetrics.validationTime;
|
|
802
777
|
}
|
|
803
778
|
});
|
|
804
|
-
|
|
779
|
+
metrics.scopesValidated = scopesValidated;
|
|
780
|
+
validationStopwatch.totalMilliseconds = linkTime;
|
|
781
|
+
metrics.totalLinkTime = validationStopwatch.getDurationText();
|
|
782
|
+
validationStopwatch.totalMilliseconds = validationTime;
|
|
783
|
+
metrics.totalScopeValidationTime = validationStopwatch.getDurationText();
|
|
784
|
+
metrics.componentValidationTime = validationStopwatch.getDurationTextFor(() => {
|
|
785
|
+
this.detectDuplicateComponentNames();
|
|
786
|
+
}).durationText;
|
|
787
|
+
this.logValidationMetrics(metrics);
|
|
788
|
+
this.isFirstValidation = false;
|
|
805
789
|
this.plugins.emit('afterProgramValidate', programValidateEvent);
|
|
806
790
|
});
|
|
807
791
|
}
|
|
792
|
+
updateLastValidationFileInfo(brsFilesValidated) {
|
|
793
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
794
|
+
this.lastValidationInfo.clear();
|
|
795
|
+
for (const file of brsFilesValidated) {
|
|
796
|
+
const fileInfo = {
|
|
797
|
+
symbolsNotDefinedInEveryScope: [],
|
|
798
|
+
duplicateSymbolsInSameScope: [],
|
|
799
|
+
symbolsNotConsistentAcrossScopes: []
|
|
800
|
+
};
|
|
801
|
+
const scopesToCheckForConsistency = this.getScopesForFile(file);
|
|
802
|
+
for (const symbol of file.requiredSymbols) {
|
|
803
|
+
let providedSymbolType;
|
|
804
|
+
let scopesDefiningSymbol = [];
|
|
805
|
+
let scopesAreInconsistent = false;
|
|
806
|
+
for (const scope of scopesToCheckForConsistency) {
|
|
807
|
+
let symbolFoundInScope = false;
|
|
808
|
+
for (const scopeFile of scope.getAllFiles()) {
|
|
809
|
+
if (!(0, reflection_1.isBrsFile)(scopeFile) || scopeFile.isTypedef || scopeFile.hasTypedef) {
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
const lowerFirstSymbolName = (_b = (_a = symbol.typeChain) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name.toLowerCase();
|
|
813
|
+
let symbolInThisScope = (_d = (_c = scopeFile.providedSymbols.symbolMap) === null || _c === void 0 ? void 0 : _c.get(symbol.flags)) === null || _d === void 0 ? void 0 : _d.get(lowerFirstSymbolName);
|
|
814
|
+
if (!symbolInThisScope && ((_e = symbol.containingNamespaces) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
815
|
+
const fullNameWithNamespaces = (symbol.containingNamespaces.join('.') + '.' + lowerFirstSymbolName).toLowerCase();
|
|
816
|
+
symbolInThisScope = (_g = (_f = scopeFile.providedSymbols.symbolMap) === null || _f === void 0 ? void 0 : _f.get(symbol.flags)) === null || _g === void 0 ? void 0 : _g.get(fullNameWithNamespaces);
|
|
817
|
+
}
|
|
818
|
+
if (symbolInThisScope) {
|
|
819
|
+
if (symbolFoundInScope) {
|
|
820
|
+
// this is duplicately defined!
|
|
821
|
+
fileInfo.duplicateSymbolsInSameScope.push({ symbol: symbol, scope: scope });
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
symbolFoundInScope = true;
|
|
825
|
+
scopesDefiningSymbol.push(scope);
|
|
826
|
+
//check for consistency across scopes
|
|
827
|
+
if (!providedSymbolType) {
|
|
828
|
+
providedSymbolType = symbolInThisScope.type;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
//get more general type
|
|
832
|
+
if (providedSymbolType.isEqual(symbolInThisScope.type)) {
|
|
833
|
+
//type in this scope is the same as one we're already checking
|
|
834
|
+
}
|
|
835
|
+
else if (providedSymbolType.isTypeCompatible(symbolInThisScope.type)) {
|
|
836
|
+
//type in this scope is compatible with one we're storing. use most generic
|
|
837
|
+
providedSymbolType = symbolInThisScope.type;
|
|
838
|
+
}
|
|
839
|
+
else if (symbolInThisScope.type.isTypeCompatible(providedSymbolType)) {
|
|
840
|
+
// type we're storing is more generic that the type in this scope
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
// type in this scope is not compatible with other types for this symbol
|
|
844
|
+
scopesAreInconsistent = true;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (!symbolFoundInScope) {
|
|
851
|
+
fileInfo.symbolsNotDefinedInEveryScope.push({ symbol: symbol, scope: scope });
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
if (scopesAreInconsistent) {
|
|
855
|
+
fileInfo.symbolsNotConsistentAcrossScopes.push({ symbol: symbol, scopes: scopesDefiningSymbol });
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
this.lastValidationInfo.set(file.srcPath.toLowerCase(), fileInfo);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
|
862
|
+
logValidationMetrics(metrics) {
|
|
863
|
+
let logs = [];
|
|
864
|
+
for (const key in metrics) {
|
|
865
|
+
logs.push(`${key}=${chalk_1.default.yellow(metrics[key].toString())}`);
|
|
866
|
+
}
|
|
867
|
+
this.logger.info(`Validation Metrics: ${logs.join(', ')}`);
|
|
868
|
+
}
|
|
808
869
|
detectIncompatibleSymbolsAcrossScopes() {
|
|
809
870
|
for (const [lowerFilePath, fileInfo] of this.lastValidationInfo.entries()) {
|
|
810
871
|
const file = this.files[lowerFilePath];
|