@lcap/nasl-language-server-core 3.14.0-rc.3 → 3.14.0-rc.4
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 +88 -34
- 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/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/reference-manager.d.ts +3 -1
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +166 -56
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/symbol-type.d.ts +2 -2
- package/out/reference-manager/symbol-type.d.ts.map +1 -1
- package/out/reference-manager/symbol-type.js +2 -1
- package/out/reference-manager/symbol-type.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/dispatch-def.d.ts +0 -2
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +10 -38
- 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 +55 -68
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-process.d.ts.map +1 -1
- package/out/typer/dispatch-process.js +4 -2
- 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 +26 -20
- 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 +6 -3
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/incremental-update.d.ts +1 -1
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +18 -14
- 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 +20 -6
- package/out/typer/subster.js.map +1 -1
- package/out/typer/type-manager.d.ts +1 -2
- package/out/typer/type-manager.d.ts.map +1 -1
- package/out/typer/type-manager.js +22 -17
- package/out/typer/type-manager.js.map +1 -1
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +2 -1
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +14 -2
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +20 -2
- 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 +4 -2
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts +1 -1
- package/out/utils/type-operator.d.ts.map +1 -1
- package/out/utils/type-operator.js +18 -3
- package/out/utils/type-operator.js.map +1 -1
- package/package.json +5 -5
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;oCAu/HpB,OAAO;sDAPW,gBAAgB,EAAE;;;;sBAfjD,UAAU,GAAG,SAAS;;;8BA2Df,UAAU;2BAsBb,UAAU;;kBAlhInB,UAAU,WAAW,MAAM,YAAY,YAAY;EAoiIzE;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;
|
|
@@ -1825,6 +1824,7 @@ function createErrorDiagnoser(context) {
|
|
|
1825
1824
|
...(node.variables || []),
|
|
1826
1825
|
...(node.logics || []),
|
|
1827
1826
|
]);
|
|
1827
|
+
checkVariableAndReturnTypeAnnotations(node.variables, [], false);
|
|
1828
1828
|
const module = node.getAncestor('Module');
|
|
1829
1829
|
if (!(module?.parentKey === 'dependencies')) {
|
|
1830
1830
|
if (node.params?.length) {
|
|
@@ -1955,6 +1955,21 @@ function createErrorDiagnoser(context) {
|
|
|
1955
1955
|
if (node._foldInView) {
|
|
1956
1956
|
error(node, `组件${node.name}已经极速折叠`);
|
|
1957
1957
|
}
|
|
1958
|
+
// 已知:选择器会漏报,因为 children 里是两个空 template。暂时先这样吧。
|
|
1959
|
+
let dsFilled = true;
|
|
1960
|
+
let errNode = node;
|
|
1961
|
+
const ds = node.bindAttrs.find(nd => nd.name === 'dataSource');
|
|
1962
|
+
if (ds) {
|
|
1963
|
+
if (ds.type === 'dynamic' && !ds.expression) {
|
|
1964
|
+
dsFilled = false;
|
|
1965
|
+
errNode = ds;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
const hasSubComponents = node.children.filter(c => c.tag !== 'template').length > 0 ||
|
|
1969
|
+
node.children.filter(c => c.tag === 'template').some(cc => cc.children.length > 0);
|
|
1970
|
+
if (!dsFilled && !hasSubComponents) {
|
|
1971
|
+
error(errNode, '数据源不能为空');
|
|
1972
|
+
}
|
|
1958
1973
|
unbindVariables?.();
|
|
1959
1974
|
}
|
|
1960
1975
|
/**
|
|
@@ -2391,7 +2406,7 @@ function createErrorDiagnoser(context) {
|
|
|
2391
2406
|
const prop = getPropertyOfType(type, propertyName);
|
|
2392
2407
|
if (!prop) {
|
|
2393
2408
|
const scope = item?.constructor?.nodeTitle;
|
|
2394
|
-
error(item, `${scope}:找不到 ${type
|
|
2409
|
+
error(item, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
2395
2410
|
}
|
|
2396
2411
|
type = env.getType(prop);
|
|
2397
2412
|
if (type?.typeKind === 'generic' && type.typeName === 'List') {
|
|
@@ -2419,6 +2434,10 @@ function createErrorDiagnoser(context) {
|
|
|
2419
2434
|
...(node.variables || []),
|
|
2420
2435
|
...(node.virtualParams || [])
|
|
2421
2436
|
]);
|
|
2437
|
+
// 仅检查用户写的逻辑
|
|
2438
|
+
// if (node.nodePath?.startsWith('app.logics')) {
|
|
2439
|
+
checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
|
|
2440
|
+
// }
|
|
2422
2441
|
const module = node.getAncestor('Module');
|
|
2423
2442
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2424
2443
|
if (node.params?.length) {
|
|
@@ -2613,6 +2632,9 @@ function createErrorDiagnoser(context) {
|
|
|
2613
2632
|
...(node.returns || []),
|
|
2614
2633
|
...(node.variables || []),
|
|
2615
2634
|
]);
|
|
2635
|
+
// if (nd.nodePath?.startsWith('app.logics')) {
|
|
2636
|
+
checkVariableAndReturnTypeAnnotations(node.variables, node.returns);
|
|
2637
|
+
// }
|
|
2616
2638
|
const module = node.getAncestor('Module');
|
|
2617
2639
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2618
2640
|
if (node.params?.length) {
|
|
@@ -2702,30 +2724,27 @@ function createErrorDiagnoser(context) {
|
|
|
2702
2724
|
if (!ensureNodeKeyExists(node, 'calleeName')) {
|
|
2703
2725
|
return;
|
|
2704
2726
|
}
|
|
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}。`);
|
|
2727
|
+
const ref = env.resolveRef(node); // 前端
|
|
2728
|
+
// TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
|
|
2729
|
+
// 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
|
|
2730
|
+
if (!ref && !isBuiltInCall(node)) {
|
|
2731
|
+
const depLibName = getExtensionLibName(node);
|
|
2732
|
+
if (depLibName) {
|
|
2733
|
+
error(node, `找不到依赖库 ${depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2723
2734
|
}
|
|
2724
2735
|
else {
|
|
2725
2736
|
error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2726
2737
|
}
|
|
2727
2738
|
return errorType;
|
|
2728
2739
|
}
|
|
2740
|
+
/**
|
|
2741
|
+
* 目前的 callInfo:所有内置函数 + 服务端调用。前端因为有组件库调用,还没统一
|
|
2742
|
+
* 排除未求解出类型变元等引发的报错,这些不应该报 '找不到'
|
|
2743
|
+
*/
|
|
2744
|
+
// FIXME: wudengke 帮帮忙,行行好
|
|
2745
|
+
const callInfo = env.resolvedCallInfo.get(node);
|
|
2746
|
+
yield* checkScopeOfUse(node, (callInfo ?? ref));
|
|
2747
|
+
yield* checkCallExpressionParameters(node, (callInfo ?? ref));
|
|
2729
2748
|
switch (node.concept) {
|
|
2730
2749
|
case 'CallFunction':
|
|
2731
2750
|
return yield* checkCallFunction(node);
|
|
@@ -3098,18 +3117,29 @@ function createErrorDiagnoser(context) {
|
|
|
3098
3117
|
}
|
|
3099
3118
|
});
|
|
3100
3119
|
}
|
|
3120
|
+
else if (!isOtherCase(node)) {
|
|
3121
|
+
// pattern 为空时,如果不是其他就报错
|
|
3122
|
+
error(node, '匹配分支:匹配模式不能为空', {
|
|
3123
|
+
titleTip: '匹配模式不能为空',
|
|
3124
|
+
});
|
|
3125
|
+
}
|
|
3101
3126
|
if (node.body?.length) {
|
|
3102
3127
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.body, function* (node) {
|
|
3103
3128
|
yield* checkNode(node);
|
|
3104
3129
|
});
|
|
3105
3130
|
}
|
|
3106
|
-
if (match?.isExpression && node.body.length === 0) {
|
|
3107
|
-
//
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3131
|
+
if (match?.isExpression && node.body.length === 0 && !isOtherCase(node)) {
|
|
3132
|
+
// 如果不是其他就报错
|
|
3133
|
+
error(node, '匹配分支:返回内容不能为空', {
|
|
3134
|
+
titleTip: '返回内容不能为空',
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
function isOtherCase(node) {
|
|
3138
|
+
const indexInParent = node.getIndexOfParent();
|
|
3139
|
+
if (indexInParent === -1) {
|
|
3140
|
+
return false;
|
|
3112
3141
|
}
|
|
3142
|
+
return indexInParent === match.cases.length - 1;
|
|
3113
3143
|
}
|
|
3114
3144
|
}
|
|
3115
3145
|
/**
|
|
@@ -3256,7 +3286,7 @@ function createErrorDiagnoser(context) {
|
|
|
3256
3286
|
}
|
|
3257
3287
|
else {
|
|
3258
3288
|
const scope = node?.constructor?.nodeTitle;
|
|
3259
|
-
error(node, `${scope}:找不到 ${type
|
|
3289
|
+
error(node, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${nodeProperty?.name}。`);
|
|
3260
3290
|
return errorType;
|
|
3261
3291
|
}
|
|
3262
3292
|
return env.getType(node);
|
|
@@ -3400,7 +3430,7 @@ function createErrorDiagnoser(context) {
|
|
|
3400
3430
|
}
|
|
3401
3431
|
else {
|
|
3402
3432
|
const scope = property?.constructor?.nodeTitle;
|
|
3403
|
-
error(property, `${scope}:找不到 ${type
|
|
3433
|
+
error(property, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
3404
3434
|
}
|
|
3405
3435
|
});
|
|
3406
3436
|
}
|
|
@@ -4168,6 +4198,26 @@ function createErrorDiagnoser(context) {
|
|
|
4168
4198
|
function setMetadataTypeEnable(enable) {
|
|
4169
4199
|
metadataTypeEnable = enable;
|
|
4170
4200
|
}
|
|
4201
|
+
const checkVariableAndReturnTypeAnnotations = (variables, returns, inLogic = true) => {
|
|
4202
|
+
for (const v of variables) {
|
|
4203
|
+
if (v.typeAnnotation)
|
|
4204
|
+
continue;
|
|
4205
|
+
const tyAnn = v.__TypeAnnotation;
|
|
4206
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4207
|
+
error(v, `局部变量 ${v.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4208
|
+
v.__TypeAnnotation = undefined;
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
for (const r of returns) {
|
|
4212
|
+
if (r.typeAnnotation)
|
|
4213
|
+
continue;
|
|
4214
|
+
const tyAnn = r.__TypeAnnotation;
|
|
4215
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4216
|
+
error(r, `输出参数 ${r.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4217
|
+
r.__TypeAnnotation = undefined;
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
};
|
|
4171
4221
|
/**
|
|
4172
4222
|
* 诊断App
|
|
4173
4223
|
* @param app
|
|
@@ -4258,4 +4308,8 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
|
4258
4308
|
exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
4259
4309
|
// @ts-expect-error
|
|
4260
4310
|
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
4311
|
+
// 是否来自系统内置
|
|
4312
|
+
const isBuiltInCall = (nd) => nd.calleeNamespace.startsWith('nasl.');
|
|
4313
|
+
// 是否来自依赖库
|
|
4314
|
+
const getExtensionLibName = (nd) => nd.calleeNamespace.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
|
|
4261
4315
|
//# sourceMappingURL=checker.js.map
|