@lcap/nasl-language-server-core 4.0.0-rc.3 → 4.0.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/collect-q-name.d.ts +2 -1
- package/out/reference-manager/collect-q-name.d.ts.map +1 -1
- package/out/reference-manager/collect-q-name.js +9 -3
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/reference-manager/get-q-name.d.ts.map +1 -1
- package/out/reference-manager/get-q-name.js +2 -0
- package/out/reference-manager/get-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +4 -1
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +197 -54
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/remove-q-name.d.ts +2 -1
- package/out/reference-manager/remove-q-name.d.ts.map +1 -1
- package/out/reference-manager/remove-q-name.js +11 -3
- package/out/reference-manager/remove-q-name.js.map +1 -1
- package/out/reference-manager/rename-q-name.d.ts +2 -1
- package/out/reference-manager/rename-q-name.d.ts.map +1 -1
- package/out/reference-manager/rename-q-name.js +11 -2
- package/out/reference-manager/rename-q-name.js.map +1 -1
- package/out/reference-manager/symbol-type.d.ts +4 -3
- package/out/reference-manager/symbol-type.d.ts.map +1 -1
- package/out/reference-manager/symbol-type.js +6 -2
- 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 +11 -39
- 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 +68 -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 +2 -0
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +8 -6
- 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 +23 -5
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +38 -28
- 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,EAGpF,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,EAGpF,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhE,OAAO,EAAE,UAAU,IAAI,kBA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AE,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
|
@@ -803,7 +803,7 @@ function createErrorDiagnoser(context) {
|
|
|
803
803
|
/**
|
|
804
804
|
* 检查 调用表达式的参数
|
|
805
805
|
* @param node
|
|
806
|
-
* @param
|
|
806
|
+
*( @param r) as anyef
|
|
807
807
|
*/
|
|
808
808
|
function* checkCallExpressionParameters(node, ref) {
|
|
809
809
|
// Handle both TypeAnnotation and FunctionDefinition formats
|
|
@@ -927,12 +927,11 @@ function createErrorDiagnoser(context) {
|
|
|
927
927
|
const type = yield* checkNode(node);
|
|
928
928
|
if (isUnresolvedType(type)) {
|
|
929
929
|
const scope = node?.constructor?.nodeTitle;
|
|
930
|
-
if (node.concept === 'Identifier') {
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
930
|
+
// if (node.concept === 'Identifier') {
|
|
931
|
+
// error(node, `${scope}:${node.name} 未定义。`);
|
|
932
|
+
// } else {
|
|
933
|
+
error(node, `${scope}:所选择的内容未定义。`);
|
|
934
|
+
// }
|
|
936
935
|
return errorType;
|
|
937
936
|
}
|
|
938
937
|
return type;
|
|
@@ -1867,6 +1866,7 @@ function createErrorDiagnoser(context) {
|
|
|
1867
1866
|
...(node.variables || []),
|
|
1868
1867
|
...(node.logics || []),
|
|
1869
1868
|
]);
|
|
1869
|
+
checkVariableAndReturnTypeAnnotations(node.variables, [], false);
|
|
1870
1870
|
const module = node.getAncestor('Module');
|
|
1871
1871
|
if (!(module?.parentKey === 'dependencies')) {
|
|
1872
1872
|
if (node.params?.length) {
|
|
@@ -1997,6 +1997,21 @@ function createErrorDiagnoser(context) {
|
|
|
1997
1997
|
if (node._foldInView) {
|
|
1998
1998
|
error(node, `组件${node.name}已经极速折叠`);
|
|
1999
1999
|
}
|
|
2000
|
+
// 已知:选择器会漏报,因为 children 里是两个空 template。暂时先这样吧。
|
|
2001
|
+
let dsFilled = true;
|
|
2002
|
+
let errNode = node;
|
|
2003
|
+
const ds = node.bindAttrs.find(nd => nd.name === 'dataSource');
|
|
2004
|
+
if (ds) {
|
|
2005
|
+
if (ds.type === 'dynamic' && !ds.expression) {
|
|
2006
|
+
dsFilled = false;
|
|
2007
|
+
errNode = ds;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
const hasSubComponents = node.children.filter(c => c.tag !== 'template').length > 0 ||
|
|
2011
|
+
node.children.filter(c => c.tag === 'template').some(cc => cc.children.length > 0);
|
|
2012
|
+
if (!dsFilled && !hasSubComponents) {
|
|
2013
|
+
error(errNode, '数据源不能为空');
|
|
2014
|
+
}
|
|
2000
2015
|
unbindVariables?.();
|
|
2001
2016
|
}
|
|
2002
2017
|
/**
|
|
@@ -2433,7 +2448,7 @@ function createErrorDiagnoser(context) {
|
|
|
2433
2448
|
const prop = getPropertyOfType(type, propertyName);
|
|
2434
2449
|
if (!prop) {
|
|
2435
2450
|
const scope = item?.constructor?.nodeTitle;
|
|
2436
|
-
error(item, `${scope}:找不到 ${type
|
|
2451
|
+
error(item, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
2437
2452
|
}
|
|
2438
2453
|
type = env.getType(prop);
|
|
2439
2454
|
if (type?.typeKind === 'generic' && type.typeName === 'List') {
|
|
@@ -2461,6 +2476,10 @@ function createErrorDiagnoser(context) {
|
|
|
2461
2476
|
...(node.variables || []),
|
|
2462
2477
|
...(node.virtualParams || [])
|
|
2463
2478
|
]);
|
|
2479
|
+
// 仅检查用户写的逻辑
|
|
2480
|
+
// if (node.nodePath?.startsWith('app.logics')) {
|
|
2481
|
+
checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
|
|
2482
|
+
// }
|
|
2464
2483
|
const module = node.getAncestor('Module');
|
|
2465
2484
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2466
2485
|
if (node.params?.length) {
|
|
@@ -2641,6 +2660,9 @@ function createErrorDiagnoser(context) {
|
|
|
2641
2660
|
...(node.returns || []),
|
|
2642
2661
|
...(node.variables || []),
|
|
2643
2662
|
]);
|
|
2663
|
+
// if (nd.nodePath?.startsWith('app.logics')) {
|
|
2664
|
+
checkVariableAndReturnTypeAnnotations(node.variables, node.returns);
|
|
2665
|
+
// }
|
|
2644
2666
|
const module = node.getAncestor('Module');
|
|
2645
2667
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2646
2668
|
if (node.params?.length) {
|
|
@@ -2731,30 +2753,27 @@ function createErrorDiagnoser(context) {
|
|
|
2731
2753
|
return;
|
|
2732
2754
|
}
|
|
2733
2755
|
yield* checkVoidCallUsedAsStatement(node);
|
|
2734
|
-
const ref = env.
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
yield* checkScopeOfUse(node, ref);
|
|
2742
|
-
yield* checkCallExpressionParameters(node, ref);
|
|
2743
|
-
}
|
|
2744
|
-
else if (ref && !typeUnresolved) {
|
|
2745
|
-
// 检查使用范围
|
|
2746
|
-
yield* checkScopeOfUse(node, ref);
|
|
2747
|
-
yield* checkCallExpressionParameters(node, ref);
|
|
2748
|
-
}
|
|
2749
|
-
else {
|
|
2750
|
-
if (ref.depLibName) {
|
|
2751
|
-
error(node, `找不到依赖库 ${ref.depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2756
|
+
const ref = env.resolveRef(node); // 前端
|
|
2757
|
+
// TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
|
|
2758
|
+
// 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
|
|
2759
|
+
if (!ref && !isBuiltInCall(node)) {
|
|
2760
|
+
const depLibName = getExtensionLibName(node);
|
|
2761
|
+
if (depLibName) {
|
|
2762
|
+
error(node, `找不到依赖库 ${depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2752
2763
|
}
|
|
2753
2764
|
else {
|
|
2754
2765
|
error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
|
|
2755
2766
|
}
|
|
2756
2767
|
return errorType;
|
|
2757
2768
|
}
|
|
2769
|
+
/**
|
|
2770
|
+
* 目前的 callInfo:所有内置函数 + 服务端调用。前端因为有组件库调用,还没统一
|
|
2771
|
+
* 排除未求解出类型变元等引发的报错,这些不应该报 '找不到'
|
|
2772
|
+
*/
|
|
2773
|
+
// FIXME: wudengke 帮帮忙,行行好
|
|
2774
|
+
const callInfo = env.resolvedCallInfo.get(node);
|
|
2775
|
+
yield* checkScopeOfUse(node, (callInfo ?? ref));
|
|
2776
|
+
yield* checkCallExpressionParameters(node, (callInfo ?? ref));
|
|
2758
2777
|
switch (node.concept) {
|
|
2759
2778
|
case 'CallFunction':
|
|
2760
2779
|
return yield* checkCallFunction(node);
|
|
@@ -3127,18 +3146,29 @@ function createErrorDiagnoser(context) {
|
|
|
3127
3146
|
}
|
|
3128
3147
|
});
|
|
3129
3148
|
}
|
|
3149
|
+
else if (!isOtherCase(node)) {
|
|
3150
|
+
// pattern 为空时,如果不是其他就报错
|
|
3151
|
+
error(node, '匹配分支:匹配模式不能为空', {
|
|
3152
|
+
titleTip: '匹配模式不能为空',
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3130
3155
|
if (node.body?.length) {
|
|
3131
3156
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.body, function* (node) {
|
|
3132
3157
|
yield* checkNode(node);
|
|
3133
3158
|
});
|
|
3134
3159
|
}
|
|
3135
|
-
if (match?.isExpression && node.body.length === 0) {
|
|
3136
|
-
//
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3160
|
+
if (match?.isExpression && node.body.length === 0 && !isOtherCase(node)) {
|
|
3161
|
+
// 如果不是其他就报错
|
|
3162
|
+
error(node, '匹配分支:返回内容不能为空', {
|
|
3163
|
+
titleTip: '返回内容不能为空',
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
function isOtherCase(node) {
|
|
3167
|
+
const indexInParent = node.getIndexOfParent();
|
|
3168
|
+
if (indexInParent === -1) {
|
|
3169
|
+
return false;
|
|
3141
3170
|
}
|
|
3171
|
+
return indexInParent === match.cases.length - 1;
|
|
3142
3172
|
}
|
|
3143
3173
|
}
|
|
3144
3174
|
/**
|
|
@@ -3285,7 +3315,7 @@ function createErrorDiagnoser(context) {
|
|
|
3285
3315
|
}
|
|
3286
3316
|
else {
|
|
3287
3317
|
const scope = node?.constructor?.nodeTitle;
|
|
3288
|
-
error(node, `${scope}:找不到 ${type
|
|
3318
|
+
error(node, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${nodeProperty?.name}。`);
|
|
3289
3319
|
return errorType;
|
|
3290
3320
|
}
|
|
3291
3321
|
return env.getType(node);
|
|
@@ -3437,7 +3467,7 @@ function createErrorDiagnoser(context) {
|
|
|
3437
3467
|
}
|
|
3438
3468
|
else {
|
|
3439
3469
|
const scope = property?.constructor?.nodeTitle;
|
|
3440
|
-
error(property, `${scope}:找不到 ${type
|
|
3470
|
+
error(property, `${scope}:找不到 ${(0, type_manager_1.showUserLevelType)(type)} 上的 ${propertyName}。`);
|
|
3441
3471
|
}
|
|
3442
3472
|
});
|
|
3443
3473
|
}
|
|
@@ -4253,6 +4283,26 @@ function createErrorDiagnoser(context) {
|
|
|
4253
4283
|
function setMetadataTypeEnable(enable) {
|
|
4254
4284
|
metadataTypeEnable = enable;
|
|
4255
4285
|
}
|
|
4286
|
+
const checkVariableAndReturnTypeAnnotations = (variables, returns, inLogic = true) => {
|
|
4287
|
+
for (const v of variables) {
|
|
4288
|
+
if (v.typeAnnotation)
|
|
4289
|
+
continue;
|
|
4290
|
+
const tyAnn = v.__TypeAnnotation;
|
|
4291
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4292
|
+
error(v, `局部变量 ${v.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4293
|
+
v.__TypeAnnotation = undefined;
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
for (const r of returns) {
|
|
4297
|
+
if (r.typeAnnotation)
|
|
4298
|
+
continue;
|
|
4299
|
+
const tyAnn = r.__TypeAnnotation;
|
|
4300
|
+
if (!(0, type_predicate_1.isResolvedUserTy)(tyAnn)) {
|
|
4301
|
+
error(r, `输出参数 ${r.name} 未设置类型,在非草稿区正常使用可自动推断类型`);
|
|
4302
|
+
r.__TypeAnnotation = undefined;
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
};
|
|
4256
4306
|
/**
|
|
4257
4307
|
* 诊断App
|
|
4258
4308
|
* @param app
|
|
@@ -4344,4 +4394,8 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
|
4344
4394
|
exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
4345
4395
|
// @ts-expect-error
|
|
4346
4396
|
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
4397
|
+
// 是否来自系统内置
|
|
4398
|
+
const isBuiltInCall = (nd) => nd.calleeNamespace.startsWith('nasl.');
|
|
4399
|
+
// 是否来自依赖库
|
|
4400
|
+
const getExtensionLibName = (nd) => nd.calleeNamespace.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
|
|
4347
4401
|
//# sourceMappingURL=checker.js.map
|