@lcap/nasl-language-server-core 4.3.0-beta.4 → 4.3.0-beta.6
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/out/checker.d.ts.map +1 -1
- package/out/checker.js +47 -2
- package/out/checker.js.map +1 -1
- package/out/typer/dispatch-call.d.ts.map +1 -1
- package/out/typer/dispatch-call.js +9 -3
- package/out/typer/dispatch-call.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +6 -1
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/get-oql-files.d.ts.map +1 -1
- package/out/typer/get-oql-files.js +18 -27
- package/out/typer/get-oql-files.js.map +1 -1
- package/out/typer/type-manager.d.ts.map +1 -1
- package/out/typer/type-manager.js +13 -14
- package/out/typer/type-manager.js.map +1 -1
- package/out/typer/type-predicate.d.ts +12 -0
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +19 -1
- package/out/typer/type-predicate.js.map +1 -1
- package/package.json +7 -6
package/out/checker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU0F,GAAG,EAMvG,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACgE,cAAc,EAGpF,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKpE,oBAAY,QAAQ;IAClB,IAAI,YAAY;IAChB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAEnE,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,QAA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BAA6B,aAC9B,UAAU,+DAGnB,MAAM,gBAAgB,CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/out/checker.js
CHANGED
|
@@ -322,6 +322,9 @@ function createErrorDiagnoser(context) {
|
|
|
322
322
|
}
|
|
323
323
|
else { }
|
|
324
324
|
}
|
|
325
|
+
function formatNodeConcept(node) {
|
|
326
|
+
return node?.constructor?.nodeTitle;
|
|
327
|
+
}
|
|
325
328
|
function scopedError(node, message, context) {
|
|
326
329
|
const scope = node?.constructor?.nodeTitle;
|
|
327
330
|
if (scope) {
|
|
@@ -899,11 +902,12 @@ function createErrorDiagnoser(context) {
|
|
|
899
902
|
/**
|
|
900
903
|
* 检查 草稿区
|
|
901
904
|
*/
|
|
902
|
-
function* checkPlayground(playground) {
|
|
905
|
+
function* checkPlayground(playground, extraCheck) {
|
|
903
906
|
if (playground?.length) {
|
|
904
907
|
inPlayground++;
|
|
905
908
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(playground, function* (node) {
|
|
906
909
|
yield* checkNode(node);
|
|
910
|
+
extraCheck?.(node);
|
|
907
911
|
});
|
|
908
912
|
inPlayground--;
|
|
909
913
|
}
|
|
@@ -2692,12 +2696,53 @@ function createErrorDiagnoser(context) {
|
|
|
2692
2696
|
});
|
|
2693
2697
|
}
|
|
2694
2698
|
}
|
|
2699
|
+
const ty = context.env.getType(node);
|
|
2700
|
+
const ancestorSubLogic = node.getAncestor('SubLogic');
|
|
2701
|
+
const shouldReportAsyncAsError = !(ancestorSubLogic && ancestorSubLogic !== node) && (0, type_predicate_1.isSyncFuncTy)(ty);
|
|
2702
|
+
const subLogicNode = node;
|
|
2703
|
+
function checkAsync(current, subLogicNode) {
|
|
2704
|
+
if (shouldReportAsyncAsError) {
|
|
2705
|
+
current.traverseStrictChildren((n) => {
|
|
2706
|
+
if (!n)
|
|
2707
|
+
return;
|
|
2708
|
+
if (isAsyncNode(n)) {
|
|
2709
|
+
error(n, `同步执行的子逻辑 ${subLogicNode.name} 中不支持使用 ${formatNodeConcept(n)}`);
|
|
2710
|
+
}
|
|
2711
|
+
function isAsyncNode(node) {
|
|
2712
|
+
switch (node.concept) {
|
|
2713
|
+
case 'CallLogic': {
|
|
2714
|
+
const callee = context.env.resolveRef(node);
|
|
2715
|
+
if (callee) {
|
|
2716
|
+
const funTy = context.env.getType(callee);
|
|
2717
|
+
if (funTy) {
|
|
2718
|
+
return (0, type_predicate_1.isAsyncFuncTy)(funTy);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
case 'Unparsed':
|
|
2723
|
+
case 'CallConnector':
|
|
2724
|
+
case 'CallFunction':
|
|
2725
|
+
case 'JSBlock':
|
|
2726
|
+
case 'CallInterface': {
|
|
2727
|
+
return true;
|
|
2728
|
+
}
|
|
2729
|
+
default: {
|
|
2730
|
+
return false;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
});
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2695
2737
|
if (node.body?.length) {
|
|
2696
2738
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.body, function* (node) {
|
|
2739
|
+
checkAsync(node, subLogicNode);
|
|
2697
2740
|
yield* checkNode(node);
|
|
2698
2741
|
});
|
|
2699
2742
|
}
|
|
2700
|
-
yield* checkPlayground(node.playground)
|
|
2743
|
+
yield* checkPlayground(node.playground, (n) => {
|
|
2744
|
+
checkAsync(n, subLogicNode);
|
|
2745
|
+
});
|
|
2701
2746
|
env.exitScope();
|
|
2702
2747
|
return env.getType(node);
|
|
2703
2748
|
}
|