@lcap/nasl-language-server-core 4.1.0-beta.9 → 4.1.0-creator.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 (179) hide show
  1. package/out/checker.d.ts +1 -1
  2. package/out/checker.d.ts.map +1 -1
  3. package/out/checker.js +92 -123
  4. package/out/checker.js.map +1 -1
  5. package/out/index.d.ts +4 -1
  6. package/out/index.d.ts.map +1 -1
  7. package/out/index.js +7 -2
  8. package/out/index.js.map +1 -1
  9. package/out/reference-manager/build-q-name-def.d.ts +10 -0
  10. package/out/reference-manager/build-q-name-def.d.ts.map +1 -0
  11. package/out/reference-manager/build-q-name-def.js +66 -0
  12. package/out/reference-manager/build-q-name-def.js.map +1 -0
  13. package/out/reference-manager/builtin-q-name.d.ts +2 -3
  14. package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
  15. package/out/reference-manager/builtin-q-name.js +13 -17
  16. package/out/reference-manager/builtin-q-name.js.map +1 -1
  17. package/out/reference-manager/collect-q-name.d.ts +2 -3
  18. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  19. package/out/reference-manager/collect-q-name.js +26 -26
  20. package/out/reference-manager/collect-q-name.js.map +1 -1
  21. package/out/reference-manager/get-q-name.d.ts.map +1 -1
  22. package/out/reference-manager/get-q-name.js +37 -18
  23. package/out/reference-manager/get-q-name.js.map +1 -1
  24. package/out/reference-manager/helper.d.ts +21 -0
  25. package/out/reference-manager/helper.d.ts.map +1 -0
  26. package/out/reference-manager/helper.js +102 -0
  27. package/out/reference-manager/helper.js.map +1 -0
  28. package/out/reference-manager/reference-manager.d.ts +103 -138
  29. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  30. package/out/reference-manager/reference-manager.js +442 -523
  31. package/out/reference-manager/reference-manager.js.map +1 -1
  32. package/out/reference-manager/remove-q-name.d.ts +1 -2
  33. package/out/reference-manager/remove-q-name.d.ts.map +1 -1
  34. package/out/reference-manager/remove-q-name.js +21 -23
  35. package/out/reference-manager/remove-q-name.js.map +1 -1
  36. package/out/reference-manager/rename-q-name.d.ts +2 -1
  37. package/out/reference-manager/rename-q-name.d.ts.map +1 -1
  38. package/out/reference-manager/rename-q-name.js +19 -8
  39. package/out/reference-manager/rename-q-name.js.map +1 -1
  40. package/out/reference-manager/special-string-ref.d.ts +7 -0
  41. package/out/reference-manager/special-string-ref.d.ts.map +1 -0
  42. package/out/reference-manager/special-string-ref.js +34 -0
  43. package/out/reference-manager/special-string-ref.js.map +1 -0
  44. package/out/reference-manager/symbol-type.d.ts +10 -6
  45. package/out/reference-manager/symbol-type.d.ts.map +1 -1
  46. package/out/reference-manager/symbol-type.js +29 -8
  47. package/out/reference-manager/symbol-type.js.map +1 -1
  48. package/out/reference-manager/update-nasl-fragment.d.ts +1 -5
  49. package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
  50. package/out/reference-manager/update-nasl-fragment.js +23 -69
  51. package/out/reference-manager/update-nasl-fragment.js.map +1 -1
  52. package/out/reference-manager/view-elem-logic.d.ts +44 -0
  53. package/out/reference-manager/view-elem-logic.d.ts.map +1 -0
  54. package/out/reference-manager/view-elem-logic.js +164 -0
  55. package/out/reference-manager/view-elem-logic.js.map +1 -0
  56. package/out/services/bindable-logic-service.d.ts +64 -0
  57. package/out/services/bindable-logic-service.d.ts.map +1 -0
  58. package/out/services/bindable-logic-service.js +186 -0
  59. package/out/services/bindable-logic-service.js.map +1 -0
  60. package/out/services/client.d.ts +10 -0
  61. package/out/services/client.d.ts.map +1 -0
  62. package/out/services/client.js +21 -0
  63. package/out/services/client.js.map +1 -0
  64. package/out/services/contextual-variables-service.d.ts +14 -0
  65. package/out/services/contextual-variables-service.d.ts.map +1 -0
  66. package/out/services/contextual-variables-service.js +17 -0
  67. package/out/services/contextual-variables-service.js.map +1 -0
  68. package/out/services/event-handler-type-service.d.ts +16 -0
  69. package/out/services/event-handler-type-service.d.ts.map +1 -0
  70. package/out/services/event-handler-type-service.js +57 -0
  71. package/out/services/event-handler-type-service.js.map +1 -0
  72. package/out/services/index.d.ts +2 -0
  73. package/out/services/index.d.ts.map +1 -0
  74. package/out/services/index.js +18 -0
  75. package/out/services/index.js.map +1 -0
  76. package/out/services/types/type.d.ts +13 -0
  77. package/out/services/types/type.d.ts.map +1 -0
  78. package/out/services/types/type.js +3 -0
  79. package/out/services/types/type.js.map +1 -0
  80. package/out/symbol/traverse/concepts/frontend/bind-event.d.ts.map +1 -1
  81. package/out/symbol/traverse/concepts/frontend/bind-event.js +3 -0
  82. package/out/symbol/traverse/concepts/frontend/bind-event.js.map +1 -1
  83. package/out/symbol/traverse/concepts/index.d.ts +1 -1
  84. package/out/symbol/traverse/concepts/index.d.ts.map +1 -1
  85. package/out/symbol/traverse/concepts/logic/expression/expression.d.ts.map +1 -1
  86. package/out/symbol/traverse/concepts/logic/expression/expression.js +2 -1
  87. package/out/symbol/traverse/concepts/logic/expression/expression.js.map +1 -1
  88. package/out/typer/collectGlobalDefs.js +1 -1
  89. package/out/typer/collectGlobalDefs.js.map +1 -1
  90. package/out/typer/component-def-manager/component-def-manager.d.ts +1 -0
  91. package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
  92. package/out/typer/component-def-manager/component-def-manager.js +3 -0
  93. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  94. package/out/typer/component-def-manager/utils.js +1 -1
  95. package/out/typer/component-def-manager/utils.js.map +1 -1
  96. package/out/typer/dispatch-all.d.ts +10 -3
  97. package/out/typer/dispatch-all.d.ts.map +1 -1
  98. package/out/typer/dispatch-all.js +45 -8
  99. package/out/typer/dispatch-all.js.map +1 -1
  100. package/out/typer/dispatch-call.d.ts +14 -0
  101. package/out/typer/dispatch-call.d.ts.map +1 -0
  102. package/out/typer/dispatch-call.js +637 -0
  103. package/out/typer/dispatch-call.js.map +1 -0
  104. package/out/typer/dispatch-def.d.ts +12 -6
  105. package/out/typer/dispatch-def.d.ts.map +1 -1
  106. package/out/typer/dispatch-def.js +112 -107
  107. package/out/typer/dispatch-def.js.map +1 -1
  108. package/out/typer/dispatch-expr.d.ts +3 -15
  109. package/out/typer/dispatch-expr.d.ts.map +1 -1
  110. package/out/typer/dispatch-expr.js +92 -678
  111. package/out/typer/dispatch-expr.js.map +1 -1
  112. package/out/typer/dispatch-process.d.ts.map +1 -1
  113. package/out/typer/dispatch-process.js +49 -16
  114. package/out/typer/dispatch-process.js.map +1 -1
  115. package/out/typer/dispatch-stmt.d.ts.map +1 -1
  116. package/out/typer/dispatch-stmt.js +39 -38
  117. package/out/typer/dispatch-stmt.js.map +1 -1
  118. package/out/typer/dispatch-view.d.ts.map +1 -1
  119. package/out/typer/dispatch-view.js +193 -100
  120. package/out/typer/dispatch-view.js.map +1 -1
  121. package/out/typer/get-oql-files.d.ts +13 -0
  122. package/out/typer/get-oql-files.d.ts.map +1 -0
  123. package/out/typer/get-oql-files.js +136 -0
  124. package/out/typer/get-oql-files.js.map +1 -0
  125. package/out/typer/helper.d.ts +2 -7
  126. package/out/typer/helper.d.ts.map +1 -1
  127. package/out/typer/helper.js +5 -25
  128. package/out/typer/helper.js.map +1 -1
  129. package/out/typer/incremental-update.d.ts +1 -13
  130. package/out/typer/incremental-update.d.ts.map +1 -1
  131. package/out/typer/incremental-update.js +192 -203
  132. package/out/typer/incremental-update.js.map +1 -1
  133. package/out/typer/index.d.ts +7 -5
  134. package/out/typer/index.d.ts.map +1 -1
  135. package/out/typer/index.js +11 -13
  136. package/out/typer/index.js.map +1 -1
  137. package/out/typer/solver.d.ts.map +1 -1
  138. package/out/typer/solver.js +4 -0
  139. package/out/typer/solver.js.map +1 -1
  140. package/out/typer/subster.d.ts +0 -1
  141. package/out/typer/subster.d.ts.map +1 -1
  142. package/out/typer/subster.js +19 -34
  143. package/out/typer/subster.js.map +1 -1
  144. package/out/typer/topo-sort.d.ts +4 -4
  145. package/out/typer/topo-sort.d.ts.map +1 -1
  146. package/out/typer/topo-sort.js +7 -3
  147. package/out/typer/topo-sort.js.map +1 -1
  148. package/out/typer/type-manager.d.ts +3 -3
  149. package/out/typer/type-manager.d.ts.map +1 -1
  150. package/out/typer/type-manager.js +40 -17
  151. package/out/typer/type-manager.js.map +1 -1
  152. package/out/typer/type-predicate.d.ts +6 -1
  153. package/out/typer/type-predicate.d.ts.map +1 -1
  154. package/out/typer/type-predicate.js +43 -11
  155. package/out/typer/type-predicate.js.map +1 -1
  156. package/out/typer/typer.d.ts +69 -12
  157. package/out/typer/typer.d.ts.map +1 -1
  158. package/out/typer/typer.js +195 -34
  159. package/out/typer/typer.js.map +1 -1
  160. package/out/typer/unifier.d.ts +1 -2
  161. package/out/typer/unifier.d.ts.map +1 -1
  162. package/out/typer/unifier.js +65 -80
  163. package/out/typer/unifier.js.map +1 -1
  164. package/out/utils/misc.d.ts +11 -0
  165. package/out/utils/misc.d.ts.map +1 -0
  166. package/out/utils/misc.js +29 -0
  167. package/out/utils/misc.js.map +1 -0
  168. package/out/utils/string.d.ts.map +1 -1
  169. package/out/utils/string.js +1 -0
  170. package/out/utils/string.js.map +1 -1
  171. package/out/utils/traverse-util.d.ts +5 -0
  172. package/out/utils/traverse-util.d.ts.map +1 -0
  173. package/out/utils/traverse-util.js +69 -0
  174. package/out/utils/traverse-util.js.map +1 -0
  175. package/package.json +6 -6
  176. package/out/typer/nasl-predicate.d.ts +0 -10
  177. package/out/typer/nasl-predicate.d.ts.map +0 -1
  178. package/out/typer/nasl-predicate.js +0 -22
  179. package/out/typer/nasl-predicate.js.map +0 -1
