@lcap/nasl-language-server-core 4.0.0-beta.6 → 4.0.0-beta.8

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 (126) hide show
  1. package/out/checker.d.ts +6 -6
  2. package/out/checker.d.ts.map +1 -1
  3. package/out/checker.js +56 -41
  4. package/out/checker.js.map +1 -1
  5. package/out/index.d.ts +2 -0
  6. package/out/index.d.ts.map +1 -1
  7. package/out/index.js +2 -0
  8. package/out/index.js.map +1 -1
  9. package/out/reference-manager/collect-q-name.d.ts +2 -2
  10. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  11. package/out/reference-manager/collect-q-name.js +15 -10
  12. package/out/reference-manager/collect-q-name.js.map +1 -1
  13. package/out/reference-manager/get-q-name.d.ts +1 -1
  14. package/out/reference-manager/get-q-name.d.ts.map +1 -1
  15. package/out/reference-manager/get-q-name.js +7 -6
  16. package/out/reference-manager/get-q-name.js.map +1 -1
  17. package/out/reference-manager/reference-manager.d.ts +54 -17
  18. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  19. package/out/reference-manager/reference-manager.js +227 -169
  20. package/out/reference-manager/reference-manager.js.map +1 -1
  21. package/out/reference-manager/remove-q-name.d.ts +2 -2
  22. package/out/reference-manager/remove-q-name.d.ts.map +1 -1
  23. package/out/reference-manager/remove-q-name.js +15 -9
  24. package/out/reference-manager/remove-q-name.js.map +1 -1
  25. package/out/reference-manager/rename-q-name.d.ts +2 -2
  26. package/out/reference-manager/rename-q-name.d.ts.map +1 -1
  27. package/out/reference-manager/rename-q-name.js +8 -5
  28. package/out/reference-manager/rename-q-name.js.map +1 -1
  29. package/out/reference-manager/symbol-type.d.ts +2 -2
  30. package/out/reference-manager/symbol-type.d.ts.map +1 -1
  31. package/out/reference-manager/symbol-type.js +1 -0
  32. package/out/reference-manager/symbol-type.js.map +1 -1
  33. package/out/reference-manager/update-nasl-fragment.d.ts +2 -0
  34. package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
  35. package/out/reference-manager/update-nasl-fragment.js +64 -21
  36. package/out/reference-manager/update-nasl-fragment.js.map +1 -1
  37. package/out/symbol/namespace.js +1 -1
  38. package/out/symbol/namespace.js.map +1 -1
  39. package/out/symbol/traverse/concepts/logic/variable.d.ts.map +1 -1
  40. package/out/symbol/traverse/concepts/logic/variable.js +2 -1
  41. package/out/symbol/traverse/concepts/logic/variable.js.map +1 -1
  42. package/out/symbol/traverse/concepts/other/app.js +3 -3
  43. package/out/symbol/traverse/concepts/other/app.js.map +1 -1
  44. package/out/typer/component-def-manager/component-def-manager.d.ts +11 -3
  45. package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
  46. package/out/typer/component-def-manager/component-def-manager.js +79 -18
  47. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  48. package/out/typer/component-def-manager/utils.d.ts.map +1 -1
  49. package/out/typer/component-def-manager/utils.js +6 -0
  50. package/out/typer/component-def-manager/utils.js.map +1 -1
  51. package/out/typer/dispatch-all.js +1 -1
  52. package/out/typer/dispatch-all.js.map +1 -1
  53. package/out/typer/dispatch-def.d.ts.map +1 -1
  54. package/out/typer/dispatch-def.js +25 -24
  55. package/out/typer/dispatch-def.js.map +1 -1
  56. package/out/typer/dispatch-expr.d.ts +2 -2
  57. package/out/typer/dispatch-expr.d.ts.map +1 -1
  58. package/out/typer/dispatch-expr.js +49 -44
  59. package/out/typer/dispatch-expr.js.map +1 -1
  60. package/out/typer/dispatch-process.d.ts.map +1 -1
  61. package/out/typer/dispatch-process.js +3 -3
  62. package/out/typer/dispatch-process.js.map +1 -1
  63. package/out/typer/dispatch-stmt.js +4 -4
  64. package/out/typer/dispatch-stmt.js.map +1 -1
  65. package/out/typer/dispatch-view.d.ts.map +1 -1
  66. package/out/typer/dispatch-view.js +46 -33
  67. package/out/typer/dispatch-view.js.map +1 -1
  68. package/out/typer/incremental-update.d.ts +36 -19
  69. package/out/typer/incremental-update.d.ts.map +1 -1
  70. package/out/typer/incremental-update.js +259 -161
  71. package/out/typer/incremental-update.js.map +1 -1
  72. package/out/typer/nasl-predicate.d.ts +6 -4
  73. package/out/typer/nasl-predicate.d.ts.map +1 -1
  74. package/out/typer/nasl-predicate.js +4 -1
  75. package/out/typer/nasl-predicate.js.map +1 -1
  76. package/out/typer/subster.d.ts.map +1 -1
  77. package/out/typer/subster.js +6 -11
  78. package/out/typer/subster.js.map +1 -1
  79. package/out/typer/topo-sort.d.ts.map +1 -1
  80. package/out/typer/topo-sort.js +4 -1
  81. package/out/typer/topo-sort.js.map +1 -1
  82. package/out/typer/type-hint-manager/type-hint-manager.d.ts +1 -1
  83. package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +1 -1
  84. package/out/typer/type-hint-manager/type-hint-manager.js +4 -4
  85. package/out/typer/type-hint-manager/type-hint-manager.js.map +1 -1
  86. package/out/typer/type-manager.d.ts +3 -1
  87. package/out/typer/type-manager.d.ts.map +1 -1
  88. package/out/typer/type-manager.js +72 -5
  89. package/out/typer/type-manager.js.map +1 -1
  90. package/out/typer/type-predicate.d.ts +10 -4
  91. package/out/typer/type-predicate.d.ts.map +1 -1
  92. package/out/typer/type-predicate.js +37 -18
  93. package/out/typer/type-predicate.js.map +1 -1
  94. package/out/typer/typer.d.ts +29 -13
  95. package/out/typer/typer.d.ts.map +1 -1
  96. package/out/typer/typer.js +53 -23
  97. package/out/typer/typer.js.map +1 -1
  98. package/out/typer/unifier.d.ts +6 -4
  99. package/out/typer/unifier.d.ts.map +1 -1
  100. package/out/typer/unifier.js +26 -52
  101. package/out/typer/unifier.js.map +1 -1
  102. package/out/types/diagnostics.d.ts +10 -0
  103. package/out/types/diagnostics.d.ts.map +1 -0
  104. package/out/types/diagnostics.js +3 -0
  105. package/out/types/diagnostics.js.map +1 -0
  106. package/out/utils/error-boundary.d.ts +1 -1
  107. package/out/utils/error-boundary.d.ts.map +1 -1
  108. package/out/utils/error-boundary.js +14 -13
  109. package/out/utils/error-boundary.js.map +1 -1
  110. package/out/utils/file-node-cache.d.ts +12 -0
  111. package/out/utils/file-node-cache.d.ts.map +1 -0
  112. package/out/utils/file-node-cache.js +30 -0
  113. package/out/utils/file-node-cache.js.map +1 -0
  114. package/out/utils/oql.d.ts +3 -0
  115. package/out/utils/oql.d.ts.map +1 -0
  116. package/out/utils/oql.js +26 -0
  117. package/out/utils/oql.js.map +1 -0
  118. package/out/utils/parseTsClassType.d.ts +2 -2
  119. package/out/utils/parseTsClassType.d.ts.map +1 -1
  120. package/out/utils/parseTsClassType.js +37 -9
  121. package/out/utils/parseTsClassType.js.map +1 -1
  122. package/out/utils/type-operator.d.ts +7 -7
  123. package/out/utils/type-operator.d.ts.map +1 -1
  124. package/out/utils/type-operator.js +52 -25
  125. package/out/utils/type-operator.js.map +1 -1
  126. package/package.json +6 -6
