@lcap/nasl-language-server-core 4.1.0-rc.9 → 4.2.0-beta.1

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 (81) hide show
  1. package/out/checker.d.ts.map +1 -1
  2. package/out/checker.js +77 -68
  3. package/out/checker.js.map +1 -1
  4. package/out/reference-manager/collect-q-name.d.ts +2 -2
  5. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  6. package/out/reference-manager/collect-q-name.js +73 -111
  7. package/out/reference-manager/collect-q-name.js.map +1 -1
  8. package/out/reference-manager/concept-registry.d.ts +8 -0
  9. package/out/reference-manager/concept-registry.d.ts.map +1 -0
  10. package/out/reference-manager/concept-registry.js +56 -0
  11. package/out/reference-manager/concept-registry.js.map +1 -0
  12. package/out/reference-manager/get-q-name.d.ts.map +1 -1
  13. package/out/reference-manager/get-q-name.js +4 -0
  14. package/out/reference-manager/get-q-name.js.map +1 -1
  15. package/out/reference-manager/helper.d.ts +1 -1
  16. package/out/reference-manager/helper.d.ts.map +1 -1
  17. package/out/reference-manager/reference-manager.d.ts +10 -1
  18. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  19. package/out/reference-manager/reference-manager.js +67 -13
  20. package/out/reference-manager/reference-manager.js.map +1 -1
  21. package/out/reference-manager/remove-q-name.d.ts +0 -9
  22. package/out/reference-manager/remove-q-name.d.ts.map +1 -1
  23. package/out/reference-manager/remove-q-name.js +62 -116
  24. package/out/reference-manager/remove-q-name.js.map +1 -1
  25. package/out/reference-manager/rename-q-name.d.ts +1 -0
  26. package/out/reference-manager/rename-q-name.d.ts.map +1 -1
  27. package/out/reference-manager/rename-q-name.js +59 -94
  28. package/out/reference-manager/rename-q-name.js.map +1 -1
  29. package/out/reference-manager/symbol-type.d.ts +3 -3
  30. package/out/reference-manager/symbol-type.d.ts.map +1 -1
  31. package/out/reference-manager/symbol-type.js +3 -0
  32. package/out/reference-manager/symbol-type.js.map +1 -1
  33. package/out/symbol/traverse/concepts/index.d.ts +1 -1
  34. package/out/symbol/traverse/concepts/index.d.ts.map +1 -1
  35. package/out/symbol/traverse/concepts/logic/expression/expression.d.ts.map +1 -1
  36. package/out/symbol/traverse/concepts/logic/expression/expression.js +2 -1
  37. package/out/symbol/traverse/concepts/logic/expression/expression.js.map +1 -1
  38. package/out/typer/dispatch-all.d.ts +2 -3
  39. package/out/typer/dispatch-all.d.ts.map +1 -1
  40. package/out/typer/dispatch-all.js +18 -38
  41. package/out/typer/dispatch-all.js.map +1 -1
  42. package/out/typer/dispatch-call.d.ts.map +1 -1
  43. package/out/typer/dispatch-call.js +31 -0
  44. package/out/typer/dispatch-call.js.map +1 -1
  45. package/out/typer/dispatch-def.d.ts +3 -9
  46. package/out/typer/dispatch-def.d.ts.map +1 -1
  47. package/out/typer/dispatch-def.js +18 -52
  48. package/out/typer/dispatch-def.js.map +1 -1
  49. package/out/typer/dispatch-expr.d.ts.map +1 -1
  50. package/out/typer/dispatch-expr.js +31 -7
  51. package/out/typer/dispatch-expr.js.map +1 -1
  52. package/out/typer/dispatch-process.d.ts +2 -2
  53. package/out/typer/dispatch-process.d.ts.map +1 -1
  54. package/out/typer/dispatch-process.js +15 -11
  55. package/out/typer/dispatch-process.js.map +1 -1
  56. package/out/typer/dispatch-stmt.d.ts.map +1 -1
  57. package/out/typer/dispatch-stmt.js.map +1 -1
  58. package/out/typer/dispatch-view.d.ts.map +1 -1
  59. package/out/typer/dispatch-view.js +29 -20
  60. package/out/typer/dispatch-view.js.map +1 -1
  61. package/out/typer/helper.d.ts.map +1 -1
  62. package/out/typer/helper.js.map +1 -1
  63. package/out/typer/incremental-update.js +2 -1
  64. package/out/typer/incremental-update.js.map +1 -1
  65. package/out/typer/subster.d.ts.map +1 -1
  66. package/out/typer/subster.js +16 -9
  67. package/out/typer/subster.js.map +1 -1
  68. package/out/typer/topo-sort.d.ts.map +1 -1
  69. package/out/typer/topo-sort.js +2 -1
  70. package/out/typer/topo-sort.js.map +1 -1
  71. package/out/typer/type-manager.d.ts.map +1 -1
  72. package/out/typer/type-manager.js +4 -1
  73. package/out/typer/type-manager.js.map +1 -1
  74. package/out/typer/typer.d.ts +6 -2
  75. package/out/typer/typer.d.ts.map +1 -1
  76. package/out/typer/typer.js +7 -4
  77. package/out/typer/typer.js.map +1 -1
  78. package/out/typer/unifier.d.ts.map +1 -1
  79. package/out/typer/unifier.js +10 -4
  80. package/out/typer/unifier.js.map +1 -1
  81. package/package.json +5 -5
