@lcap/nasl-language-server-core 4.3.0-beta.25 → 4.3.0-beta.27
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 +94 -5
- 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/reference-manager/get-q-name.js +3 -3
- 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 +16 -15
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/symbol-type.d.ts.map +1 -1
- package/out/reference-manager/symbol-type.js +1 -0
- package/out/reference-manager/symbol-type.js.map +1 -1
- package/out/reference-manager/update-nasl-fragment.d.ts +2 -2
- package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
- package/out/reference-manager/update-nasl-fragment.js +13 -14
- package/out/reference-manager/update-nasl-fragment.js.map +1 -1
- package/out/typer/collectGlobalDefs.js +1 -1
- package/out/typer/collectGlobalDefs.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 +7 -0
- package/out/typer/dispatch-call.js.map +1 -1
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +35 -6
- 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 +138 -103
- 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 +33 -18
- 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 +58 -45
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/incremental-update.d.ts +2 -2
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +93 -17
- 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 +230 -31
- 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 +139 -11
- package/out/typer/overload-helper.js.map +1 -1
- package/out/typer/solver.d.ts +8 -9
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +54 -31
- package/out/typer/solver.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 +176 -49
- package/out/typer/subster.js.map +1 -1
- package/out/typer/topo-sort.d.ts +37 -0
- package/out/typer/topo-sort.d.ts.map +1 -1
- package/out/typer/topo-sort.js +260 -1
- package/out/typer/topo-sort.js.map +1 -1
- package/out/typer/type-manager.d.ts.map +1 -1
- package/out/typer/type-manager.js +3 -3
- package/out/typer/type-manager.js.map +1 -1
- package/out/typer/type-predicate.d.ts +1 -0
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +50 -4
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +42 -3
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +189 -16
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts +11 -0
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +74 -31
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/type-operator.d.ts +15 -0
- package/out/utils/type-operator.d.ts.map +1 -1
- package/out/utils/type-operator.js +65 -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,EAU2G,GAAG,EAMxH,QAAQ,
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU2G,GAAG,EAMxH,QAAQ,EAGT,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;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;AA4OF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe;oCA83IpB,OAAO;sDAPW,gBAAgB,EAAE;;;;sBAhBjD,UAAU,GAAG,SAAS;;;8BA4Df,UAAU;2BAuBb,UAAU;;;iBAW3B,MAAM;kBACL,MAAM;kBACN,MAAM;qBACH,MAAM;;kBA/4IF,UAAU,WAAW,MAAM,YAAY,YAAY;EAk7IzE;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;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
|
@@ -571,6 +571,9 @@ function createErrorDiagnoser(context) {
|
|
|
571
571
|
else if (nasl_concepts_1.asserts.isValidationLogic(node)) {
|
|
572
572
|
message = '验证函数:参数不能为空!';
|
|
573
573
|
}
|
|
574
|
+
else if (nasl_concepts_1.asserts.isNewComposite(node)) {
|
|
575
|
+
message = '新建实体/数据结构:参数不能为空!';
|
|
576
|
+
}
|
|
574
577
|
if (message) {
|
|
575
578
|
error(node, message);
|
|
576
579
|
}
|
|
@@ -1097,6 +1100,11 @@ function createErrorDiagnoser(context) {
|
|
|
1097
1100
|
});
|
|
1098
1101
|
}
|
|
1099
1102
|
}
|
|
1103
|
+
if (node.interfaces?.length) {
|
|
1104
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.interfaces, function* (node) {
|
|
1105
|
+
yield* checkNode(node);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1100
1108
|
yield* checkNode(node.configuration);
|
|
1101
1109
|
if (node.type === 'sharedApp') {
|
|
1102
1110
|
const status = getStatusOfSharedApp(node);
|
|
@@ -1316,6 +1324,11 @@ function createErrorDiagnoser(context) {
|
|
|
1316
1324
|
yield* checkNode(node);
|
|
1317
1325
|
});
|
|
1318
1326
|
}
|
|
1327
|
+
if (node.indexes?.length) {
|
|
1328
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.indexes, function* (node) {
|
|
1329
|
+
yield* checkNode(node);
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1319
1332
|
// 在多模式切换为单模式的时候,数据库表名是否符合规范
|
|
1320
1333
|
// /^[a-zA-Z0-9_]+$/ 由字母、数字、下划线组成
|
|
1321
1334
|
const dataSource = node.dataSource;
|
|
@@ -1643,6 +1656,23 @@ function createErrorDiagnoser(context) {
|
|
|
1643
1656
|
}
|
|
1644
1657
|
}
|
|
1645
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* 检查 实体索引
|
|
1661
|
+
* @param node
|
|
1662
|
+
*/
|
|
1663
|
+
function* checkEntityIndex(node) {
|
|
1664
|
+
if (node.propertyNames?.length) {
|
|
1665
|
+
const entity = node.parentNode;
|
|
1666
|
+
node.propertyNames.forEach((propertyName) => {
|
|
1667
|
+
const prop = findPropertyByName(entity, propertyName);
|
|
1668
|
+
if (!prop) {
|
|
1669
|
+
const scope = node?.constructor?.nodeTitle;
|
|
1670
|
+
error(node, `${scope}:索引${node.name}找不到 实体上的 ${propertyName}属性。`);
|
|
1671
|
+
return errorType;
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1646
1676
|
/**
|
|
1647
1677
|
* 检查 枚举
|
|
1648
1678
|
* @param node
|
|
@@ -1783,6 +1813,17 @@ function createErrorDiagnoser(context) {
|
|
|
1783
1813
|
yield* checkNode(node);
|
|
1784
1814
|
});
|
|
1785
1815
|
}
|
|
1816
|
+
// 仅对内部接口(app.interfaces,由 Logic 导出)校验 originLogicName;外部接口(interfaceDependencies 等)无此字段
|
|
1817
|
+
const isInternalInterface = nasl_concepts_1.asserts.isApp(node.parentNode);
|
|
1818
|
+
if (isInternalInterface) {
|
|
1819
|
+
if (ensureNodeKeyExists(node, 'originLogicName')) {
|
|
1820
|
+
const originLogicName = node.originLogicName;
|
|
1821
|
+
const ref = app.logics.find((item) => item.name === originLogicName);
|
|
1822
|
+
if (!ref) {
|
|
1823
|
+
error(node, `接口 ${node.title || node.name} 引用了不存在的逻辑 ${originLogicName}`);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1786
1827
|
yield* checkNode(node.validation);
|
|
1787
1828
|
yield* checkTimeout(node);
|
|
1788
1829
|
env.exitScope();
|
|
@@ -1970,6 +2011,17 @@ function createErrorDiagnoser(context) {
|
|
|
1970
2011
|
*/
|
|
1971
2012
|
function* checkBusinessComponent(node) {
|
|
1972
2013
|
env.enterScope(node);
|
|
2014
|
+
if (node.params?.length) {
|
|
2015
|
+
yield* checkParams(node.params);
|
|
2016
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
|
|
2017
|
+
yield* checkNode(node);
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
if (node.variables?.length) {
|
|
2021
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
|
|
2022
|
+
yield* checkNode(node);
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
1973
2025
|
// 组件元素
|
|
1974
2026
|
if (node.elements?.length) {
|
|
1975
2027
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.elements, function* (node) {
|
|
@@ -2929,15 +2981,27 @@ function createErrorDiagnoser(context) {
|
|
|
2929
2981
|
}
|
|
2930
2982
|
return type;
|
|
2931
2983
|
function checkListSort(nd) {
|
|
2984
|
+
const parTy = env.getType(nd.arguments?.[0]);
|
|
2985
|
+
let paramType = '未知类型';
|
|
2986
|
+
if (parTy?.typeName === 'List') {
|
|
2987
|
+
paramType = (0, type_manager_1.showUserLevelType)(parTy.typeArguments?.[0] || type_manager_1.naslAnyTy);
|
|
2988
|
+
}
|
|
2989
|
+
const expectTy = `{ by: (item: ${paramType}) => 未知类型, asc: 布尔值 }`;
|
|
2932
2990
|
for (let i = 1; i < nd.arguments.length; i++) {
|
|
2933
2991
|
const expr = nd.arguments[i].expression;
|
|
2934
2992
|
let resTy;
|
|
2935
2993
|
if (expr?.concept === 'AnonymousFunction') {
|
|
2936
2994
|
resTy = env.getType(expr.body);
|
|
2995
|
+
if (!nasl_concepts_1.asserts.isNewComposite(expr.body)) {
|
|
2996
|
+
error(nd.arguments[i], (0, sem_diag_1.mkIncompatibleTyErr)(env, env.getType(expr) || type_manager_1.naslAnyTy, expectTy));
|
|
2997
|
+
}
|
|
2937
2998
|
}
|
|
2938
2999
|
else if (expr?.concept === 'SubLogic') {
|
|
2939
3000
|
resTy = env.getType(expr.returns?.[0]);
|
|
2940
3001
|
}
|
|
3002
|
+
else {
|
|
3003
|
+
error(nd.arguments[i], (0, sem_diag_1.mkIncompatibleTyErr)(env, env.getType(expr) || type_manager_1.naslAnyTy, expectTy));
|
|
3004
|
+
}
|
|
2941
3005
|
const byTy = resTy?.properties?.find((prop) => prop.name === 'by')?.typeAnnotation;
|
|
2942
3006
|
if (byTy?.typeKind === 'union') {
|
|
2943
3007
|
// 这里使用 node.arguments[i] 则无红框,猜测是 ListSort 的特殊交互导致的问题
|
|
@@ -3367,11 +3431,23 @@ function createErrorDiagnoser(context) {
|
|
|
3367
3431
|
}
|
|
3368
3432
|
else {
|
|
3369
3433
|
const { name } = node;
|
|
3434
|
+
// 检查是否在 NewComposite 的 properties(左边)中
|
|
3435
|
+
// 如果在 properties 中,可以跳过未定义检查(因为 properties 是属性名,不是变量)
|
|
3436
|
+
// 但如果是在 rights(右边)中,即使有类型也应该检查变量是否定义
|
|
3437
|
+
const newComposite = node.getAncestor('NewComposite');
|
|
3438
|
+
if (newComposite) {
|
|
3439
|
+
const { properties = [] } = newComposite;
|
|
3440
|
+
// 只对 properties 中的 node 允许跳过未定义检查
|
|
3441
|
+
// 无论是否有类型都应该返回,因为 properties 是属性名,不是变量,不应该报"未定义"错误
|
|
3442
|
+
if (properties.some((item) => item === node)) {
|
|
3443
|
+
const type = env.getType(node);
|
|
3444
|
+
return type || errorType;
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3370
3447
|
if (
|
|
3371
3448
|
// name 是 A.B.C
|
|
3372
3449
|
name?.split('.')?.length > 1
|
|
3373
|
-
|| node.getAncestor('CallQueryComponent')
|
|
3374
|
-
|| node.getAncestor('NewComposite')) {
|
|
3450
|
+
|| node.getAncestor('CallQueryComponent')) {
|
|
3375
3451
|
const type = env.getType(node);
|
|
3376
3452
|
if (type) {
|
|
3377
3453
|
return type;
|
|
@@ -3558,6 +3634,7 @@ function createErrorDiagnoser(context) {
|
|
|
3558
3634
|
*/
|
|
3559
3635
|
function* checkNewComposite(node) {
|
|
3560
3636
|
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3637
|
+
ensureNodeKeyExists(node, 'typeAnnotation');
|
|
3561
3638
|
const type = env.getType(node);
|
|
3562
3639
|
if (node.properties?.length) {
|
|
3563
3640
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (property, index) {
|
|
@@ -3797,7 +3874,13 @@ function createErrorDiagnoser(context) {
|
|
|
3797
3874
|
return;
|
|
3798
3875
|
}
|
|
3799
3876
|
const { entityAsName } = node;
|
|
3800
|
-
const
|
|
3877
|
+
const callQueryComponent = node.getAncestor('CallQueryComponent');
|
|
3878
|
+
if (!callQueryComponent.inFromJoinPart(entityAsName)) {
|
|
3879
|
+
// 实体不存在from中
|
|
3880
|
+
error(node, '数据查询:所查询的实体不存在数据源中。');
|
|
3881
|
+
return;
|
|
3882
|
+
}
|
|
3883
|
+
const entityNamespace = node.entityNamespace ?? callQueryComponent?.from?.entityNamespace;
|
|
3801
3884
|
const entityQName = `${entityNamespace}.${entityAsName}`;
|
|
3802
3885
|
const ref = referenceManager.gQNameDefs.get(entityQName);
|
|
3803
3886
|
if (!ref) {
|
|
@@ -4182,6 +4265,8 @@ function createErrorDiagnoser(context) {
|
|
|
4182
4265
|
return yield* checkBackendVariable(node);
|
|
4183
4266
|
case 'Param':
|
|
4184
4267
|
return yield* checkParam(node);
|
|
4268
|
+
case 'ParamWithGroup':
|
|
4269
|
+
return yield* checkParam(node);
|
|
4185
4270
|
case 'Return':
|
|
4186
4271
|
return yield* checkReturn(node);
|
|
4187
4272
|
case 'DefaultValue':
|
|
@@ -4196,6 +4281,8 @@ function createErrorDiagnoser(context) {
|
|
|
4196
4281
|
return yield* checkEntity(node);
|
|
4197
4282
|
case 'EntityProperty':
|
|
4198
4283
|
return yield* checkEntityProperty(node);
|
|
4284
|
+
case 'EntityIndex':
|
|
4285
|
+
return yield* checkEntityIndex(node);
|
|
4199
4286
|
case 'Enum':
|
|
4200
4287
|
return yield* checkEnum(node);
|
|
4201
4288
|
case 'EnumItem':
|
|
@@ -4407,6 +4494,10 @@ function createErrorDiagnoser(context) {
|
|
|
4407
4494
|
// TODO: checkNodeIsFileModuleInIdeWithCache 也慢,后续可以优化
|
|
4408
4495
|
const isFileModule = fileNodes.length ? (0, file_node_cache_1.checkNodeIsFileModuleInIdeWithCache)(node) : true;
|
|
4409
4496
|
if (isFileModule) {
|
|
4497
|
+
// 增量更新时按文件逐个 checkNode,需重置闭包状态;若本文件在 Module 内,inModule 需为 true(否则不会经过 checkModule,inModule 会失效)
|
|
4498
|
+
inModule = !!node.getAncestor?.('Module');
|
|
4499
|
+
inPlayground = 0;
|
|
4500
|
+
inAuthLogic = false;
|
|
4410
4501
|
fileNodes.push(node);
|
|
4411
4502
|
let diagnostics = diagnosticMap.get(node);
|
|
4412
4503
|
if (!diagnostics) {
|
|
@@ -4491,8 +4582,6 @@ function createErrorDiagnoser(context) {
|
|
|
4491
4582
|
}
|
|
4492
4583
|
});
|
|
4493
4584
|
diagnostics?.clear();
|
|
4494
|
-
// 删除 diagnosticMap 中的 key,避免内存泄漏和冗余报错
|
|
4495
|
-
diagnosticMap.delete(node);
|
|
4496
4585
|
}
|
|
4497
4586
|
else {
|
|
4498
4587
|
diagnosticMap.clear();
|