@fairfox/polly 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/teach/src/cli.js +106 -3
- package/dist/tools/teach/src/cli.js.map +5 -5
- package/dist/tools/teach/src/index.js +86 -3
- package/dist/tools/teach/src/index.js.map +4 -4
- package/dist/tools/verify/Dockerfile +18 -0
- package/dist/tools/verify/src/cli.js +235 -50
- package/dist/tools/verify/src/cli.js.map +8 -8
- package/dist/tools/visualize/src/cli.js +84 -2
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +1 -1
|
@@ -1573,17 +1573,21 @@ class HandlerExtractor {
|
|
|
1573
1573
|
const handlers = [];
|
|
1574
1574
|
const messageTypes = new Set;
|
|
1575
1575
|
const invalidMessageTypes = new Set;
|
|
1576
|
+
const stateConstraints = [];
|
|
1576
1577
|
const sourceFiles = this.project.getSourceFiles();
|
|
1577
1578
|
this.debugLogSourceFiles(sourceFiles);
|
|
1578
1579
|
for (const sourceFile of sourceFiles) {
|
|
1579
1580
|
const fileHandlers = this.extractFromFile(sourceFile);
|
|
1580
1581
|
handlers.push(...fileHandlers);
|
|
1581
1582
|
this.categorizeHandlerMessageTypes(fileHandlers, messageTypes, invalidMessageTypes);
|
|
1583
|
+
const fileConstraints = this.extractStateConstraintsFromFile(sourceFile);
|
|
1584
|
+
stateConstraints.push(...fileConstraints);
|
|
1582
1585
|
}
|
|
1583
1586
|
this.debugLogExtractionResults(handlers.length, invalidMessageTypes.size);
|
|
1584
1587
|
return {
|
|
1585
1588
|
handlers,
|
|
1586
|
-
messageTypes
|
|
1589
|
+
messageTypes,
|
|
1590
|
+
stateConstraints
|
|
1587
1591
|
};
|
|
1588
1592
|
}
|
|
1589
1593
|
debugLogSourceFiles(sourceFiles) {
|
|
@@ -2415,6 +2419,84 @@ class HandlerExtractor {
|
|
|
2415
2419
|
mutations.push({ field, line, afterAwait });
|
|
2416
2420
|
}
|
|
2417
2421
|
}
|
|
2422
|
+
extractStateConstraintsFromFile(sourceFile) {
|
|
2423
|
+
const constraints = [];
|
|
2424
|
+
const filePath = sourceFile.getFilePath();
|
|
2425
|
+
sourceFile.forEachDescendant((node) => {
|
|
2426
|
+
const nodeConstraints = this.recognizeStateConstraint(node, filePath);
|
|
2427
|
+
constraints.push(...nodeConstraints);
|
|
2428
|
+
});
|
|
2429
|
+
return constraints;
|
|
2430
|
+
}
|
|
2431
|
+
recognizeStateConstraint(node, filePath) {
|
|
2432
|
+
if (!Node4.isCallExpression(node)) {
|
|
2433
|
+
return [];
|
|
2434
|
+
}
|
|
2435
|
+
const expression = node.getExpression();
|
|
2436
|
+
if (!Node4.isIdentifier(expression)) {
|
|
2437
|
+
return [];
|
|
2438
|
+
}
|
|
2439
|
+
const functionName = expression.getText();
|
|
2440
|
+
if (functionName !== "$constraints") {
|
|
2441
|
+
return [];
|
|
2442
|
+
}
|
|
2443
|
+
const args = node.getArguments();
|
|
2444
|
+
if (args.length < 2) {
|
|
2445
|
+
return [];
|
|
2446
|
+
}
|
|
2447
|
+
const fieldArg = args[0];
|
|
2448
|
+
if (!Node4.isStringLiteral(fieldArg)) {
|
|
2449
|
+
return [];
|
|
2450
|
+
}
|
|
2451
|
+
const field = fieldArg.getLiteralValue();
|
|
2452
|
+
const constraintsArg = args[1];
|
|
2453
|
+
if (!Node4.isObjectLiteralExpression(constraintsArg)) {
|
|
2454
|
+
return [];
|
|
2455
|
+
}
|
|
2456
|
+
const results = [];
|
|
2457
|
+
for (const property of constraintsArg.getProperties()) {
|
|
2458
|
+
if (!Node4.isPropertyAssignment(property)) {
|
|
2459
|
+
continue;
|
|
2460
|
+
}
|
|
2461
|
+
const messageType = property.getName();
|
|
2462
|
+
const initializer = property.getInitializer();
|
|
2463
|
+
if (!initializer || !Node4.isObjectLiteralExpression(initializer)) {
|
|
2464
|
+
continue;
|
|
2465
|
+
}
|
|
2466
|
+
let requires;
|
|
2467
|
+
let ensures;
|
|
2468
|
+
let message;
|
|
2469
|
+
for (const constraintProp of initializer.getProperties()) {
|
|
2470
|
+
if (!Node4.isPropertyAssignment(constraintProp)) {
|
|
2471
|
+
continue;
|
|
2472
|
+
}
|
|
2473
|
+
const propName = constraintProp.getName();
|
|
2474
|
+
const propValue = constraintProp.getInitializer();
|
|
2475
|
+
if (!propValue) {
|
|
2476
|
+
continue;
|
|
2477
|
+
}
|
|
2478
|
+
if (propName === "requires" && Node4.isStringLiteral(propValue)) {
|
|
2479
|
+
requires = propValue.getLiteralValue();
|
|
2480
|
+
} else if (propName === "ensures" && Node4.isStringLiteral(propValue)) {
|
|
2481
|
+
ensures = propValue.getLiteralValue();
|
|
2482
|
+
} else if (propName === "message" && Node4.isStringLiteral(propValue)) {
|
|
2483
|
+
message = propValue.getLiteralValue();
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
results.push({
|
|
2487
|
+
field,
|
|
2488
|
+
messageType,
|
|
2489
|
+
requires,
|
|
2490
|
+
ensures,
|
|
2491
|
+
message,
|
|
2492
|
+
location: {
|
|
2493
|
+
file: filePath,
|
|
2494
|
+
line: property.getStartLineNumber()
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
return results;
|
|
2499
|
+
}
|
|
2418
2500
|
}
|
|
2419
2501
|
|
|
2420
2502
|
// tools/analysis/src/extract/integrations.ts
|
|
@@ -4717,4 +4799,4 @@ main().catch((_error) => {
|
|
|
4717
4799
|
process.exit(1);
|
|
4718
4800
|
});
|
|
4719
4801
|
|
|
4720
|
-
//# debugId=
|
|
4802
|
+
//# debugId=4E2F22D76354977564756E2164756E21
|