@lcap/nasl-language-server-core 4.0.0-beta.1 → 4.0.0-beta.2
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 +27 -32
- 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 -5
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +3 -3
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +16 -9
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/remove-q-name.d.ts.map +1 -1
- package/out/reference-manager/remove-q-name.js +4 -3
- package/out/reference-manager/remove-q-name.js.map +1 -1
- package/out/typer/collectGlobalDefs.d.ts.map +1 -1
- package/out/typer/collectGlobalDefs.js +23 -20
- package/out/typer/collectGlobalDefs.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.d.ts +19 -5
- package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +30 -18
- 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 +56 -15
- package/out/typer/component-def-manager/utils.js.map +1 -1
- package/out/typer/dispatch-all.d.ts.map +1 -1
- package/out/typer/dispatch-all.js +19 -20
- package/out/typer/dispatch-all.js.map +1 -1
- package/out/typer/dispatch-def.d.ts +4 -2
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +58 -30
- package/out/typer/dispatch-def.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts +2 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +421 -327
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-process.d.ts +1 -1
- package/out/typer/dispatch-process.d.ts.map +1 -1
- package/out/typer/dispatch-process.js +29 -27
- 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 -48
- package/out/typer/dispatch-stmt.js.map +1 -1
- package/out/typer/dispatch-view.d.ts +1 -1
- package/out/typer/dispatch-view.d.ts.map +1 -1
- package/out/typer/dispatch-view.js +201 -105
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/fix-use-before-assign.js +8 -8
- package/out/typer/fix-use-before-assign.js.map +1 -1
- package/out/typer/helper.d.ts +2 -2
- package/out/typer/helper.d.ts.map +1 -1
- package/out/typer/helper.js +7 -7
- package/out/typer/helper.js.map +1 -1
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +13 -14
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/index.d.ts +3 -2
- package/out/typer/index.d.ts.map +1 -1
- package/out/typer/index.js +49 -48
- package/out/typer/index.js.map +1 -1
- package/out/typer/sem-diag.d.ts +5 -3
- package/out/typer/sem-diag.d.ts.map +1 -1
- package/out/typer/sem-diag.js +57 -15
- package/out/typer/sem-diag.js.map +1 -1
- package/out/typer/solver.d.ts +10 -9
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +34 -33
- package/out/typer/solver.js.map +1 -1
- package/out/typer/subster.d.ts +20 -7
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +117 -68
- package/out/typer/subster.js.map +1 -1
- package/out/typer/topo-sort.d.ts.map +1 -1
- package/out/typer/topo-sort.js +13 -6
- package/out/typer/topo-sort.js.map +1 -1
- package/out/typer/type-manager.d.ts +154 -0
- package/out/typer/type-manager.d.ts.map +1 -0
- package/out/typer/{typeManager.js → type-manager.js} +298 -363
- package/out/typer/type-manager.js.map +1 -0
- package/out/typer/type-predicate.d.ts +47 -2
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +380 -2
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +27 -11
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +85 -61
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts +13 -5
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +142 -92
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/nasl-type-manipulation.d.ts +24 -2
- package/out/utils/nasl-type-manipulation.d.ts.map +1 -1
- package/out/utils/nasl-type-manipulation.js +56 -5
- package/out/utils/nasl-type-manipulation.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +43 -38
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts +12 -0
- package/out/utils/type-operator.d.ts.map +1 -0
- package/out/utils/type-operator.js +38 -0
- package/out/utils/type-operator.js.map +1 -0
- package/package.json +5 -5
- package/out/typer/typeManager.d.ts +0 -72
- package/out/typer/typeManager.d.ts.map +0 -1
- package/out/typer/typeManager.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;AAC7B,OAAO,EACgE,cAAc,EAGpF,MAAM,qBAAqB,CAAC;AAM7B,OAAO,
|
|
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;AAC7B,OAAO,EACgE,cAAc,EAGpF,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAA4B,MAAM,EAAE,MAAM,SAAS,CAAC;AAI3D,oBAAY,QAAQ;IAClB,IAAI,YAAY;IA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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,GAAI,UAAU,UAAU,EAAE,aAAa,kBAAkB,KAAG,KAAK,CAAC,gBAAgB,CAmC3H,CAAA"}
|
package/out/checker.js
CHANGED
|
@@ -7,6 +7,8 @@ const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
|
7
7
|
const service_1 = require("@lcap/nasl-concepts/service");
|
|
8
8
|
const nasl_utils_1 = require("@lcap/nasl-utils");
|
|
9
9
|
const typer_1 = require("./typer");
|
|
10
|
+
const type_predicate_1 = require("./typer/type-predicate");
|
|
11
|
+
const type_manager_1 = require("./typer/type-manager");
|
|
10
12
|
var Severity;
|
|
11
13
|
(function (Severity) {
|
|
12
14
|
Severity["WARN"] = "warning";
|
|
@@ -48,6 +50,7 @@ const isContinue = (node) => node.concept === 'Continue';
|
|
|
48
50
|
* @param node
|
|
49
51
|
*/
|
|
50
52
|
const fastIsControlFlowNode = (node) => isEnd(node) || isAbort(node) || isBreak(node) || isContinue(node);
|
|
53
|
+
const isArgument = (node) => node.concept === 'Argument';
|
|
51
54
|
/**
|
|
52
55
|
* 是端类型下的参数
|
|
53
56
|
* @param node
|
|
@@ -315,7 +318,7 @@ function createErrorDiagnoser(context) {
|
|
|
315
318
|
if (diagnostics) {
|
|
316
319
|
const diagnostic = {
|
|
317
320
|
message,
|
|
318
|
-
severity: inPlayground > 0 ? Severity.WARN : severity ?? Severity.ERROR,
|
|
321
|
+
severity: inPlayground > 0 ? Severity.WARN : (severity ?? Severity.ERROR),
|
|
319
322
|
...others,
|
|
320
323
|
};
|
|
321
324
|
if (isDebug) {
|
|
@@ -694,14 +697,11 @@ function createErrorDiagnoser(context) {
|
|
|
694
697
|
*/
|
|
695
698
|
function getMinArgsCount(params) {
|
|
696
699
|
const paramLen = params?.length;
|
|
697
|
-
let minArgsCount =
|
|
698
|
-
for (let i =
|
|
700
|
+
let minArgsCount = 0;
|
|
701
|
+
for (let i = 0; i < paramLen; i++) {
|
|
699
702
|
const param = params[i];
|
|
700
|
-
if (isNonRequiredParam(param)) {
|
|
701
|
-
minArgsCount
|
|
702
|
-
}
|
|
703
|
-
else { // 如果参数有默认值,则跳过
|
|
704
|
-
break;
|
|
703
|
+
if (!isNonRequiredParam(param)) {
|
|
704
|
+
minArgsCount++; // 如果参数有默认值,则跳过
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
return minArgsCount;
|
|
@@ -805,10 +805,12 @@ function createErrorDiagnoser(context) {
|
|
|
805
805
|
* @param ref
|
|
806
806
|
*/
|
|
807
807
|
function* checkCallExpressionParameters(node, ref) {
|
|
808
|
-
|
|
808
|
+
// Handle both TypeAnnotation and FunctionDefinition formats
|
|
809
|
+
const params = ref.params ?? ref.typeArguments;
|
|
809
810
|
const { arguments: args } = node;
|
|
810
811
|
const paramsLen = params?.length || 0;
|
|
811
812
|
const argsLen = args?.length || 0;
|
|
813
|
+
// For FunctionDefinition format, check spread and optional params
|
|
812
814
|
const spreadParamIndex = params?.findIndex((param) => param.spread);
|
|
813
815
|
const hasSpreadParam = spreadParamIndex !== -1;
|
|
814
816
|
const minArgsCount = getMinArgsCount(params);
|
|
@@ -820,11 +822,12 @@ function createErrorDiagnoser(context) {
|
|
|
820
822
|
}
|
|
821
823
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(args, function* (arg, index) {
|
|
822
824
|
const param = params?.[index];
|
|
823
|
-
const isParamRequired = !(hasSpreadParam && index > spreadParamIndex) && !isNonRequiredParam(param);
|
|
824
|
-
arg.paramRequired = isParamRequired;
|
|
825
825
|
if (!param)
|
|
826
826
|
return;
|
|
827
|
-
const
|
|
827
|
+
const isParamRequired = !(hasSpreadParam && index > spreadParamIndex) && !isNonRequiredParam(param);
|
|
828
|
+
arg.paramRequired = isParamRequired;
|
|
829
|
+
const paramType = param.typeAnnotation ??
|
|
830
|
+
(nasl_concepts_1.asserts.isTypeAnnotation(param) ? param : env.getType(param));
|
|
828
831
|
const argType = yield* checkNode(arg);
|
|
829
832
|
if (paramType?.typeKind === 'function' && argType?.typeKind === 'function') {
|
|
830
833
|
const argTypeArgs = argType?.typeArguments || [];
|
|
@@ -2155,7 +2158,7 @@ function createErrorDiagnoser(context) {
|
|
|
2155
2158
|
error(node, '流程暂不支持可变参数');
|
|
2156
2159
|
}
|
|
2157
2160
|
if (node.includeTypeArgs) {
|
|
2158
|
-
error(node, '
|
|
2161
|
+
error(node, '流程暂不支持泛型参数');
|
|
2159
2162
|
}
|
|
2160
2163
|
const unbindVariables = env.temporarilyBindVariables([
|
|
2161
2164
|
...(node?.params || []),
|
|
@@ -2269,7 +2272,7 @@ function createErrorDiagnoser(context) {
|
|
|
2269
2272
|
error(node, '流程暂不支持可变参数');
|
|
2270
2273
|
}
|
|
2271
2274
|
if (node.includeTypeArgs) {
|
|
2272
|
-
error(node, '
|
|
2275
|
+
error(node, '流程暂不支持泛型参数');
|
|
2273
2276
|
}
|
|
2274
2277
|
}
|
|
2275
2278
|
/**
|
|
@@ -2530,7 +2533,7 @@ function createErrorDiagnoser(context) {
|
|
|
2530
2533
|
if (logicReturns[0].name !== itfReturns[0].name) {
|
|
2531
2534
|
isSame = false;
|
|
2532
2535
|
}
|
|
2533
|
-
else if (!(
|
|
2536
|
+
else if (!(0, type_predicate_1.isEqualTy)(env, env.getType(logicReturns[0]), env.getType(itfReturns[0]))) {
|
|
2534
2537
|
isSame = false;
|
|
2535
2538
|
}
|
|
2536
2539
|
}
|
|
@@ -2733,8 +2736,14 @@ function createErrorDiagnoser(context) {
|
|
|
2733
2736
|
return;
|
|
2734
2737
|
}
|
|
2735
2738
|
yield* checkVoidCallUsedAsStatement(node);
|
|
2736
|
-
const ref = env.
|
|
2737
|
-
|
|
2739
|
+
const ref = env.resolvedCallInfo.get(node) ?? env.resolveRef(node);
|
|
2740
|
+
// Handle the new FunctionDefinition structure
|
|
2741
|
+
if (ref?.params && !(0, type_manager_1.hasUnresolvedTyInCallInfo)(ref)) {
|
|
2742
|
+
// It's a FunctionDefinition object
|
|
2743
|
+
yield* checkScopeOfUse(node, ref);
|
|
2744
|
+
yield* checkCallExpressionParameters(node, ref);
|
|
2745
|
+
}
|
|
2746
|
+
else if (ref && !(0, type_predicate_1.isUnResolvedTy)(ref)) {
|
|
2738
2747
|
// 检查使用范围
|
|
2739
2748
|
yield* checkScopeOfUse(node, ref);
|
|
2740
2749
|
yield* checkCallExpressionParameters(node, ref);
|
|
@@ -3777,20 +3786,6 @@ function createErrorDiagnoser(context) {
|
|
|
3777
3786
|
if (ensureNodeKeyExists(node, 'argument')) {
|
|
3778
3787
|
yield* checkNode(node.argument);
|
|
3779
3788
|
}
|
|
3780
|
-
if (node.operator === 'isNull' && !!node.getAncestor('CallQueryComponent')) {
|
|
3781
|
-
function useVariable(node) {
|
|
3782
|
-
let res = false;
|
|
3783
|
-
node.traverseStrictChildren((child) => {
|
|
3784
|
-
if (child.concept === 'Identifier' && child.namespace !== 'inner') {
|
|
3785
|
-
res = true;
|
|
3786
|
-
}
|
|
3787
|
-
});
|
|
3788
|
-
return res;
|
|
3789
|
-
}
|
|
3790
|
-
if (useVariable(node)) {
|
|
3791
|
-
error(node, '空值匹配组件暂不支持使用变量');
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
3789
|
return env.getType(node);
|
|
3795
3790
|
}
|
|
3796
3791
|
/**
|
|
@@ -3949,7 +3944,7 @@ function createErrorDiagnoser(context) {
|
|
|
3949
3944
|
nasl_concepts_1.asserts.isBlock(parentNode));
|
|
3950
3945
|
const nodeType = env.getType(node);
|
|
3951
3946
|
if (isUnresolvedType(nodeType) && !usedAsStatement) {
|
|
3952
|
-
error(node, `无返回值的${node?.constructor?.nodeTitle}不能在${parentNode?.constructor?.nodeTitle}中作为表达式使用。`);
|
|
3947
|
+
error(node, `无返回值的${node?.constructor?.nodeTitle}${node.calleeName} 不能在${parentNode?.constructor?.nodeTitle}中作为表达式使用。`);
|
|
3953
3948
|
}
|
|
3954
3949
|
}
|
|
3955
3950
|
function* dispatchNode(node) {
|