@lcap/nasl-language-server-core 4.3.0-beta.26 → 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.
Files changed (73) hide show
  1. package/out/checker.d.ts.map +1 -1
  2. package/out/checker.js +82 -5
  3. package/out/checker.js.map +1 -1
  4. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  5. package/out/reference-manager/collect-q-name.js +6 -3
  6. package/out/reference-manager/collect-q-name.js.map +1 -1
  7. package/out/reference-manager/get-q-name.js +3 -3
  8. package/out/reference-manager/get-q-name.js.map +1 -1
  9. package/out/reference-manager/reference-manager.d.ts +4 -1
  10. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  11. package/out/reference-manager/reference-manager.js +16 -15
  12. package/out/reference-manager/reference-manager.js.map +1 -1
  13. package/out/reference-manager/symbol-type.d.ts.map +1 -1
  14. package/out/reference-manager/symbol-type.js +1 -0
  15. package/out/reference-manager/symbol-type.js.map +1 -1
  16. package/out/typer/collectGlobalDefs.js +1 -1
  17. package/out/typer/collectGlobalDefs.js.map +1 -1
  18. package/out/typer/dispatch-call.d.ts.map +1 -1
  19. package/out/typer/dispatch-call.js +4 -0
  20. package/out/typer/dispatch-call.js.map +1 -1
  21. package/out/typer/dispatch-def.d.ts.map +1 -1
  22. package/out/typer/dispatch-def.js +32 -5
  23. package/out/typer/dispatch-def.js.map +1 -1
  24. package/out/typer/dispatch-expr.d.ts.map +1 -1
  25. package/out/typer/dispatch-expr.js +124 -127
  26. package/out/typer/dispatch-expr.js.map +1 -1
  27. package/out/typer/dispatch-stmt.d.ts.map +1 -1
  28. package/out/typer/dispatch-stmt.js +27 -23
  29. package/out/typer/dispatch-stmt.js.map +1 -1
  30. package/out/typer/dispatch-view.d.ts.map +1 -1
  31. package/out/typer/dispatch-view.js +58 -41
  32. package/out/typer/dispatch-view.js.map +1 -1
  33. package/out/typer/incremental-update.d.ts +2 -6
  34. package/out/typer/incremental-update.d.ts.map +1 -1
  35. package/out/typer/incremental-update.js +95 -98
  36. package/out/typer/incremental-update.js.map +1 -1
  37. package/out/typer/oql-checker/ts-parser.d.ts.map +1 -1
  38. package/out/typer/oql-checker/ts-parser.js +99 -20
  39. package/out/typer/oql-checker/ts-parser.js.map +1 -1
  40. package/out/typer/overload-helper.d.ts.map +1 -1
  41. package/out/typer/overload-helper.js +135 -9
  42. package/out/typer/overload-helper.js.map +1 -1
  43. package/out/typer/solver.d.ts +8 -9
  44. package/out/typer/solver.d.ts.map +1 -1
  45. package/out/typer/solver.js +54 -31
  46. package/out/typer/solver.js.map +1 -1
  47. package/out/typer/subster.d.ts.map +1 -1
  48. package/out/typer/subster.js +174 -48
  49. package/out/typer/subster.js.map +1 -1
  50. package/out/typer/topo-sort.d.ts +37 -0
  51. package/out/typer/topo-sort.d.ts.map +1 -1
  52. package/out/typer/topo-sort.js +260 -1
  53. package/out/typer/topo-sort.js.map +1 -1
  54. package/out/typer/type-manager.d.ts.map +1 -1
  55. package/out/typer/type-manager.js +3 -3
  56. package/out/typer/type-manager.js.map +1 -1
  57. package/out/typer/type-predicate.d.ts +1 -0
  58. package/out/typer/type-predicate.d.ts.map +1 -1
  59. package/out/typer/type-predicate.js +12 -4
  60. package/out/typer/type-predicate.js.map +1 -1
  61. package/out/typer/typer.d.ts +30 -2
  62. package/out/typer/typer.d.ts.map +1 -1
  63. package/out/typer/typer.js +109 -11
  64. package/out/typer/typer.js.map +1 -1
  65. package/out/typer/unifier.d.ts +11 -0
  66. package/out/typer/unifier.d.ts.map +1 -1
  67. package/out/typer/unifier.js +73 -30
  68. package/out/typer/unifier.js.map +1 -1
  69. package/out/utils/type-operator.d.ts +15 -0
  70. package/out/utils/type-operator.d.ts.map +1 -1
  71. package/out/utils/type-operator.js +65 -3
  72. package/out/utils/type-operator.js.map +1 -1
  73. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"A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U,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) {
