@lcap/nasl-language-server-core 4.3.0-rc.4 → 4.3.0-rc.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 +1 -1
- package/out/checker.d.ts.map +1 -1
- package/out/checker.js +46 -11
- package/out/checker.js.map +1 -1
- package/out/reference-manager/collect-q-name.d.ts.map +1 -1
- package/out/reference-manager/collect-q-name.js +6 -3
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +1 -1
- package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
- package/out/typer/dispatch-call.d.ts.map +1 -1
- package/out/typer/dispatch-call.js +6 -0
- 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 +73 -18
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-stmt.d.ts.map +1 -1
- package/out/typer/dispatch-stmt.js +10 -5
- 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 +9 -11
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +7 -0
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/oql-checker/chain-call-transformer.d.ts.map +1 -1
- package/out/typer/oql-checker/chain-call-transformer.js +17 -4
- package/out/typer/oql-checker/chain-call-transformer.js.map +1 -1
- package/out/typer/oql-checker/ts-parser.d.ts.map +1 -1
- package/out/typer/oql-checker/ts-parser.js +173 -23
- package/out/typer/oql-checker/ts-parser.js.map +1 -1
- package/out/typer/overload-helper.d.ts.map +1 -1
- package/out/typer/overload-helper.js +12 -15
- package/out/typer/overload-helper.js.map +1 -1
- package/out/typer/subster.d.ts +1 -1
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +7 -3
- package/out/typer/subster.js.map +1 -1
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +38 -2
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +18 -1
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +95 -13
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.js +2 -2
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +0 -2
- package/out/utils/parseTsClassType.js.map +1 -1
- package/package.json +5 -5
package/out/checker.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare function createErrorDiagnoser(context: DiagnoseContext): {
|
|
|
42
42
|
clearDiagnostics: (node?: SyntaxNode) => void;
|
|
43
43
|
getDiagnostics: (node: SyntaxNode) => NodeDiagnosticsMap | undefined;
|
|
44
44
|
getAllDiagnostics: () => FileDiagnosticsMap;
|
|
45
|
-
getDebugDiagnostics: () => {
|
|
45
|
+
getDebugDiagnostics: (normalize?: boolean) => {
|
|
46
46
|
message: string;
|
|
47
47
|
severity: string;
|
|
48
48
|
nodePath: string;
|
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,EAU2G,GAAG,EAMxH,QAAQ,EAET,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;AAMpE,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;I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CAC1C;AAMD,eAAO,MAAM,6BAA6B,aAC9B,UAAU,+DAGnB,MAAM,gBAAgB,CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/out/checker.js
CHANGED
|
@@ -1970,6 +1970,17 @@ function createErrorDiagnoser(context) {
|
|
|
1970
1970
|
*/
|
|
1971
1971
|
function* checkBusinessComponent(node) {
|
|
1972
1972
|
env.enterScope(node);
|
|
1973
|
+
if (node.params?.length) {
|
|
1974
|
+
yield* checkParams(node.params);
|
|
1975
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
|
|
1976
|
+
yield* checkNode(node);
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
if (node.variables?.length) {
|
|
1980
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
|
|
1981
|
+
yield* checkNode(node);
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1973
1984
|
// 组件元素
|
|
1974
1985
|
if (node.elements?.length) {
|
|
1975
1986
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.elements, function* (node) {
|
|
@@ -2929,15 +2940,27 @@ function createErrorDiagnoser(context) {
|
|
|
2929
2940
|
}
|
|
2930
2941
|
return type;
|
|
2931
2942
|
function checkListSort(nd) {
|
|
2943
|
+
const parTy = env.getType(nd.arguments?.[0]);
|
|
2944
|
+
let paramType = '未知类型';
|
|
2945
|
+
if (parTy?.typeName === 'List') {
|
|
2946
|
+
paramType = (0, type_manager_1.showUserLevelType)(parTy.typeArguments?.[0] || type_manager_1.naslAnyTy);
|
|
2947
|
+
}
|
|
2948
|
+
const expectTy = `{ by: (item: ${paramType}) => 未知类型, asc: 布尔值 }`;
|
|
2932
2949
|
for (let i = 1; i < nd.arguments.length; i++) {
|
|
2933
2950
|
const expr = nd.arguments[i].expression;
|
|
2934
2951
|
let resTy;
|
|
2935
2952
|
if (expr?.concept === 'AnonymousFunction') {
|
|
2936
2953
|
resTy = env.getType(expr.body);
|
|
2954
|
+
if (!nasl_concepts_1.asserts.isNewComposite(expr.body)) {
|
|
2955
|
+
error(nd.arguments[i], (0, sem_diag_1.mkIncompatibleTyErr)(env, env.getType(expr) || type_manager_1.naslAnyTy, expectTy));
|
|
2956
|
+
}
|
|
2937
2957
|
}
|
|
2938
2958
|
else if (expr?.concept === 'SubLogic') {
|
|
2939
2959
|
resTy = env.getType(expr.returns?.[0]);
|
|
2940
2960
|
}
|
|
2961
|
+
else {
|
|
2962
|
+
error(nd.arguments[i], (0, sem_diag_1.mkIncompatibleTyErr)(env, env.getType(expr) || type_manager_1.naslAnyTy, expectTy));
|
|
2963
|
+
}
|
|
2941
2964
|
const byTy = resTy?.properties?.find((prop) => prop.name === 'by')?.typeAnnotation;
|
|
2942
2965
|
if (byTy?.typeKind === 'union') {
|
|
2943
2966
|
// 这里使用 node.arguments[i] 则无红框,猜测是 ListSort 的特殊交互导致的问题
|
|
@@ -3851,7 +3874,9 @@ function createErrorDiagnoser(context) {
|
|
|
3851
3874
|
* @param node
|
|
3852
3875
|
*/
|
|
3853
3876
|
function* checkQueryOrderByExpression(node) {
|
|
3854
|
-
|
|
3877
|
+
if (ensureNodeKeyExists(node, 'orderElement')) {
|
|
3878
|
+
yield* checkNode(node.orderElement);
|
|
3879
|
+
}
|
|
3855
3880
|
yield* checkPlayground(node.orderElementPlayground);
|
|
3856
3881
|
}
|
|
3857
3882
|
/**
|
|
@@ -3880,13 +3905,20 @@ function createErrorDiagnoser(context) {
|
|
|
3880
3905
|
function* checkOqlQueryComponent(node) {
|
|
3881
3906
|
ensureNodeKeyExists(node, 'code');
|
|
3882
3907
|
yield* checkSameSource(node);
|
|
3883
|
-
//
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3908
|
+
if (node.typeAnnotation) { // 手动设置
|
|
3909
|
+
const IMPOSSIBLE_TOPLEVEL_TYPES = ['Map'];
|
|
3910
|
+
if (IMPOSSIBLE_TOPLEVEL_TYPES.includes(node.typeAnnotation.typeName || "")) {
|
|
3911
|
+
error(node, `SQL查询:返回类型不支持设置为 ${node.typeAnnotation.headTitle}。`);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
else { // 自动推导
|
|
3915
|
+
const typeAnnotation = env.getType(node);
|
|
3916
|
+
if (typeAnnotation) {
|
|
3917
|
+
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
3918
|
+
const { typeArguments = [] } = typeAnnotation;
|
|
3919
|
+
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
3920
|
+
error(node, `SQL查询:返回类型不支持单个复杂类型 ${typeArguments[0].headTitle}。`);
|
|
3921
|
+
}
|
|
3890
3922
|
}
|
|
3891
3923
|
}
|
|
3892
3924
|
}
|
|
@@ -4173,6 +4205,8 @@ function createErrorDiagnoser(context) {
|
|
|
4173
4205
|
return yield* checkBackendVariable(node);
|
|
4174
4206
|
case 'Param':
|
|
4175
4207
|
return yield* checkParam(node);
|
|
4208
|
+
case 'ParamWithGroup':
|
|
4209
|
+
return yield* checkParam(node);
|
|
4176
4210
|
case 'Return':
|
|
4177
4211
|
return yield* checkReturn(node);
|
|
4178
4212
|
case 'DefaultValue':
|
|
@@ -4497,7 +4531,7 @@ function createErrorDiagnoser(context) {
|
|
|
4497
4531
|
function getAllDiagnostics() {
|
|
4498
4532
|
return diagnosticMap;
|
|
4499
4533
|
}
|
|
4500
|
-
function getDebugDiagnostics() {
|
|
4534
|
+
function getDebugDiagnostics(normalize = false) {
|
|
4501
4535
|
const diagMap = getAllDiagnostics();
|
|
4502
4536
|
const flattenedDiags = [];
|
|
4503
4537
|
diagMap.forEach((item) => {
|
|
@@ -4506,11 +4540,12 @@ function createErrorDiagnoser(context) {
|
|
|
4506
4540
|
if (!x.message || !x.severity) {
|
|
4507
4541
|
return [];
|
|
4508
4542
|
}
|
|
4543
|
+
const msg = normalize ? (0, lodash_1.sortBy)(x.message).join('') : x.message;
|
|
4509
4544
|
return [{
|
|
4510
|
-
message:
|
|
4545
|
+
message: msg,
|
|
4511
4546
|
severity: x.severity,
|
|
4512
4547
|
nodePath: node.nodePath,
|
|
4513
|
-
nodeConcept: node.concept
|
|
4548
|
+
nodeConcept: node.concept
|
|
4514
4549
|
}];
|
|
4515
4550
|
});
|
|
4516
4551
|
})));
|