@@ -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,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOpE,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,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B,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
@@ -31,19 +31,6 @@ const processV2TaskTitleMap = {
31
31
  SubmitTask: '执行任务',
32
32
  CCTask: '抄送任务',
33
33
  };
34
- /**
35
- * 是否属于 控制流节点
36
- * @param node
37
- */
38
- function isControlFlowNode(node) {
39
- return nasl_concepts_1.asserts.isStrictEnd(node) || nasl_concepts_1.asserts.isStrictAbort(node) || nasl_concepts_1.asserts.isStrictBreak(node) || nasl_concepts_1.asserts.isStrictContinue(node);
40
- }
41
- /**
42
- * 是否属于 调用表达式
43
- */
44
- function isCallExpression(node) {
45
- return nasl_concepts_1.asserts.isCallFunction(node) || nasl_concepts_1.asserts.isCallInterface(node) || nasl_concepts_1.asserts.isCallLogic(node) || nasl_concepts_1.asserts.isCallConnector(node) || nasl_concepts_1.asserts.isCallEvent(node);
46
- }
47
34
  const isEnd = (node) => node.concept === 'End';
48
35
  const isAbort = (node) => node.concept === 'Abort';
49
36
  const isBreak = (node) => node.concept === 'Break';
@@ -53,7 +40,6 @@ const isContinue = (node) => node.concept === 'Continue';
53
40
  * @param node
54
41
  */
55
42
  const fastIsControlFlowNode = (node) => isEnd(node) || isAbort(node) || isBreak(node) || isContinue(node);