package/out/checker.d.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import type { SyntaxNode, App, BaseNode } from '@lcap/nasl-concepts';
2
2
  import { TypeAnnotation } from '@lcap/nasl-concepts';
3
3
  import { type SemEnv } from './typer';
4
+ import { Diagnostic as NaslTypeDiagnostic } from '@lcap/nasl-types';
4
5
  export declare enum Severity {
5
6
  WARN = "warning",
6
7
  ERROR = "error"
7
8
  }
8
- export interface Diagnostic {
9
- severity?: Severity;
10
- message?: string;
11
- }
9
+ export type Diagnostic = NaslTypeDiagnostic.Diagnostic<SyntaxNode>;
12
10
  type ErrorContext = {
13
11
  severity?: Severity;
14
12
  [key: string]: any;
@@ -41,8 +39,9 @@ export declare function createErrorDiagnoser(context: DiagnoseContext): {
41
39
  checkNode: (node: SyntaxNode | undefined) => Generator<TypeAnnotation | {
42
40
  typeKind: string;
43
41
  } | undefined, any, unknown>;
44
- clearDiagnostics: (node: SyntaxNode) => void;
45
- getDiagnostics: (node: SyntaxNode) => NodeDiagnosticsMap | FileDiagnosticsMap | undefined;
42
+ clearDiagnostics: (node?: SyntaxNode) => void;
43
+ getDiagnostics: (node: SyntaxNode) => NodeDiagnosticsMap | undefined;
44
+ getAllDiagnostics: () => FileDiagnosticsMap;
46
45
  error: (node: SyntaxNode, message: string, context?: ErrorContext) => void;
47
46
  };
48
47
  export interface DiagnosticRecord {
@@ -56,5 +55,6 @@ export interface DiagnosticRecord {
56
55
  suggestionDiagnostics: Array<Diagnostic>;
57
56
  }
58
57
  export declare const transformDiagnosticsToRecords: (fileNode: SyntaxNode, diagnostics: NodeDiagnosticsMap) => Array<DiagnosticRecord>;
58
+ export type ErrorDiagnoser = ReturnType<typeof createErrorDiagnoser>;
59
59
  export {};
60
60
  //# sourceMappingURL=checker.d.ts.map
@@ -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;AAQ7B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAKhE,oBAAY,QAAQ;IAClB,IAAI,YAAY;IAChB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,UAAU;IAEzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,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,C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CAAC;IACrC,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,6BAA6B,aAAc,UAAU,sCAAoC,MAAM,gBAAgB,CAmC3H,CAAA;AAMD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
package/out/checker.js CHANGED
@@ -4,6 +4,7 @@ exports.transformDiagnosticsToRecords = exports.createErrorDiagnoser = exports.S
4
4
  const decimal_js_1 = require("decimal.js");
5
5
  const nasl_concepts_1 = require("@lcap/nasl-concepts");
6
6
  const service_1 = require("@lcap/nasl-concepts/service");
7
+ const file_node_cache_1 = require("./utils/file-node-cache");
7
8
  const nasl_utils_1 = require("@lcap/nasl-utils");
8
9
  const typer_1 = require("./typer");
9
10
  const type_predicate_1 = require("./typer/type-predicate");
@@ -91,7 +92,7 @@ function getExpressionNodeName(concept) {
91
92
  function isDescendant(node, rangeNode) {
92
93
  let currentNode = node;
93
94
  while (currentNode) {
94
- if (currentNode === rangeNode) {
95
+ if (toRaw(currentNode) === toRaw(rangeNode)) {
95
96
  return true;
96
97
  }
97
98
  currentNode = currentNode.parentNode;
@@ -561,15 +562,6 @@ function createErrorDiagnoser(context) {
561
562
  message = 'SQL查询:语句不能为空。';
562
563
  }
563
564
  else if (nasl_concepts_1.asserts.isDestination(node)) {
564
- chkDest(node);
565
- }
566
- else if (node.concept === 'Argument' && nasl_concepts_1.asserts.isDestination(node.parentNode)) {
567
- chkDest(node.parentNode);
568
- }
569
- if (message) {
570
- error(node, message);
571
- }
572
- function chkDest(node) {
573
565
  const processElement = node.getAncestor('ProcessElementV2') ?? node.getAncestor('ProcessElement');
574
566
  if (processElement) {
575
567
  message = '任务未关联页面';
@@ -579,6 +571,9 @@ function createErrorDiagnoser(context) {
579
571
  message = '';
580
572
  }
581
573
  }
574
+ if (message) {
575
+ error(node, message);
576
+ }
582
577
  }
583
578
  /**
584
579
  * 创建一个未找到定义的实体的错误信息
@@ -677,7 +672,7 @@ function createErrorDiagnoser(context) {
677
672
  // 允许在当前业务组件中访问
678
673
  businessComponent,
679
674
  ],
680
- errMsg: `“${node.name}”是私有的,只能在“${businessComponent.name}”中访问。`,
675
+ errMsg: `"${node.name}"是私有的,只能在"${businessComponent.name}"中访问。`,
681
676
  } : null;
682
677
  case 'ConfigProperty':
683
678
  return node.isPrivate ? {
@@ -1100,8 +1095,8 @@ function createErrorDiagnoser(context) {
1100
1095
  const status = getStatusOfSharedApp(node);
1101
1096
  if (status) {
1102
1097
  const msgMap = {
1103
- update: `共享数据 ${node.name} 已在“${node.provider}应用”中更新,请同步更新`,
1104
- delete: `共享数据 ${node.name} 已在“${node.provider}应用”中被删除,请同步删除`,
1098
+ update: `共享数据 ${node.name} 已在"${node.provider}应用"中更新,请同步更新`,
1099
+ delete: `共享数据 ${node.name} 已在"${node.provider}应用"中被删除,请同步删除`,
1105
1100
  };
1106
1101
  error(node, msgMap[status], {
1107
1102
  severity: Severity.WARN,
@@ -1273,7 +1268,6 @@ function createErrorDiagnoser(context) {
1273
1268
  * @param node
1274
1269
  */
1275
1270
  function* checkDataSource(node) {
1276
- dbType = node.dataSourceSqlType;
1277
1271
  if (node.entities?.length) {
1278
1272
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.entities, function* (node) {
1279
1273
  yield* checkNode(node);
@@ -1297,13 +1291,13 @@ function createErrorDiagnoser(context) {
1297
1291
  });
1298
1292
  }
1299
1293
  }
1300
- dbType = '';
1301
1294
  }
1302
1295
  /**
1303
1296
  * 检查 实体
1304
1297
  * @param node
1305
1298
  */
1306
1299
  function* checkEntity(node) {
1300
+ dbType = node.getAncestor('DataSource')?.dataSourceSqlType;
1307
1301
  if (node.properties?.length) {
1308
1302
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (node) {
1309
1303
  yield* checkNode(node);
@@ -1321,6 +1315,7 @@ function createErrorDiagnoser(context) {
1321
1315
  if (node.sharedScope?.scope === 'specifiedRange' && !node.sharedScope?.specifiedRange?.length) {
1322
1316
  error(node, '共享范围为指定应用时,必须指定共享应用');
1323
1317
  }
1318
+ dbType = '';
1324
1319
  }
1325
1320
  function getCurrentDataBaseType(node) {
1326
1321
  if (node.databaseTypeAnnotation) {
@@ -1600,6 +1595,7 @@ function createErrorDiagnoser(context) {
1600
1595
  typeAnnotationErrorDetail.errorPos.min = errorMsg;
1601
1596
  }
1602
1597
  }
1598
+ typeAnnotation.tsErrorDetail = undefined;
1603
1599
  if (Object.keys(typeAnnotationErrorDetail.errorPos).length) {
1604
1600
  typeAnnotation.tsErrorDetail = typeAnnotationErrorDetail;
1605
1601
  }
@@ -2447,7 +2443,7 @@ function createErrorDiagnoser(context) {
2447
2443
  }
2448
2444
  }
2449
2445
  function* checkMsgTriggerLauncher(node) {
2450
- console.log(node);
2446
+ nasl_utils_1.isDebugMode && console.log(node);
2451
2447
  }
2452
2448
  /**
2453
2449
  * 检查 角色
@@ -2736,19 +2732,27 @@ function createErrorDiagnoser(context) {
2736
2732
  }
2737
2733
  yield* checkVoidCallUsedAsStatement(node);
2738
2734
  const ref = env.resolvedCallInfo.get(node) ?? env.resolveRef(node);
2735
+ const typeUnresolved = ref.ret
2736
+ ? (0, type_manager_1.hasUnresolvedTyInCallInfo)(ref) // 其他
2737
+ : (0, type_predicate_1.isUnResolvedTy)(ref); // 前端页面,TODO: 需要统一处理
2739
2738
  // Handle the new FunctionDefinition structure
2740
- if (ref?.params && !(0, type_manager_1.hasUnresolvedTyInCallInfo)(ref)) {
2739
+ if (ref?.params && !typeUnresolved) {
2741
2740
  // It's a FunctionDefinition object
2742
2741
  yield* checkScopeOfUse(node, ref);
2743
2742
  yield* checkCallExpressionParameters(node, ref);
2744
2743
  }
2745
- else if (ref && !(0, type_predicate_1.isUnResolvedTy)(ref)) {
2744
+ else if (ref && !typeUnresolved) {
2746
2745
  // 检查使用范围
2747
2746
  yield* checkScopeOfUse(node, ref);
2748
2747
  yield* checkCallExpressionParameters(node, ref);
2749
2748
  }
2750
2749
  else {
2751
- error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2750
+ if (ref.depLibName) {
2751
+ error(node, `找不到依赖库 ${ref.depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2752
+ }
2753
+ else {
2754
+ error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2755
+ }
2752
2756
  return errorType;
2753
2757
  }
2754
2758
  switch (node.concept) {
@@ -2823,6 +2827,9 @@ function createErrorDiagnoser(context) {
2823
2827
  * @param node
2824
2828
  */
2825
2829
  function* checkCallLogic(node) {
2830
+ // HACK 取这个字段会修复 arguments 中 keyword 为空的问题
2831
+ // 参考:流程回退接口报错500 http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=3127862102823424
2832
+ node.completeArguments;
2826
2833
  if (inAuthLogic && node.calleeNamespace?.startsWith?.('app.logics')) {
2827
2834
  const authLogic = node.getAncestor('AuthLogic');
2828
2835
  error(authLogic, `鉴权逻辑 ${authLogic.name} 不允许调用 服务端逻辑`);
@@ -3483,7 +3490,7 @@ function createErrorDiagnoser(context) {
3483
3490
  if (ensureNodeKeyExists(node, 'members')) {
3484
3491
  if (node.members?.length) {
3485
3492
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.members, function* (node) {
3486
- yield* checkNode(node);
3493
+ yield* checkNode(toRaw(node));
3487
3494
  });
3488
3495
  }
3489
3496
  }
@@ -3497,6 +3504,7 @@ function createErrorDiagnoser(context) {
3497
3504
  if (ensureNodeKeyExists(node, 'viewName')) {
3498
3505
  if (node.arguments?.length) {
3499
3506
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.arguments, function* (node) {
3507
+ node.paramRequired = false;
3500
3508
  yield* checkNode(node);
3501
3509
  });
3502
3510
  }
@@ -3724,23 +3732,23 @@ function createErrorDiagnoser(context) {
3724
3732
  function* checkOqlQueryComponent(node) {
3725
3733
  ensureNodeKeyExists(node, 'code');
3726
3734
  yield* checkSameSource(node);
3727
- if (node.typeAnnotation) { // 手动设置
3728
- const IMPOSSIBLE_TOPLEVEL_TYPES = ['Map'];
3729
- if (IMPOSSIBLE_TOPLEVEL_TYPES.includes(node.typeAnnotation.typeName || "")) {
3730
- error(node, `SQL查询:返回类型不支持设置为 ${node.typeAnnotation.headTitle}。`);
3731
- }
3732
- }
3733
- else { // 自动推导
3734
- const typeAnnotation = env.getType(node);
3735
- if (typeAnnotation) {
3736
- if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
3737
- const { typeArguments = [] } = typeAnnotation;
3738
- if (typeArguments.length && typeArguments[0].isComplexType()) {
3739
- error(node, `SQL查询:返回类型不支持单个复杂类型 ${typeArguments[0].headTitle}。`);
3740
- }
3735
+ // 自动推导情况
3736
+ const typeAnnotation = env.getType(node);
3737
+ if (!node.typeAnnotation && typeAnnotation) {
3738
+ if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
3739
+ const { typeArguments = [] } = typeAnnotation;
3740
+ if (typeArguments.length && typeArguments[0].isComplexType()) {
3741
+ error(node, `SQL查询:返回类型不支持单个复杂类型 ${typeArguments[0].headTitle}。`);
3741
3742
  }
3742
3743
  }
3743
3744
  }
3745
+ // 尝试加载错误
3746
+ const errs = node.errorsFromTSServer;
3747
+ if (errs) {
3748
+ errs.forEach((e) => {
3749
+ env.addDiagnosticsFor(e.message, node);
3750
+ });
3751
+ }
3744
3752
  return env.getType(node);
3745
3753
  }
3746
3754
  /**
@@ -3844,6 +3852,10 @@ function createErrorDiagnoser(context) {
3844
3852
  * @param node
3845
3853
  */
3846
3854
  function* checkValidationRule(node) {
3855
+ /**
3856
+ * HACK: 从 toEmbeddedTS 中提取出补全参数 keyword 的逻辑。ValidationRule 的 Argument 的脏数据需要通过这个方法来修复。
3857
+ */
3858
+ node.fixArgumentsKeyword();
3847
3859
  // const ref: any = env.resolveRef(node);
3848
3860
  if (node.arguments?.length) {
3849
3861
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.arguments, function* (node) {
@@ -3880,7 +3892,7 @@ function createErrorDiagnoser(context) {
3880
3892
  }
3881
3893
  // 元数据
3882
3894
  if (!metadataTypeEnable && node.typeNamespace?.endsWith('.metadataTypes')) {
3883
- error(node, '未启用元数据功能,请在“偏好设置”中启用元数据。');
3895
+ error(node, '未启用元数据功能,请在"偏好设置"中启用元数据。');
3884
3896
  }
3885
3897
  if (node.typeArguments?.length) {
3886
3898
  // 有同名的
@@ -3934,6 +3946,8 @@ function createErrorDiagnoser(context) {
3934
3946
  function* checkVoidCallUsedAsStatement(node) {
3935
3947
  const parentNode = node.parentNode;
3936
3948
  const usedAsStatement = parentNode && (nasl_concepts_1.asserts.isLogic(parentNode) ||
3949
+ // temp fix: should have been covered in `isLogic` by defining OverriddenLogic as a subclass of Logic in old ast
3950
+ nasl_concepts_1.asserts.isOverriddenLogic(parentNode) ||
3937
3951
  nasl_concepts_1.asserts.isSubLogic(parentNode) ||
3938
3952
  nasl_concepts_1.asserts.isForEachStatement(parentNode) ||
3939
3953
  nasl_concepts_1.asserts.isWhileStatement(parentNode) ||
@@ -4196,8 +4210,8 @@ function createErrorDiagnoser(context) {
4196
4210
  * @returns 清理函数
4197
4211
  */
4198
4212
  function handleFileNode(node) {
4199
- // TODO: checkNodeIsFileModuleInIde 也慢,后续可以优化
4200
- const isFileModule = fileNodes.length ? (0, service_1.checkNodeIsFileModuleInIde)(node) : true;
4213
+ // TODO: checkNodeIsFileModuleInIdeWithCache 也慢,后续可以优化
4214
+ const isFileModule = fileNodes.length ? (0, file_node_cache_1.checkNodeIsFileModuleInIdeWithCache)(node) : true;
4201
4215
  if (isFileModule) {
4202
4216
  fileNodes.push(node);
4203
4217
  let diagnostics = diagnosticMap.get(node);
@@ -4273,9 +4287,9 @@ function createErrorDiagnoser(context) {
4273
4287
  * @returns
4274
4288
  */
4275
4289
  function getDiagnostics(node) {
4276
- if (node) {
4277
- return diagnosticMap.get(node);
4278
- }
4290
+ return diagnosticMap.get(node);
4291
+ }
4292
+ function getAllDiagnostics() {
4279
4293
  return diagnosticMap;
4280
4294
  }
4281
4295
  return {
@@ -4285,6 +4299,7 @@ function createErrorDiagnoser(context) {
4285
4299
  checkNode,
4286
4300
  clearDiagnostics,
4287
4301
  getDiagnostics,
4302
+ getAllDiagnostics,
4288
4303
  error,
4289
4304
  };
4290
4305
  }
@@ -4296,7 +4311,7 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
4296
4311
  filePath = fileNode.concept !== 'App' ? fileNode.getEmbeddedFilePath() : undefined;
4297
4312
  }
4298
4313
  catch (err) {
4299
- console.log(err);
4314
+ nasl_utils_1.isDebugMode && console.error(err);
4300
4315
  }
4301
4316
  const semanticDiagnostics = [];
4302
4317
  const suggestionDiagnostics = [];