@@ -3379,11 +3431,23 @@ function createErrorDiagnoser(context) {
3379
3431
  }
3380
3432
  else {
3381
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
+ }
3382
3447
  if (
3383
3448
  // name 是 A.B.C
3384
3449
  name?.split('.')?.length > 1
3385
- || node.getAncestor('CallQueryComponent')
3386
- || node.getAncestor('NewComposite')) {
3450
+ || node.getAncestor('CallQueryComponent')) {
3387
3451
  const type = env.getType(node);
3388
3452
  if (type) {
3389
3453
  return type;
@@ -3570,6 +3634,7 @@ function createErrorDiagnoser(context) {
3570
3634
  */
3571
3635
  function* checkNewComposite(node) {
3572
3636
  yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
3637
+ ensureNodeKeyExists(node, 'typeAnnotation');
3573
3638
  const type = env.getType(node);
3574
3639
  if (node.properties?.length) {
3575
3640
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (property, index) {
@@ -3809,7 +3874,13 @@ function createErrorDiagnoser(context) {
3809
3874
  return;
3810
3875
  }
3811
3876
  const { entityAsName } = node;
3812
- const entityNamespace = node.entityNamespace ?? node.getAncestor('CallQueryComponent')?.from?.entityNamespace;
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;
3813
3884
  const entityQName = `${entityNamespace}.${entityAsName}`;
3814
3885
  const ref = referenceManager.gQNameDefs.get(entityQName);
3815
3886
  if (!ref) {
@@ -4194,6 +4265,8 @@ function createErrorDiagnoser(context) {
4194
4265
  return yield* checkBackendVariable(node);
4195
4266
  case 'Param':
4196
4267
  return yield* checkParam(node);
4268
+ case 'ParamWithGroup':
4269
+ return yield* checkParam(node);
4197
4270
  case 'Return':
4198
4271
  return yield* checkReturn(node);
4199
4272
  case 'DefaultValue':
@@ -4208,6 +4281,8 @@ function createErrorDiagnoser(context) {
4208
4281
  return yield* checkEntity(node);
4209
4282
  case 'EntityProperty':
4210
4283
  return yield* checkEntityProperty(node);
4284
+ case 'EntityIndex':
4285
+ return yield* checkEntityIndex(node);
4211
4286
  case 'Enum':
4212
4287
  return yield* checkEnum(node);
4213
4288
  case 'EnumItem':
@@ -4419,6 +4494,10 @@ function createErrorDiagnoser(context) {
4419
4494
  // TODO: checkNodeIsFileModuleInIdeWithCache 也慢,后续可以优化
4420
4495
  const isFileModule = fileNodes.length ? (0, file_node_cache_1.checkNodeIsFileModuleInIdeWithCache)(node) : true;
4421
4496
  if (isFileModule) {
4497
+ // 增量更新时按文件逐个 checkNode,需重置闭包状态;若本文件在 Module 内,inModule 需为 true(否则不会经过 checkModule,inModule 会失效)
4498
+ inModule = !!node.getAncestor?.('Module');
4499
+ inPlayground = 0;
4500
+ inAuthLogic = false;
4422
4501
  fileNodes.push(node);
4423
4502
  let diagnostics = diagnosticMap.get(node);
4424
4503
  if (!diagnostics) {
@@ -4503,8 +4582,6 @@ function createErrorDiagnoser(context) {
4503
4582
  }
4504
4583
  });
4505
4584
  diagnostics?.clear();
4506
- // 删除 diagnosticMap 中的 key,避免内存泄漏和冗余报错
4507
- diagnosticMap.delete(node);
4508
4585
  }
4509
4586
  else {
4510
4587
  diagnosticMap.clear();