56
- const isArgument = (node) => node.concept === 'Argument';
57
43
  /**
58
44
  * 是端类型下的参数
59
45
  * @param node
@@ -80,7 +66,8 @@ function getExpressionNodeName(concept) {
80
66
  CallInterface: '接口',
81
67
  CallAuthInterface: '鉴权接口',
82
68
  CallConnector: '连接器',
83
- CallMicroserviceInterface: '',
69
+ CallMicroserviceInterface: '微服务接口',
70
+ CallGatewayInterface: '网关接口',
84
71
  CallEvent: '事件',
85
72
  };
86
73
  return expressionNodeName[concept];
@@ -249,11 +236,6 @@ function resolveMetadataType(typeArg, app) {
249
236
  return metadataTypes?.find(metadataType => metadataType.name === typeArg.typeName)?.typeAnnotation;
250
237
  }
251
238
  }
252
- const cheapNewError = (obj) => {
253
- const err = Object.create(Error.prototype);
254
- Object.assign(err, obj);
255
- return err;
256
- };
257
239
  /**
258
240
  * 创建错误诊断器
259
241
  * @returns
@@ -391,7 +373,6 @@ function createErrorDiagnoser(context) {
391
373
  timeoutConfig.values.forEach((value) => {
392
374
  const __env = value.env;
393
375
  const timeout = Number(value.value);
394
- const label = value.envDisplayLabel;
395
376
  if (timeout * 1000 < retryInterval * retryTimes) {
396
377
  const HTTP_TIMEOUT_ORIGIN_MESSAGE = 'the local timeout is greater than the system timeout';
397
378
  error(node, `${nodeType}“${node.title ?? node.name}”配置的重试间隔时间乘以重试次数大于${__env === 'dev' ? '开发环境' : '生产环境'}接口超时时间,可能导致重试失败`, {
@@ -1628,6 +1609,30 @@ function createErrorDiagnoser(context) {
1628
1609
  error(node, message);
1629
1610
  }
1630
1611
  }
1612
+ const relationEntity = node.relationEntity;
1613
+ const relationNamespace = node.relationNamespace;
1614
+ const relationProperty = node.relationProperty;
1615
+ if (relationEntity && relationNamespace && relationProperty) {
1616
+ const releationEntityQName = `${relationNamespace}.${relationEntity}`;
1617
+ const releationEntityPropertyQName = `${releationEntityQName}.properties.${relationProperty}`;
1618
+ const entityEntityDef = env.refMgr.queryQNameDef(releationEntityQName);
1619
+ const entityPropertyDef = env.refMgr.queryQNameDef(releationEntityPropertyQName);
1620
+ if (entityPropertyDef) {
1621
+ const equal = (0, type_predicate_1.isEqualTy)(env, entityPropertyDef.typeAnnotation, node.typeAnnotation);
1622
+ if (equal) {
1623
+ return;
1624
+ }
1625
+ const content = (0, sem_diag_1.mkIncompatibleTyErr)(env, entityPropertyDef.typeAnnotation, node.typeAnnotation);
1626
+ const message = `关联属性${content}`;
1627
+ error(node, message);
1628
+ }
1629
+ else {
1630
+ const message = entityEntityDef
1631
+ ? `找不到 ${relationEntity} 上的 ${relationProperty}`
1632
+ : `找不到实体 ${relationEntity}`;
1633
+ error(node, message);
1634
+ }
1635
+ }
1631
1636
  }
1632
1637
  /**
1633
1638
  * 检查 枚举
@@ -2500,59 +2505,63 @@ function createErrorDiagnoser(context) {
2500
2505
  error(node.sharedScope, '共享范围为指定应用时,必须指定共享应用');
2501
2506
  }
2502
2507
  // 导出接口
2503
- if (node?.exportInterface) {
2504
- let isSame = true;
2505
- const itf = node.exportInterface;
2506
- const { params: logicParams = [], returns: logicReturns = [] } = node;
2507
- const { params: itfParams = [], returns: itfReturns = [] } = itf;
2508
- // 参数和返回数量不同
2509
- if (logicParams.length !== itfParams.length || logicReturns.length !== itfReturns.length) {
2510
- isSame = false;
2511
- }
2512
- if (isSame && logicParams.length === itfParams.length) {
2513
- const logicParamMap = logicParams?.reduce((acc, param) => {
2514
- acc[param.name] = param.typeAnnotation;
2515
- return acc;
2516
- }, {});
2517
- itfParams.forEach((param) => {
2518
- const logicParam = logicParamMap?.[param.name];
2519
- if (!logicParam) {
2520
- isSame = false;
2521
- return;
2522
- }
2523
- // 枚举会被转为 String
2524
- else if (logicParam.typeKind === 'reference' && logicParam.typeNamespace?.endsWith('enums')) {
2525
- if (param.typeAnnotation.typeName !== 'String') {
2508
+ if (node?.exportInterfaces?.length) {
2509
+ node?.exportInterfaces?.forEach?.((exportInterface) => {
2510
+ let isSame = true;
2511
+ const itf = exportInterface;
2512
+ const { params: logicParams = [], returns: logicReturns = [] } = node;
2513
+ const { params: itfParams = [], returns: itfReturns = [] } = itf;
2514
+ // 参数和返回数量不同
2515
+ if (logicParams.length !== itfParams.length || logicReturns.length !== itfReturns.length) {
2516
+ isSame = false;
2517
+ }
2518
+ if (isSame && logicParams.length === itfParams.length) {
2519
+ const logicParamMap = logicParams?.reduce((acc, param) => {
2520
+ acc[param.name] = param.typeAnnotation;
2521
+ return acc;
2522
+ }, {});
2523
+ itfParams.forEach((param) => {
2524
+ const logicParam = logicParamMap?.[param.name];
2525
+ if (!logicParam) {
2526
2526
  isSame = false;
2527
2527
  return;
2528
2528
  }
2529
+ // 枚举会被转为 String
2530
+ else if (logicParam.typeKind === 'reference' && logicParam.typeNamespace?.endsWith('enums')) {
2531
+ if (param.typeAnnotation.typeName !== 'String') {
2532
+ isSame = false;
2533
+ return;
2534
+ }
2535
+ }
2536
+ else if (!logicParam.isSame(param.typeAnnotation)) {
2537
+ isSame = false;
2538
+ return;
2539
+ }
2540
+ });
2541
+ }
2542
+ if (isSame && logicReturns.length === itfReturns.length && logicReturns.length > 0) {
2543
+ if (logicReturns[0].name !== itfReturns[0].name) {
2544
+ isSame = false;
2529
2545
  }
2530
- else if (!logicParam.isSame(param.typeAnnotation)) {
2546
+ else if (!(0, type_predicate_1.isEqualTy)(env, env.getType(logicReturns[0]), env.getType(itfReturns[0]))) {
2531
2547
  isSame = false;
2532
- return;
2533
2548
  }
2534
- });
2535
- }
2536
- if (isSame && logicReturns.length === itfReturns.length && logicReturns.length > 0) {
2537
- if (logicReturns[0].name !== itfReturns[0].name) {
2538
- isSame = false;
2539
2549
  }
2540
- else if (!(0, type_predicate_1.isEqualTy)(env, env.getType(logicReturns[0]), env.getType(itfReturns[0]))) {
2541
- isSame = false;
2550
+ if (!isSame) {
2551
+ const macthed = exportInterface.concept === 'McpInterface';
2552
+ const key = macthed ? 'exportMcpInterface' : 'exportInterface';
2553
+ error(node, `逻辑已变更,请确认请求类型无误后重新导出${'${event}'}`, {
2554
+ severity: Severity.ERROR,
2555
+ events: [
2556
+ {
2557
+ key,
2558
+ label: '接口配置',
2559
+ params: node,
2560
+ },
2561
+ ],
2562
+ });
2542
2563
  }
2543
- }
2544
- if (!isSame) {
2545
- error(node, `逻辑已变更,请确认请求类型无误后重新导出${'${event}'}`, {
2546
- severity: Severity.ERROR,
2547
- events: [
2548
- {
2549
- key: 'exportInterface',
2550
- label: '接口配置',
2551
- params: node,
2552
- },
2553
- ],
2554
- });
2555
- }
2564
+ });
2556
2565
  }
2557
2566
  }
2558
2567
  const likeComponent = (node.getAncestorRaw('View') || node.getAncestorRaw('BusinessComponent'));
@@ -3851,7 +3860,7 @@ function createErrorDiagnoser(context) {
3851
3860
  return errorType;
3852
3861
  }
3853
3862
  const typeAnnotation = (yield* checkNode(node.expression));
3854
- if (typeAnnotation.typeKind === 'generic') {
3863
+ if (typeAnnotation?.typeKind === 'generic') {
3855
3864
  yield* checkGenericTypeHasExpectedTyArgs(typeAnnotation);
3856
3865
  }
3857
3866
  return typeAnnotation;
@@ -4244,7 +4253,7 @@ function createErrorDiagnoser(context) {
4244
4253
  }
4245
4254
  }
4246
4255
  catch (err) {
4247
- // console.error(err);
4256
+ console.error(err);
4248
4257
  }
4249
4258
  }
4250
4259
  /**