package/out/checker.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface DiagnosticRecord {
54
54
  semanticDiagnostics: Array<Diagnostic>;
55
55
  suggestionDiagnostics: Array<Diagnostic>;
56
56
  }
57
- export declare const transformDiagnosticsToRecords: (fileNode: SyntaxNode, diagnostics: NodeDiagnosticsMap) => Array<DiagnosticRecord>;
57
+ export declare const transformDiagnosticsToRecords: (fileNode: SyntaxNode, diagnostics: NodeDiagnosticsMap, deduplication?: boolean) => Array<DiagnosticRecord>;
58
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;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;AAiQ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B,CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
package/out/checker.js CHANGED
@@ -9,7 +9,8 @@ const nasl_utils_1 = require("@lcap/nasl-utils");
9
9
  const sem_diag_1 = require("./typer/sem-diag");
10
10
  const type_predicate_1 = require("./typer/type-predicate");
11
11
  const type_manager_1 = require("./typer/type-manager");
12
- const nasl_predicate_1 = require("./typer/nasl-predicate");
12
+ const service_2 = require("@lcap/nasl-concepts/service");
13
+ const lodash_1 = require("lodash");
13
14
  const helper_1 = require("./typer/helper");
14
15
  var Severity;
15
16
  (function (Severity) {
@@ -79,7 +80,8 @@ function getExpressionNodeName(concept) {
79
80
  CallInterface: '接口',
80
81
  CallAuthInterface: '鉴权接口',
81
82
  CallConnector: '连接器',
82
- CallMicroserviceInterface: '',
83
+ CallMicroserviceInterface: '微服务接口',
84
+ CallGatewayInterface: '网关接口',
83
85
  CallEvent: '事件',
84
86
  };
85
87
  return expressionNodeName[concept];
@@ -1126,6 +1128,7 @@ function createErrorDiagnoser(context) {
1126
1128
  * @param node
1127
1129
  */
1128
1130
  function* checkConnector(node) {
1131
+ env.enterScope(node);
1129
1132
  yield* checkModule(node);
1130
1133
  if (node.triggerLaunchers?.length) {
1131
1134
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.triggerLaunchers, function* (node) {
@@ -1152,6 +1155,7 @@ function createErrorDiagnoser(context) {
1152
1155
  yield* checkNode(node);
1153
1156
  });
1154
1157
  }
1158
+ env.exitScope();
1155
1159
  }
1156
1160
  /**
1157
1161
  * 检查 连接器触发器
@@ -1266,11 +1270,14 @@ function createErrorDiagnoser(context) {
1266
1270
  * @param node
1267
1271
  */
1268
1272
  function* checkStructure(node) {
1273
+ const pConn = node.getAncestor('Connector');
1274
+ pConn && env.enterScope(pConn);
1269
1275
  if (node.properties?.length) {
1270
1276
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (node) {
1271
1277
  yield* checkNode(node);
1272
1278
  });
1273
1279
  }
1280
+ pConn && env.exitScope();
1274
1281
  }
1275
1282
  /**
1276
1283
  * 检查 数据结构属性
@@ -1745,11 +1752,9 @@ function createErrorDiagnoser(context) {
1745
1752
  * @param node
1746
1753
  */
1747
1754
  function* checkInterface(node) {
1748
- const unbindVariables = env.temporarilyBindVariables([
1749
- ...(node.params || []),
1750
- ...(node.returns || []),
1751
- ...(node.protocolParams || [])
1752
- ]);
1755
+ const pConn = node.getAncestor('Connector');
1756
+ pConn && env.enterScope(pConn);
1757
+ env.enterScope(node);
1753
1758
  if (node.params?.length) {
1754
1759
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
1755
1760
  yield* checkNode(node);
@@ -1767,18 +1772,17 @@ function createErrorDiagnoser(context) {
1767
1772
  }
1768
1773
  yield* checkNode(node.validation);
1769
1774
  yield* checkTimeout(node);
1770
- unbindVariables();
1775
+ env.exitScope();
1776
+ pConn && env.exitScope();
1771
1777
  }
1772
1778
  /**
1773
1779
  * 检查 鉴权接口
1774
1780
  * @param node
1775
1781
  */
1776
1782
  function* checkAuthInterface(node) {
1777
- const unbindVariables = env.temporarilyBindVariables([
1778
- ...(node.params || []),
1779
- ...(node.returns || []),
1780
- ...(node.protocolParams || [])
1781
- ]);
1783
+ const pConn = node.getAncestor('Connector');
1784
+ pConn && env.enterScope(pConn);
1785
+ env.enterScope(node);
1782
1786
  if (node.params?.length) {
1783
1787
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
1784
1788
  yield* checkNode(node);
@@ -1796,7 +1800,8 @@ function createErrorDiagnoser(context) {
1796
1800
  }
1797
1801
  yield* checkNode(node.validation);
1798
1802
  yield* checkTimeout(node);
1799
- unbindVariables();
1803
+ env.exitScope();
1804
+ pConn && env.exitScope();
1800
1805
  }
1801
1806
  /**
1802
1807
  * 检查 接口参数
@@ -1857,7 +1862,7 @@ function createErrorDiagnoser(context) {
1857
1862
  * @param node
1858
1863
  */
1859
1864
  function* checkFrontend(node) {
1860
- const unbindVariables = env.temporarilyBindVariables(node.variables);
1865
+ env.enterScope(node);
1861
1866
  if (node.variables?.length) {
1862
1867
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
1863
1868
  yield* checkNode(node);
@@ -1873,18 +1878,14 @@ function createErrorDiagnoser(context) {
1873
1878
  yield* checkNode(node);
1874
1879
  });
1875
1880
  }
1876
- unbindVariables();
1881
+ env.exitScope();
1877
1882
  }
1878
1883
  /**
1879
1884
  * 检查 页面
1880
1885
  * @param node
1881
1886
  */
1882
1887
  function* checkView(node) {
1883
- const unbindVariables = env.temporarilyBindVariables([
1884
- ...(node.params || []),
1885
- ...(node.variables || []),
1886
- ...(node.logics || []),
1887
- ]);
1888
+ env.enterScope(node);
1888
1889
  checkVariableAndReturnTypeAnnotations(node.variables, [], false);
1889
1890
  const module = node.getAncestor('Module');
1890
1891
  if (!(module?.parentKey === 'dependencies')) {
@@ -1927,18 +1928,14 @@ function createErrorDiagnoser(context) {
1927
1928
  yield* checkNode(node);
1928
1929
  });
1929
1930
  }
1930
- unbindVariables();
1931
+ env.exitScope();
1931
1932
  }
1932
1933
  /**
1933
1934
  * 检查 业务组件
1934
1935
  * @param node
1935
1936
  */
1936
1937
  function* checkBusinessComponent(node) {
1937
- const unbindVariables = env.temporarilyBindVariables([
1938
- ...(node.params || []),
1939
- ...(node.variables || []),
1940
- ...(node.logics || []),
1941
- ]);
1938
+ env.enterScope(node);
1942
1939
  // 组件元素
1943
1940
  if (node.elements?.length) {
1944
1941
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.elements, function* (node) {
@@ -1963,7 +1960,7 @@ function createErrorDiagnoser(context) {
1963
1960
  yield* checkNode(node);
1964
1961
  });
1965
1962
  }
1966
- unbindVariables();
1963
+ env.exitScope();
1967
1964
  }
1968
1965
  /**
1969
1966
  * 检查 页面元素
@@ -1975,18 +1972,14 @@ function createErrorDiagnoser(context) {
1975
1972
  return;
1976
1973
  }
1977
1974
  const shouldProvideCurrentCtx = !!(node.slotScope);
1978
- let unbindVariables;
1975
+ let scopeEntered = false;
1979
1976
  if (shouldProvideCurrentCtx) {
1980
1977
  const name = curVarCounter > 0 ? node.slotScope + curVarCounter : node.slotScope;
1981
- const variable = new nasl_concepts_1.Variable({
1982
- name,
1983
- });
1978
+ const variable = new nasl_concepts_1.Variable({ name });
1984
1979
  curVarCounter++;
1985
- unbindVariables = env.temporarilyBindVariables([
1986
- variable,
1987
- ], () => {
1988
- curVarCounter--;
1989
- });
1980
+ // @ts-expect-error ViewElement 引入的 current 目前没有加入 refMgr,VE 也没当做 ScopeNode
1981
+ env.enterScope(node, [variable]);
1982
+ scopeEntered = true;
1990
1983
  }
1991
1984
  if (node.bindAttrs?.length) {
1992
1985
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.bindAttrs, function* (node) {
@@ -2031,7 +2024,10 @@ function createErrorDiagnoser(context) {
2031
2024
  if (!dsFilled && !hasSubComponents) {
2032
2025
  error(errNode, '数据源不能为空');
2033
2026
  }
2034
- unbindVariables?.();
2027
+ if (scopeEntered) {
2028
+ env.exitScope();
2029
+ curVarCounter--;
2030
+ }
2035
2031
  }
2036
2032
  /**
2037
2033
  * 检查 元素绑定属性
@@ -2189,10 +2185,7 @@ function createErrorDiagnoser(context) {
2189
2185
  if (node.includeTypeArgs) {
2190
2186
  error(node, '流程暂不支持泛型参数');
2191
2187
  }
2192
- const unbindVariables = env.temporarilyBindVariables([
2193
- ...(node?.params || []),
2194
- ...(node?.returns || []),
2195
- ]);
2188
+ // env.enterScope(node); 尚不支持流程 1.0
2196
2189
  if (node.params?.length) {
2197
2190
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
2198
2191
  yield* checkNode(node);
@@ -2218,17 +2211,14 @@ function createErrorDiagnoser(context) {
2218
2211
  yield* checkNode(node);
2219
2212
  });
2220
2213
  }
2221
- unbindVariables();
2214
+ // env.exitScope();
2222
2215
  }
2223
2216
  /**
2224
2217
  * 检查 流程元素
2225
2218
  * @param node
2226
2219
  */
2227
2220
  function* checkProcessElement(node) {
2228
- const unbindVariables = env.temporarilyBindVariables([
2229
- ...(node?.variables || []),
2230
- ...(node?.returns || []),
2231
- ]);
2221
+ // env.enterScope(node); 尚不支持流程1.0
2232
2222
  if (node.returns?.length) {
2233
2223
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.returns, function* (node) {
2234
2224
  yield* checkNode(node);
@@ -2273,7 +2263,7 @@ function createErrorDiagnoser(context) {
2273
2263
  yield* checkNode(node);
2274
2264
  });
2275
2265
  }
2276
- unbindVariables();
2266
+ // env.exitScope();
2277
2267
  }
2278
2268
  /**
2279
2269
  * 检查 常量
@@ -2288,6 +2278,7 @@ function createErrorDiagnoser(context) {
2288
2278
  * @param node
2289
2279
  */
2290
2280
  function* checkProcessV2(node) {
2281
+ env.enterScope(node);
2291
2282
  yield* checkNode(node.bind);
2292
2283
  if (node.processDefinitions?.length) {
2293
2284
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.processDefinitions, function* (node) {
@@ -2304,6 +2295,7 @@ function createErrorDiagnoser(context) {
2304
2295
  if (node.includeTypeArgs) {
2305
2296
  error(node, '流程暂不支持泛型参数');
2306
2297
  }
2298
+ env.exitScope();
2307
2299
  }
2308
2300
  /**
2309
2301
  * 检查 绑定实体或数据结构
@@ -2317,14 +2309,7 @@ function createErrorDiagnoser(context) {
2317
2309
  * @param node
2318
2310
  */
2319
2311
  function* checkProcessDefinitionV2(node) {
2320
- const unbindVariables = env.temporarilyBindVariables([
2321
- ...(node.variables || []),
2322
- ...['custom', 'processSystem'].map((name) => {
2323
- return new nasl_concepts_1.Variable({
2324
- name,
2325
- });
2326
- }),
2327
- ]);
2312
+ env.enterScope(node);
2328
2313
  if (node.variables?.length) {
2329
2314
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
2330
2315
  yield* checkNode(node);
@@ -2340,20 +2325,14 @@ function createErrorDiagnoser(context) {
2340
2325
  yield* checkNode(node);
2341
2326
  });
2342
2327
  }
2343
- unbindVariables();
2328
+ env.exitScope();
2344
2329
  }
2345
2330
  /**
2346
2331
  * 检查 流程元素
2347
2332
  * @param node
2348
2333
  */
2349
2334
  function* checkProcessElementV2(node) {
2350
- const unbindVariables = env.temporarilyBindVariables([
2351
- ...['custom', 'processSystem'].map((name) => {
2352
- return new nasl_concepts_1.Variable({
2353
- name,
2354
- });
2355
- }),
2356
- ]);
2335
+ env.enterScope(node);
2357
2336
  yield* checkNode(node.logic);
2358
2337
  yield* checkNode(node.flowCondition);
2359
2338
  if (node.bindEvents?.length) {
@@ -2408,7 +2387,7 @@ function createErrorDiagnoser(context) {
2408
2387
  else if (!service_1.ProcessesV2.isFromStartNode(node)) {
2409
2388
  error(node, '节点未关联到流程图');
2410
2389
  }
2411
- unbindVariables();
2390
+ env.exitScope();
2412
2391
  }
2413
2392
  /**
2414
2393
  * 检查 无人时,自动转派审批策略
@@ -2490,16 +2469,8 @@ function createErrorDiagnoser(context) {
2490
2469
  * @param node
2491
2470
  */
2492
2471
  function* checkLogic(node) {
2493
- const unbindVariables = env.temporarilyBindVariables([
2494
- ...(node.params || []),
2495
- ...(node.returns || []),
2496
- ...(node.variables || []),
2497
- ...(node.virtualParams || [])
2498
- ]);
2499
- // 仅检查用户写的逻辑
2500
- // if (node.nodePath?.startsWith('app.logics')) {
2472
+ env.enterScope(node);
2501
2473
  checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
2502
- // }
2503
2474
  const module = node.getAncestor('Module');
2504
2475
  if (!(module?.parentKey === 'dependencies')) {
2505
2476
  if (node.params?.length) {
@@ -2590,34 +2561,38 @@ function createErrorDiagnoser(context) {
2590
2561
  if (!likeComponent) {
2591
2562
  yield* checkTrigger(node);
2592
2563
  }
2593
- unbindVariables();
2564
+ env.exitScope();
2594
2565
  }
2595
2566
  /**
2596
2567
  * 检查 鉴权逻辑
2597
2568
  * @param node
2598
2569
  */
2599
2570
  function* checkAuthLogic(node) {
2571
+ const pConn = node.getAncestor('Connector');
2572
+ pConn && env.enterScope(pConn);
2600
2573
  inAuthLogic = true;
2574
+ // checkLogic 会 enter scope
2601
2575
  yield* checkLogic(node);
2602
2576
  inAuthLogic = false;
2577
+ pConn && env.exitScope();
2603
2578
  }
2604
2579
  /**
2605
2580
  * 检查 调用接口的鉴权逻辑
2606
2581
  * @param node
2607
2582
  */
2608
2583
  function* checkAuthLogicForCallInterface(node) {
2609
- const unbindVariables = env.temporarilyBindVariables([
2610
- ...(node.authParams || []),
2611
- ]);
2584
+ // authLogic 会打开 Connector 的局部-全局变量
2612
2585
  yield* checkAuthLogic(node);
2613
- unbindVariables();
2614
2586
  }
2615
2587
  /**
2616
2588
  * 检查 调用接口的鉴权逻辑
2617
2589
  * @param node
2618
2590
  */
2619
2591
  function* checkConnectorLogic(node) {
2592
+ const pConn = node.getAncestor('Connector');
2593
+ pConn && env.enterScope(pConn);
2620
2594
  yield* checkLogic(node);
2595
+ pConn && env.exitScope();
2621
2596
  }
2622
2597
  /**
2623
2598
  * 检查 业务组件逻辑
@@ -2631,12 +2606,7 @@ function createErrorDiagnoser(context) {
2631
2606
  * @param node
2632
2607
  */
2633
2608
  function* checkOverriddenLogic(node) {
2634
- const unbindVariables = env.temporarilyBindVariables([
2635
- ...(node.params || []),
2636
- ...(node.returns || []),
2637
- ...(node.variables || []),
2638
- ...(node.virtualParams || [])
2639
- ]);
2609
+ env.enterScope(node);
2640
2610
  const module = node.getAncestor('Module');
2641
2611
  if (!(module?.parentKey === 'dependencies')) {
2642
2612
  if (node.params?.length) {
@@ -2662,7 +2632,7 @@ function createErrorDiagnoser(context) {
2662
2632
  });
2663
2633
  }
2664
2634
  yield* checkPlayground(node.playground);
2665
- unbindVariables();
2635
+ env.exitScope();
2666
2636
  yield* checkTrigger(node);
2667
2637
  }
2668
2638
  /**
@@ -2675,14 +2645,8 @@ function createErrorDiagnoser(context) {
2675
2645
  * @param node
2676
2646
  */
2677
2647
  function* checkSubLogic(node) {
2678
- const unbindVariables = env.temporarilyBindVariables([
2679
- ...(node.params || []),
2680
- ...(node.returns || []),
2681
- ...(node.variables || []),
2682
- ]);
2683
- // if (nd.nodePath?.startsWith('app.logics')) {
2648
+ env.enterScope(node);
2684
2649
  checkVariableAndReturnTypeAnnotations(node.variables, node.returns);
2685
- // }
2686
2650
  const module = node.getAncestor('Module');
2687
2651
  if (!(module?.parentKey === 'dependencies')) {
2688
2652
  if (node.params?.length) {
@@ -2708,7 +2672,7 @@ function createErrorDiagnoser(context) {
2708
2672
  });
2709
2673
  }
2710
2674
  yield* checkPlayground(node.playground);
2711
- unbindVariables();
2675
+ env.exitScope();
2712
2676
  return env.getType(node);
2713
2677
  }
2714
2678
  /**
@@ -2775,7 +2739,7 @@ function createErrorDiagnoser(context) {
2775
2739
  yield* checkVoidCallUsedAsStatement(node);
2776
2740
  const ref = env.resolveRef(node); // 前端
2777
2741
  // TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
2778
- // 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
2742
+ // 暂时不在 gQNameDefs 里,用 isBuiltInCall 简单判断了
2779
2743
  if (!ref && !isBuiltInCall(node)) {
2780
2744
  const depLibName = getExtensionLibName(node);
2781
2745
  if (depLibName) {
@@ -3243,10 +3207,7 @@ function createErrorDiagnoser(context) {
3243
3207
  * @param node
3244
3208
  */
3245
3209
  function* checkForEachStatement(node) {
3246
- const unbindVariables = env.temporarilyBindVariables([
3247
- node.item,
3248
- node.index,
3249
- ]);
3210
+ env.enterScope(node);
3250
3211
  if (ensureNodeKeyExists(node, 'each')) {
3251
3212
  yield* checkNode(node.each);
3252
3213
  }
@@ -3268,7 +3229,7 @@ function createErrorDiagnoser(context) {
3268
3229
  error(node, `ForEach:循环列表:参数类型不匹配!结束值自动推导失败。`);
3269
3230
  }
3270
3231
  }
3271
- unbindVariables();
3232
+ env.exitScope();
3272
3233
  }
3273
3234
  /**
3274
3235
  * 检查 循环分支
@@ -3720,7 +3681,7 @@ function createErrorDiagnoser(context) {
3720
3681
  const { entityAsName } = node;
3721
3682
  const entityNamespace = node.entityNamespace ?? node.getAncestor('CallQueryComponent')?.from?.entityNamespace;
3722
3683
  const entityQName = `${entityNamespace}.${entityAsName}`;
3723
- const ref = referenceManager.qNameDefs.get(entityQName);
3684
+ const ref = referenceManager.gQNameDefs.get(entityQName);
3724
3685
  if (!ref) {
3725
3686
  error(node, `找不到实体 ${entityAsName}。`);
3726
3687
  return;
@@ -3902,14 +3863,14 @@ function createErrorDiagnoser(context) {
3902
3863
  */
3903
3864
  function* checkFunction(node) {
3904
3865
  if (ensureNodeKeyExists(node, 'returnExpression')) {
3905
- const unbindVariables = env.temporarilyBindVariables(node.params);
3866
+ env.enterScope(node);
3906
3867
  if (node.params?.length) {
3907
3868
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
3908
3869
  yield* checkNode(node);
3909
3870
  });
3910
3871
  }
3911
3872
  yield* checkNode(node.returnExpression);
3912
- unbindVariables();
3873
+ env.exitScope();
3913
3874
  }
3914
3875
  }
3915
3876
  /**
@@ -3917,7 +3878,7 @@ function createErrorDiagnoser(context) {
3917
3878
  * @param node
3918
3879
  */
3919
3880
  function* checkAnonymousFunction(node) {
3920
- const unbindVariables = env.temporarilyBindVariables(node.params);
3881
+ env.enterScope(node);
3921
3882
  if (node.params?.length) {
3922
3883
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
3923
3884
  yield* checkNode(node);
@@ -3926,7 +3887,7 @@ function createErrorDiagnoser(context) {
3926
3887
  if (ensureNodeKeyExists(node, 'body')) {
3927
3888
  yield* checkNode(node.body);
3928
3889
  }
3929
- unbindVariables();
3890
+ env.exitScope();
3930
3891
  }
3931
3892
  /**
3932
3893
  * 检查 验证规则
@@ -4044,7 +4005,7 @@ function createErrorDiagnoser(context) {
4044
4005
  function* dispatchNode(node) {
4045
4006
  try {
4046
4007
  // 调用表达式
4047
- if ((0, nasl_predicate_1.isNaslCallExpr)(node)) {
4008
+ if ((0, service_2.isNaslCallExpr)(node)) {
4048
4009
  return yield* checkCallExpression(node);
4049
4010
  }
4050
4011
  const { concept } = node;
@@ -4407,8 +4368,10 @@ function createErrorDiagnoser(context) {
4407
4368
  };
4408
4369
  }
4409
4370
  exports.createErrorDiagnoser = createErrorDiagnoser;
4410
- const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
4411
- const records = [];
4371
+ function deduplicateDiagnostics(diagnostics) {
4372
+ return (0, lodash_1.uniqWith)(diagnostics, (a, b) => a.node === b.node && a.message === b.message);
4373
+ }
4374
+ const transformDiagnosticsToRecords = (fileNode, diagnostics, deduplication = true) => {
4412
4375
  let filePath;
4413
4376
  try {
4414
4377
  filePath = fileNode.concept !== 'App' ? fileNode.getEmbeddedFilePath() : undefined;
@@ -4416,10 +4379,8 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
4416
4379
  catch (err) {
4417
4380
  nasl_utils_1.isDebugMode && console.error(err);
4418
4381
  }
4419
- const semanticDiagnostics = [];
4420
- const suggestionDiagnostics = [];
4421
- const syntaxDiagnostics = [];
4422
- //
4382
+ let semanticDiagnostics = [];
4383
+ let suggestionDiagnostics = [];
4423
4384
  diagnostics.forEach((err, node) => {
4424
4385
  if (err.length) {
4425
4386
  err.forEach((item) => {
@@ -4432,17 +4393,25 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
4432
4393
  }
4433
4394
  });
4434
4395
  if (filePath) {
4435
- records.push({
4436
- filePath,
4437
- id: fileNode.id,
4438
- node: fileNode,
4439
- semanticDiagnostics,
4440
- suggestionDiagnostics,
4441
- syntaxDiagnostics,
4442
- message: '',
4443
- });
4444
- }
4445
- return records;
4396
+ if (deduplication) {
4397
+ if (semanticDiagnostics.length) {
4398
+ semanticDiagnostics = deduplicateDiagnostics(semanticDiagnostics);
4399
+ }
4400
+ if (suggestionDiagnostics.length) {
4401
+ suggestionDiagnostics = deduplicateDiagnostics(suggestionDiagnostics);
4402
+ }
4403
+ }
4404
+ return [{
4405
+ filePath,
4406
+ id: fileNode.id,
4407
+ node: fileNode,
4408
+ semanticDiagnostics,
4409
+ suggestionDiagnostics,
4410
+ syntaxDiagnostics: [],
4411
+ message: '',
4412
+ }];
4413
+ }
4414
+ return [];
4446
4415
  };
4447
4416
  exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
4448
4417
  // @ts-expect-error