@lcap/nasl-language-server-core 3.14.0-rc.3 → 3.14.0-rc.5
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 +93 -36
- package/out/checker.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/module/graph.js +6 -6
- package/out/module/graph.js.map +1 -1
- package/out/module/module.d.ts.map +1 -1
- package/out/module/module.js +3 -6
- package/out/module/module.js.map +1 -1
- package/out/reference-manager/builtin-q-name.d.ts +8 -1
- package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
- package/out/reference-manager/builtin-q-name.js +55 -1
- package/out/reference-manager/builtin-q-name.js.map +1 -1
- package/out/reference-manager/get-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +14 -6
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +221 -111
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/rename-q-name.d.ts.map +1 -1
- package/out/reference-manager/rename-q-name.js +3 -0
- package/out/reference-manager/rename-q-name.js.map +1 -1
- package/out/reference-manager/symbol-type.d.ts +5 -3
- package/out/reference-manager/symbol-type.d.ts.map +1 -1
- package/out/reference-manager/symbol-type.js +11 -8
- package/out/reference-manager/symbol-type.js.map +1 -1
- package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
- package/out/reference-manager/update-nasl-fragment.js +5 -4
- package/out/reference-manager/update-nasl-fragment.js.map +1 -1
- package/out/symbol/graph.js +2 -2
- package/out/symbol/graph.js.map +1 -1
- package/out/typer/collectGlobalDefs.d.ts.map +1 -1
- package/out/typer/collectGlobalDefs.js +79 -15
- package/out/typer/collectGlobalDefs.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.d.ts +11 -7
- package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +17 -6
- package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
- package/out/typer/component-def-manager/utils.d.ts.map +1 -1
- package/out/typer/component-def-manager/utils.js +5 -3
- package/out/typer/component-def-manager/utils.js.map +1 -1
- package/out/typer/dispatch-def.d.ts +0 -2
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +15 -43
- package/out/typer/dispatch-def.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +135 -97
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-process.d.ts +0 -1
- package/out/typer/dispatch-process.d.ts.map +1 -1
- package/out/typer/dispatch-process.js +22 -14
- package/out/typer/dispatch-process.js.map +1 -1
- package/out/typer/dispatch-stmt.d.ts.map +1 -1
- package/out/typer/dispatch-stmt.js +30 -21
- package/out/typer/dispatch-stmt.js.map +1 -1
- package/out/typer/dispatch-view.d.ts.map +1 -1
- package/out/typer/dispatch-view.js +90 -40
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/incremental-update.d.ts +7 -30
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +133 -217
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/index.d.ts +3 -4
- package/out/typer/index.d.ts.map +1 -1
- package/out/typer/index.js +4 -4
- package/out/typer/index.js.map +1 -1
- package/out/typer/sem-diag.d.ts +1 -0
- package/out/typer/sem-diag.d.ts.map +1 -1
- package/out/typer/sem-diag.js +24 -17
- package/out/typer/sem-diag.js.map +1 -1
- package/out/typer/solver.d.ts +1 -0
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +9 -1
- package/out/typer/solver.js.map +1 -1
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +21 -10
- package/out/typer/subster.js.map +1 -1
- package/out/typer/type-manager.d.ts +3 -2
- package/out/typer/type-manager.d.ts.map +1 -1
- package/out/typer/type-manager.js +30 -20
- package/out/typer/type-manager.js.map +1 -1
- package/out/typer/type-predicate.d.ts +15 -2
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +56 -24
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +25 -2
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +39 -7
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +37 -27
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts +2 -0
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +7 -2
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts +2 -2
- package/out/utils/type-operator.d.ts.map +1 -1
- package/out/utils/type-operator.js +24 -7
- package/out/utils/type-operator.js.map +1 -1
- package/package.json +5 -6
- package/out/utils/vue-hack.d.ts +0 -25
- package/out/utils/vue-hack.d.ts.map +0 -1
- package/out/utils/vue-hack.js +0 -33
- package/out/utils/vue-hack.js.map +0 -1
- package/out/utils/vue.d.ts +0 -2
- package/out/utils/vue.d.ts.map +0 -1
- package/out/utils/vue.js +0 -10
- package/out/utils/vue.js.map +0 -1
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,EAEpF,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhE,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
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,EAEpF,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhE,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,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,QAAQ,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAMF,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAMrE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAqBF,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,yBAAyB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAuPF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe;oCA0/HpB,OAAO;sDAPW,gBAAgB,EAAE;;;;sBAfjD,UAAU,GAAG,SAAS;;;8BA2Df,UAAU;2BAsBb,UAAU;;kBArhInB,UAAU,WAAW,MAAM,YAAY,YAAY;EAuiIzE;AAGD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACrC,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,6BAA6B,aAAc,UAAU,sCAAoC,MAAM,gBAAgB,CAmC3H,CAAA;AAMD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/out/checker.js
CHANGED
|
@@ -693,7 +693,7 @@ function createErrorDiagnoser(context) {
|
|
|
693
693
|
/**
|
|
694
694
|
* 检查 调用表达式的参数
|
|
695
695
|
* @param node
|
|
696
|
-
* @param
|
|
696
|
+
*( @param r) as anyef
|
|
697
697
|
*/
|
|
698
698
|
function* checkCallExpressionParameters(node, ref) {
|
|
699
699
|
// Handle both TypeAnnotation and FunctionDefinition formats
|
|
@@ -817,12 +817,11 @@ function createErrorDiagnoser(context) {
|
|
|
817
817
|
const type = yield* checkNode(node);
|
|
818
818
|
if (isUnresolvedType(type)) {
|
|
819
819
|
const scope = node?.constructor?.nodeTitle;
|
|
820
|
-
if (node.concept === 'Identifier') {
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
}
|
|
820
|
+
// if (node.concept === 'Identifier') {
|
|
821
|
+
// error(node, `${scope}:${node.name} 未定义。`);
|
|
822
|
+
// } else {
|
|
823
|
+
error(node, `${scope}:所选择的内容未定义。`);
|
|
824
|
+
// }
|
|
826
825
|
return errorType;
|
|
827
826
|
}
|
|
828
827
|
return type;
|
|
@@ -1148,13 +1147,14 @@ function createErrorDiagnoser(context) {
|
|
|
1148
1147
|
}
|
|
1149
1148
|
}
|
|
1150
1149
|
/**
|
|
1151
|
-
*
|
|
1150
|
+
* 检查【局部】变量
|
|
1152
1151
|
* @param node
|
|
1153
1152
|
*/
|
|
1154
1153
|
function* checkVariable(node) {
|
|
1155
1154
|
yield* checkNode(node.defaultValue);
|
|
1156
1155
|
// 前面加了报错,省点时间,报错不用那么精确
|
|
1157
1156
|
// yield* checkVariableType(node);
|
|
1157
|
+
yield* checkNode(node.typeAnnotation);
|
|
1158
1158
|
}
|
|
1159
1159
|
/**
|
|
1160
1160
|
* 检查 前端全局变量
|
|
@@ -1679,6 +1679,7 @@ function createErrorDiagnoser(context) {
|
|
|
1679
1679
|
yield* checkNode(node.defaultValue);
|
|
1680
1680
|
// 前面加了报错,省点时间,报错不用那么精确
|
|
1681
1681
|
// yield* checkVariableType(node);
|
|
1682
|
+
yield* checkNode(node.typeAnnotation);
|
|
1682
1683
|
}
|
|
1683
1684
|
/**
|
|
1684
1685
|
* 检查 接口
|
|
@@ -1825,6 +1826,7 @@ function createErrorDiagnoser(context) {
|
|
|
1825
1826
|
...(node.variables || []),
|
|
1826
1827
|
...(node.logics || []),
|
|
1827
1828
|
]);
|
|
1829
|
+
checkVariableAndReturnTypeAnnotations(node.variables, [], false);
|
|
1828
1830
|
const module = node.getAncestor('Module');
|
|
1829
1831
|
if (!(module?.parentKey === 'dependencies')) {
|
|
1830
1832
|
if (node.params?.length) {
|
|
@@ -1955,6 +1957,21 @@ function createErrorDiagnoser(context) {
|
|
|
1955
1957
|
if (node._foldInView) {
|
|
1956
1958
|
error(node, `组件${node.name}已经极速折叠`);
|
|
1957
1959
|
}
|
|
1960
|
+
// 已知:选择器会漏报,因为 children 里是两个空 template。暂时先这样吧。
|
|
1961
|
+
let dsFilled = true;
|
|
1962
|
+
let errNode = node;
|
|
1963
|
+
const ds = node.bindAttrs.find(nd => nd.name === 'dataSource');
|
|
1964
|
+
if (ds) {
|
|
1965
|
+
if (ds.type === 'dynamic' && !ds.expression) {
|
|
1966
|
+
dsFilled = false;
|
|
1967
|
+
errNode = ds;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
const hasSubComponents = node.children.filter(c => c.tag !== 'template').length > 0 ||
|
|
1971
|
+
node.children.filter(c => c.tag === 'template').some(cc => cc.children.length > 0);
|
|
1972
|
+
if (!dsFilled && !hasSubComponents) {
|
|
1973
|
+
error(errNode, '数据源不能为空');
|
|
1974
|
+
}
|
|
1958
1975
|
unbindVariables?.();
|
|
1959
1976
|
}
|
|
1960
1977
|
/**
|
|
@@ -2215,7 +2232,8 @@ function createErrorDiagnoser(context) {
|
|
|
2215
2232
|
yield* checkNode(node.bind);
|
|
2216
2233
|
if (node.processDefinitions?.length) {
|
|
2217
2234
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.processDefinitions, function* (node) {
|
|
2218
|
-
|
|
2235
|
+
// 现有流程版本 [v1, v2],加个 v3 后,变成了 [proxy(v1), proxy(v2), v3],无法理解
|
|
2236
|
+
yield* checkNode(toRaw(node));
|
|
2219
2237
|
});
|
|
2220
2238
|
}
|
|
2221
2239
|
if (node?.subLogics?.length) {
|
|
@@ -2391,7 +2409,7 @@ function createErrorDiagnoser(context) {
|
|
|
2391
2409
|
const prop = getPropertyOfType(type, propertyName);
|
|
2392
2410
|
if (!prop) {
|
|
2393
2411
|
const scope = item?.constructor?.nodeTitle;
|
|
2394
|
-
error(item, `${scope}:找不到 ${type
|
|
2412
|
+
error(item, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
2395
2413
|
}
|
|
2396
2414
|
type = env.getType(prop);
|
|
2397
2415
|
if (type?.typeKind === 'generic' && type.typeName === 'List') {
|
|
@@ -2419,6 +2437,10 @@ function createErrorDiagnoser(context) {
|
|
|
2419
2437
|
...(node.variables || []),
|
|
2420
2438
|
...(node.virtualParams || [])
|
|
2421
2439
|
]);
|
|
2440
|
+
// 仅检查用户写的逻辑
|
|
2441
|
+
// if (node.nodePath?.startsWith('app.logics')) {
|
|
2442
|
+
checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
|
|
2443
|
+
// }
|
|
2422
2444
|
const module = node.getAncestor('Module');
|
|
2423
2445
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2424
2446
|
if (node.params?.length) {
|
|
@@ -2613,6 +2635,9 @@ function createErrorDiagnoser(context) {
|
|
|
2613
2635
|
...(node.returns || []),
|
|
2614
2636
|
...(node.variables || []),
|
|
2615
2637
|
]);
|
|
2638
|
+
// if (nd.nodePath?.startsWith('app.logics')) {
|
|
2639
|
+
checkVariableAndReturnTypeAnnotations(node.variables, node.returns);
|
|
2640
|
+
// }
|
|
2616
2641
|
const module = node.getAncestor('Module');
|
|
2617
2642
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2618
2643
|
if (node.params?.length) {
|
|
@@ -2702,30 +2727,27 @@ function createErrorDiagnoser(context) {
|
|
|
2702
2727
|
if (!ensureNodeKeyExists(node, 'calleeName')) {
|
|
2703
2728
|
return;
|
|
2704
2729
|
}
|
|
2705
|
-
const ref = env.
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
yield* checkScopeOfUse(node, ref);
|
|
2713
|
-
yield* checkCallExpressionParameters(node, ref);
|
|
2714
|
-
}
|
|
2715
|
-
else if (ref && !typeUnresolved) {
|
|
2716
|
-
// 检查使用范围
|
|
2717
|
-
yield* checkScopeOfUse(node, ref);
|
|
2718
|
-
yield* checkCallExpressionParameters(node, ref);
|
|
2719
|
-
}
|
|
2720
|
-
else {
|
|
2721
|
-
if (ref.depLibName) {
|
|
2722
|
-
error(node, `找不到依赖库 ${ref.depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2730
|
+
const ref = env.resolveRef(node); // 前端
|
|
2731
|
+
// TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
|
|
2732
|
+
// 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
|
|
2733
|
+
if (!ref && !isBuiltInCall(node)) {
|
|
2734
|
+
const depLibName = getExtensionLibName(node);
|
|
2735
|
+
if (depLibName) {
|
|
2736
|
+
error(node, `找不到依赖库 ${depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2723
2737
|
}
|
|
2724
2738
|
else {
|
|
2725
2739
|
error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2726
2740
|
}
|
|
2727
2741
|
return errorType;
|
|
2728
2742
|
}
|
|
2743
|
+
/**
|
|
2744
|
+
* 目前的 callInfo:所有内置函数 + 服务端调用。前端因为有组件库调用,还没统一
|
|
2745
|
+
* 排除未求解出类型变元等引发的报错,这些不应该报 '找不到'
|
|
2746
|
+
*/
|
|
2747
|
+
// FIXME: wudengke 帮帮忙,行行好
|
|
2748
|
+
const callInfo = env.resolvedCallInfo.get(node);
|
|
2749
|
+
yield* checkScopeOfUse(node, (callInfo ?? ref));
|
|
2750
|
+
yield* checkCallExpressionParameters(node, (callInfo ?? ref));
|
|
2729
2751
|
switch (node.concept) {
|
|
2730
2752
|
case 'CallFunction':
|
|
2731
2753
|
return yield* checkCallFunction(node);
|
|
@@ -3098,18 +3120,29 @@ function createErrorDiagnoser(context) {
|
|
|
3098
3120
|
}
|
|
3099
3121
|
});
|
|
3100
3122
|
}
|
|
3123
|
+
else if (!isOtherCase(node)) {
|
|
3124
|
+
// pattern 为空时,如果不是其他就报错
|
|
3125
|
+
error(node, '匹配分支:匹配模式不能为空', {
|
|
3126
|
+
titleTip: '匹配模式不能为空',
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3101
3129
|
if (node.body?.length) {
|
|
3102
3130
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.body, function* (node) {
|
|
3103
3131
|
yield* checkNode(node);
|
|
3104
3132
|
});
|
|
3105
3133
|
}
|
|
3106
|
-
if (match?.isExpression && node.body.length === 0) {
|
|
3107
|
-
//
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3134
|
+
if (match?.isExpression && node.body.length === 0 && !isOtherCase(node)) {
|
|
3135
|
+
// 如果不是其他就报错
|
|
3136
|
+
error(node, '匹配分支:返回内容不能为空', {
|
|
3137
|
+
titleTip: '返回内容不能为空',
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
function isOtherCase(node) {
|
|
3141
|
+
const indexInParent = node.getIndexOfParent();
|
|
3142
|
+
if (indexInParent === -1) {
|
|
3143
|
+
return false;
|
|
3112
3144
|
}
|
|
3145
|
+
return indexInParent === match.cases.length - 1;
|
|
3113
3146
|
}
|
|
3114
3147
|
}
|
|
3115
3148
|
/**
|
|
@@ -3256,7 +3289,7 @@ function createErrorDiagnoser(context) {
|
|
|
3256
3289
|
}
|
|
3257
3290
|
else {
|
|
3258
3291
|
const scope = node?.constructor?.nodeTitle;
|
|
3259
|
-
error(node, `${scope}:找不到 ${type
|
|
3292
|
+
error(node, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${nodeProperty?.name}。`);
|
|
3260
3293
|
return errorType;
|
|
3261
3294
|
}
|
|
3262
3295
|
return env.getType(node);
|
|
@@ -3400,7 +3433,7 @@ function createErrorDiagnoser(context) {
|
|
|
3400
3433
|
}
|
|
3401
3434
|
else {
|
|
3402
3435
|
const scope = property?.constructor?.nodeTitle;
|
|
3403
|
-
error(property, `${scope}:找不到 ${type
|
|
3436
|
+
error(property, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
3404
3437
|
}
|
|
3405
3438
|
});
|
|
3406
3439
|
}
|
|
@@ -4168,6 +4201,26 @@ function createErrorDiagnoser(context) {
|
|
|
4168
4201
|
function setMetadataTypeEnable(enable) {
|
|
4169
4202
|
metadataTypeEnable = enable;
|
|
4170
4203
|
}
|
|
4204
|
+
const checkVariableAndReturnTypeAnnotations = (variables, returns, inLogic = true) => {
|
|
4205
|
+
for (const v of variables) {
|
|
4206
|
+
if (v.typeAnnotation)
|
|
4207
|
+
continue;
|
|
4208
|
+
const tyAnn = v.__TypeAnnotation;
|
|
4209
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4210
|
+
error(v, `局部变量 ${v.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4211
|
+
v.__TypeAnnotation = undefined;
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
for (const r of returns) {
|
|
4215
|
+
if (r.typeAnnotation)
|
|
4216
|
+
continue;
|
|
4217
|
+
const tyAnn = r.__TypeAnnotation;
|
|
4218
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4219
|
+
error(r, `输出参数 ${r.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4220
|
+
r.__TypeAnnotation = undefined;
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
};
|
|
4171
4224
|
/**
|
|
4172
4225
|
* 诊断App
|
|
4173
4226
|
* @param app
|
|
@@ -4258,4 +4311,8 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
|
4258
4311
|
exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
4259
4312
|
// @ts-expect-error
|
|
4260
4313
|
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
4314
|
+
// 是否来自系统内置
|
|
4315
|
+
const isBuiltInCall = (nd) => nd.calleeNamespace.startsWith('nasl.');
|
|
4316
|
+
// 是否来自依赖库
|
|
4317
|
+
const getExtensionLibName = (nd) => nd.calleeNamespace.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
|
|
4261
4318
|
//# sourceMappingURL=checker.js.map
|