@lcap/nasl-language-server-core 4.1.0-beta.14 → 4.1.0-beta.16

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 (112) hide show
  1. package/out/checker.d.ts.map +1 -1
  2. package/out/checker.js +62 -105
  3. package/out/checker.js.map +1 -1
  4. package/out/index.d.ts +2 -2
  5. package/out/index.d.ts.map +1 -1
  6. package/out/index.js +4 -3
  7. package/out/index.js.map +1 -1
  8. package/out/reference-manager/build-q-name-def.d.ts +2 -2
  9. package/out/reference-manager/build-q-name-def.d.ts.map +1 -1
  10. package/out/reference-manager/build-q-name-def.js +10 -10
  11. package/out/reference-manager/build-q-name-def.js.map +1 -1
  12. package/out/reference-manager/builtin-q-name.d.ts +2 -3
  13. package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
  14. package/out/reference-manager/builtin-q-name.js +7 -11
  15. package/out/reference-manager/builtin-q-name.js.map +1 -1
  16. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  17. package/out/reference-manager/collect-q-name.js +11 -11
  18. package/out/reference-manager/collect-q-name.js.map +1 -1
  19. package/out/reference-manager/helper.d.ts +1 -1
  20. package/out/reference-manager/helper.d.ts.map +1 -1
  21. package/out/reference-manager/helper.js +11 -1
  22. package/out/reference-manager/helper.js.map +1 -1
  23. package/out/reference-manager/reference-manager.d.ts +64 -7
  24. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  25. package/out/reference-manager/reference-manager.js +206 -63
  26. package/out/reference-manager/reference-manager.js.map +1 -1
  27. package/out/reference-manager/remove-q-name.js +8 -8
  28. package/out/reference-manager/remove-q-name.js.map +1 -1
  29. package/out/reference-manager/rename-q-name.d.ts.map +1 -1
  30. package/out/reference-manager/rename-q-name.js +6 -6
  31. package/out/reference-manager/rename-q-name.js.map +1 -1
  32. package/out/reference-manager/update-nasl-fragment.d.ts +0 -1
  33. package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
  34. package/out/reference-manager/update-nasl-fragment.js +2 -33
  35. package/out/reference-manager/update-nasl-fragment.js.map +1 -1
  36. package/out/reference-manager/view-elem-logic.d.ts +1 -1
  37. package/out/reference-manager/view-elem-logic.d.ts.map +1 -1
  38. package/out/reference-manager/view-elem-logic.js +2 -2
  39. package/out/reference-manager/view-elem-logic.js.map +1 -1
  40. package/out/typer/component-def-manager/component-def-manager.d.ts +1 -0
  41. package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
  42. package/out/typer/component-def-manager/component-def-manager.js +3 -0
  43. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  44. package/out/typer/dispatch-all.d.ts +10 -3
  45. package/out/typer/dispatch-all.d.ts.map +1 -1
  46. package/out/typer/dispatch-all.js +44 -7
  47. package/out/typer/dispatch-all.js.map +1 -1
  48. package/out/typer/dispatch-call.d.ts +14 -0
  49. package/out/typer/dispatch-call.d.ts.map +1 -0
  50. package/out/typer/dispatch-call.js +634 -0
  51. package/out/typer/dispatch-call.js.map +1 -0
  52. package/out/typer/dispatch-def.d.ts +10 -4
  53. package/out/typer/dispatch-def.d.ts.map +1 -1
  54. package/out/typer/dispatch-def.js +97 -88
  55. package/out/typer/dispatch-def.js.map +1 -1
  56. package/out/typer/dispatch-expr.d.ts +3 -13
  57. package/out/typer/dispatch-expr.d.ts.map +1 -1
  58. package/out/typer/dispatch-expr.js +67 -659
  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 +28 -11
  62. package/out/typer/dispatch-process.js.map +1 -1
  63. package/out/typer/dispatch-stmt.d.ts.map +1 -1
  64. package/out/typer/dispatch-stmt.js +37 -35
  65. package/out/typer/dispatch-stmt.js.map +1 -1
  66. package/out/typer/dispatch-view.d.ts.map +1 -1
  67. package/out/typer/dispatch-view.js +36 -22
  68. package/out/typer/dispatch-view.js.map +1 -1
  69. package/out/typer/get-oql-files.d.ts +13 -0
  70. package/out/typer/get-oql-files.d.ts.map +1 -0
  71. package/out/typer/get-oql-files.js +136 -0
  72. package/out/typer/get-oql-files.js.map +1 -0
  73. package/out/typer/helper.d.ts +2 -2
  74. package/out/typer/helper.d.ts.map +1 -1
  75. package/out/typer/helper.js +5 -5
  76. package/out/typer/helper.js.map +1 -1
  77. package/out/typer/incremental-update.d.ts +1 -13
  78. package/out/typer/incremental-update.d.ts.map +1 -1
  79. package/out/typer/incremental-update.js +102 -196
  80. package/out/typer/incremental-update.js.map +1 -1
  81. package/out/typer/index.d.ts +6 -4
  82. package/out/typer/index.d.ts.map +1 -1
  83. package/out/typer/index.js +9 -9
  84. package/out/typer/index.js.map +1 -1
  85. package/out/typer/subster.d.ts +0 -1
  86. package/out/typer/subster.d.ts.map +1 -1
  87. package/out/typer/subster.js +1 -40
  88. package/out/typer/subster.js.map +1 -1
  89. package/out/typer/topo-sort.d.ts +4 -4
  90. package/out/typer/topo-sort.d.ts.map +1 -1
  91. package/out/typer/topo-sort.js +5 -1
  92. package/out/typer/topo-sort.js.map +1 -1
  93. package/out/typer/type-manager.d.ts +2 -2
  94. package/out/typer/type-manager.d.ts.map +1 -1
  95. package/out/typer/type-manager.js +33 -10
  96. package/out/typer/type-manager.js.map +1 -1
  97. package/out/typer/typer.d.ts +27 -6
  98. package/out/typer/typer.d.ts.map +1 -1
  99. package/out/typer/typer.js +70 -19
  100. package/out/typer/typer.js.map +1 -1
  101. package/out/typer/unifier.d.ts +1 -1
  102. package/out/typer/unifier.d.ts.map +1 -1
  103. package/out/typer/unifier.js +40 -34
  104. package/out/typer/unifier.js.map +1 -1
  105. package/out/utils/string.d.ts.map +1 -1
  106. package/out/utils/string.js +1 -0
  107. package/out/utils/string.js.map +1 -1
  108. package/package.json +5 -5
  109. package/out/typer/nasl-predicate.d.ts +0 -8
  110. package/out/typer/nasl-predicate.d.ts.map +0 -1
  111. package/out/typer/nasl-predicate.js +0 -25
  112. package/out/typer/nasl-predicate.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"chec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7 +10,6 @@ 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
12
  const service_2 = require("@lcap/nasl-concepts/service");
13
- const get_q_name_1 = require("./reference-manager/get-q-name");
14
13
  const helper_1 = require("./typer/helper");
15
14
  var Severity;
16
15
  (function (Severity) {
@@ -1128,6 +1127,7 @@ function createErrorDiagnoser(context) {
1128
1127
  * @param node
1129
1128
  */
1130
1129
  function* checkConnector(node) {
1130
+ env.enterScope(node);
1131
1131
  yield* checkModule(node);
1132
1132
  if (node.triggerLaunchers?.length) {
1133
1133
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.triggerLaunchers, function* (node) {
@@ -1154,6 +1154,7 @@ function createErrorDiagnoser(context) {
1154
1154
  yield* checkNode(node);
1155
1155
  });
1156
1156
  }
1157
+ env.exitScope();
1157
1158
  }
1158
1159
  /**
1159
1160
  * 检查 连接器触发器
@@ -1268,11 +1269,14 @@ function createErrorDiagnoser(context) {
1268
1269
  * @param node
1269
1270
  */
1270
1271
  function* checkStructure(node) {
1272
+ const pConn = node.getAncestor('Connector');
1273
+ pConn && env.enterScope(pConn);
1271
1274
  if (node.properties?.length) {
1272
1275
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (node) {
1273
1276
  yield* checkNode(node);
1274
1277
  });
1275
1278
  }
1279
+ pConn && env.exitScope();
1276
1280
  }
1277
1281
  /**
1278
1282
  * 检查 数据结构属性
@@ -1747,11 +1751,9 @@ function createErrorDiagnoser(context) {
1747
1751
  * @param node
1748
1752
  */
1749
1753
  function* checkInterface(node) {
1750
- const unbindVariables = env.temporarilyBindVariables([
1751
- ...(node.params || []),
1752
- ...(node.returns || []),
1753
- ...(node.protocolParams || [])
1754
- ]);
1754
+ const pConn = node.getAncestor('Connector');
1755
+ pConn && env.enterScope(pConn);
1756
+ env.enterScope(node);
1755
1757
  if (node.params?.length) {
1756
1758
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
1757
1759
  yield* checkNode(node);
@@ -1769,18 +1771,17 @@ function createErrorDiagnoser(context) {
1769
1771
  }
1770
1772
  yield* checkNode(node.validation);
1771
1773
  yield* checkTimeout(node);
1772
- unbindVariables();
1774
+ env.exitScope();
1775
+ pConn && env.exitScope();
1773
1776
  }
1774
1777
  /**
1775
1778
  * 检查 鉴权接口
1776
1779
  * @param node
1777
1780
  */
1778
1781
  function* checkAuthInterface(node) {
1779
- const unbindVariables = env.temporarilyBindVariables([
1780
- ...(node.params || []),
1781
- ...(node.returns || []),
1782
- ...(node.protocolParams || [])
1783
- ]);
1782
+ const pConn = node.getAncestor('Connector');
1783
+ pConn && env.enterScope(pConn);
1784
+ env.enterScope(node);
1784
1785
  if (node.params?.length) {
1785
1786
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
1786
1787
  yield* checkNode(node);
@@ -1798,7 +1799,8 @@ function createErrorDiagnoser(context) {
1798
1799
  }
1799
1800
  yield* checkNode(node.validation);
1800
1801
  yield* checkTimeout(node);
1801
- unbindVariables();
1802
+ env.exitScope();
1803
+ pConn && env.exitScope();
1802
1804
  }
1803
1805
  /**
1804
1806
  * 检查 接口参数
@@ -1859,7 +1861,7 @@ function createErrorDiagnoser(context) {
1859
1861
  * @param node
1860
1862
  */
1861
1863
  function* checkFrontend(node) {
1862
- const unbindVariables = env.temporarilyBindVariables(node.variables);
1864
+ env.enterScope(node);
1863
1865
  if (node.variables?.length) {
1864
1866
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
1865
1867
  yield* checkNode(node);
@@ -1875,18 +1877,14 @@ function createErrorDiagnoser(context) {
1875
1877
  yield* checkNode(node);
1876
1878
  });
1877
1879
  }
1878
- unbindVariables();
1880
+ env.exitScope();
1879
1881
  }
1880
1882
  /**
1881
1883
  * 检查 页面
1882
1884
  * @param node
1883
1885
  */
1884
1886
  function* checkView(node) {
1885
- const unbindVariables = env.temporarilyBindVariables([
1886
- ...(node.params || []),
1887
- ...(node.variables || []),
1888
- ...(node.logics || []),
1889
- ]);
1887
+ env.enterScope(node);
1890
1888
  checkVariableAndReturnTypeAnnotations(node.variables, [], false);
1891
1889
  const module = node.getAncestor('Module');
1892
1890
  if (!(module?.parentKey === 'dependencies')) {
@@ -1929,18 +1927,14 @@ function createErrorDiagnoser(context) {
1929
1927
  yield* checkNode(node);
1930
1928
  });
1931
1929
  }
1932
- unbindVariables();
1930
+ env.exitScope();
1933
1931
  }
1934
1932
  /**
1935
1933
  * 检查 业务组件
1936
1934
  * @param node
1937
1935
  */
1938
1936
  function* checkBusinessComponent(node) {
1939
- const unbindVariables = env.temporarilyBindVariables([
1940
- ...(node.params || []),
1941
- ...(node.variables || []),
1942
- ...(node.logics || []),
1943
- ]);
1937
+ env.enterScope(node);
1944
1938
  // 组件元素
1945
1939
  if (node.elements?.length) {
1946
1940
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.elements, function* (node) {
@@ -1965,7 +1959,7 @@ function createErrorDiagnoser(context) {
1965
1959
  yield* checkNode(node);
1966
1960
  });
1967
1961
  }
1968
- unbindVariables();
1962
+ env.exitScope();
1969
1963
  }
1970
1964
  /**
1971
1965
  * 检查 页面元素
@@ -1977,18 +1971,14 @@ function createErrorDiagnoser(context) {
1977
1971
  return;
1978
1972
  }
1979
1973
  const shouldProvideCurrentCtx = !!(node.slotScope);
1980
- let unbindVariables;
1974
+ let scopeEntered = false;
1981
1975
  if (shouldProvideCurrentCtx) {
1982
1976
  const name = curVarCounter > 0 ? node.slotScope + curVarCounter : node.slotScope;
1983
- const variable = new nasl_concepts_1.Variable({
1984
- name,
1985
- });
1977
+ const variable = new nasl_concepts_1.Variable({ name });
1986
1978
  curVarCounter++;
1987
- unbindVariables = env.temporarilyBindVariables([
1988
- variable,
1989
- ], () => {
1990
- curVarCounter--;
1991
- });
1979
+ // @ts-expect-error ViewElement 引入的 current 目前没有加入 refMgr,VE 也没当做 ScopeNode
1980
+ env.enterScope(node, [variable]);
1981
+ scopeEntered = true;
1992
1982
  }
1993
1983
  if (node.bindAttrs?.length) {
1994
1984
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.bindAttrs, function* (node) {
@@ -2033,7 +2023,10 @@ function createErrorDiagnoser(context) {
2033
2023
  if (!dsFilled && !hasSubComponents) {
2034
2024
  error(errNode, '数据源不能为空');
2035
2025
  }
2036
- unbindVariables?.();
2026
+ if (scopeEntered) {
2027
+ env.exitScope();
2028
+ curVarCounter--;
2029
+ }
2037
2030
  }
2038
2031
  /**
2039
2032
  * 检查 元素绑定属性
@@ -2191,10 +2184,7 @@ function createErrorDiagnoser(context) {
2191
2184
  if (node.includeTypeArgs) {
2192
2185
  error(node, '流程暂不支持泛型参数');
2193
2186
  }
2194
- const unbindVariables = env.temporarilyBindVariables([
2195
- ...(node?.params || []),
2196
- ...(node?.returns || []),
2197
- ]);
2187
+ // env.enterScope(node); 尚不支持流程 1.0
2198
2188
  if (node.params?.length) {
2199
2189
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
2200
2190
  yield* checkNode(node);
@@ -2220,17 +2210,14 @@ function createErrorDiagnoser(context) {
2220
2210
  yield* checkNode(node);
2221
2211
  });
2222
2212
  }
2223
- unbindVariables();
2213
+ // env.exitScope();
2224
2214
  }
2225
2215
  /**
2226
2216
  * 检查 流程元素
2227
2217
  * @param node
2228
2218
  */
2229
2219
  function* checkProcessElement(node) {
2230
- const unbindVariables = env.temporarilyBindVariables([
2231
- ...(node?.variables || []),
2232
- ...(node?.returns || []),
2233
- ]);
2220
+ // env.enterScope(node); 尚不支持流程1.0
2234
2221
  if (node.returns?.length) {
2235
2222
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.returns, function* (node) {
2236
2223
  yield* checkNode(node);
@@ -2275,7 +2262,7 @@ function createErrorDiagnoser(context) {
2275
2262
  yield* checkNode(node);
2276
2263
  });
2277
2264
  }
2278
- unbindVariables();
2265
+ // env.exitScope();
2279
2266
  }
2280
2267
  /**
2281
2268
  * 检查 常量
@@ -2290,6 +2277,7 @@ function createErrorDiagnoser(context) {
2290
2277
  * @param node
2291
2278
  */
2292
2279
  function* checkProcessV2(node) {
2280
+ env.enterScope(node);
2293
2281
  yield* checkNode(node.bind);
2294
2282
  if (node.processDefinitions?.length) {
2295
2283
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.processDefinitions, function* (node) {
@@ -2306,6 +2294,7 @@ function createErrorDiagnoser(context) {
2306
2294
  if (node.includeTypeArgs) {
2307
2295
  error(node, '流程暂不支持泛型参数');
2308
2296
  }
2297
+ env.exitScope();
2309
2298
  }
2310
2299
  /**
2311
2300
  * 检查 绑定实体或数据结构
@@ -2319,14 +2308,7 @@ function createErrorDiagnoser(context) {
2319
2308
  * @param node
2320
2309
  */
2321
2310
  function* checkProcessDefinitionV2(node) {
2322
- const unbindVariables = env.temporarilyBindVariables([
2323
- ...(node.variables || []),
2324
- ...['custom', 'processSystem'].map((name) => {
2325
- return new nasl_concepts_1.Variable({
2326
- name,
2327
- });
2328
- }),
2329
- ]);
2311
+ env.enterScope(node);
2330
2312
  if (node.variables?.length) {
2331
2313
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.variables, function* (node) {
2332
2314
  yield* checkNode(node);
@@ -2342,20 +2324,14 @@ function createErrorDiagnoser(context) {
2342
2324
  yield* checkNode(node);
2343
2325
  });
2344
2326
  }
2345
- unbindVariables();
2327
+ env.exitScope();
2346
2328
  }
2347
2329
  /**
2348
2330
  * 检查 流程元素
2349
2331
  * @param node
2350
2332
  */
2351
2333
  function* checkProcessElementV2(node) {
2352
- const unbindVariables = env.temporarilyBindVariables([
2353
- ...['custom', 'processSystem'].map((name) => {
2354
- return new nasl_concepts_1.Variable({
2355
- name,
2356
- });
2357
- }),
2358
- ]);
2334
+ env.enterScope(node);
2359
2335
  yield* checkNode(node.logic);
2360
2336
  yield* checkNode(node.flowCondition);
2361
2337
  if (node.bindEvents?.length) {
@@ -2410,7 +2386,7 @@ function createErrorDiagnoser(context) {
2410
2386
  else if (!service_1.ProcessesV2.isFromStartNode(node)) {
2411
2387
  error(node, '节点未关联到流程图');
2412
2388
  }
2413
- unbindVariables();
2389
+ env.exitScope();
2414
2390
  }
2415
2391
  /**
2416
2392
  * 检查 无人时,自动转派审批策略
@@ -2492,16 +2468,8 @@ function createErrorDiagnoser(context) {
2492
2468
  * @param node
2493
2469
  */
2494
2470
  function* checkLogic(node) {
2495
- const unbindVariables = env.temporarilyBindVariables([
2496
- ...(node.params || []),
2497
- ...(node.returns || []),
2498
- ...(node.variables || []),
2499
- ...(node.virtualParams || [])
2500
- ]);
2501
- // 仅检查用户写的逻辑
2502
- // if (node.nodePath?.startsWith('app.logics')) {
2471
+ env.enterScope(node);
2503
2472
  checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
2504
- // }
2505
2473
  const module = node.getAncestor('Module');
2506
2474
  if (!(module?.parentKey === 'dependencies')) {
2507
2475
  if (node.params?.length) {
@@ -2592,34 +2560,38 @@ function createErrorDiagnoser(context) {
2592
2560
  if (!likeComponent) {
2593
2561
  yield* checkTrigger(node);
2594
2562
  }
2595
- unbindVariables();
2563
+ env.exitScope();
2596
2564
  }
2597
2565
  /**
2598
2566
  * 检查 鉴权逻辑
2599
2567
  * @param node
2600
2568
  */
2601
2569
  function* checkAuthLogic(node) {
2570
+ const pConn = node.getAncestor('Connector');
2571
+ pConn && env.enterScope(pConn);
2602
2572
  inAuthLogic = true;
2573
+ // checkLogic 会 enter scope
2603
2574
  yield* checkLogic(node);
2604
2575
  inAuthLogic = false;
2576
+ pConn && env.exitScope();
2605
2577
  }
2606
2578
  /**
2607
2579
  * 检查 调用接口的鉴权逻辑
2608
2580
  * @param node
2609
2581
  */
2610
2582
  function* checkAuthLogicForCallInterface(node) {
2611
- const unbindVariables = env.temporarilyBindVariables([
2612
- ...(node.authParams || []),
2613
- ]);
2583
+ // authLogic 会打开 Connector 的局部-全局变量
2614
2584
  yield* checkAuthLogic(node);
2615
- unbindVariables();
2616
2585
  }
2617
2586
  /**
2618
2587
  * 检查 调用接口的鉴权逻辑
2619
2588
  * @param node
2620
2589
  */
2621
2590
  function* checkConnectorLogic(node) {
2591
+ const pConn = node.getAncestor('Connector');
2592
+ pConn && env.enterScope(pConn);
2622
2593
  yield* checkLogic(node);
2594
+ pConn && env.exitScope();
2623
2595
  }
2624
2596
  /**
2625
2597
  * 检查 业务组件逻辑
@@ -2633,12 +2605,7 @@ function createErrorDiagnoser(context) {
2633
2605
  * @param node
2634
2606
  */
2635
2607
  function* checkOverriddenLogic(node) {
2636
- const unbindVariables = env.temporarilyBindVariables([
2637
- ...(node.params || []),
2638
- ...(node.returns || []),
2639
- ...(node.variables || []),
2640
- ...(node.virtualParams || [])
2641
- ]);
2608
+ env.enterScope(node);
2642
2609
  const module = node.getAncestor('Module');
2643
2610
  if (!(module?.parentKey === 'dependencies')) {
2644
2611
  if (node.params?.length) {
@@ -2664,7 +2631,7 @@ function createErrorDiagnoser(context) {
2664
2631
  });
2665
2632
  }
2666
2633
  yield* checkPlayground(node.playground);
2667
- unbindVariables();
2634
+ env.exitScope();
2668
2635
  yield* checkTrigger(node);
2669
2636
  }
2670
2637
  /**
@@ -2677,14 +2644,8 @@ function createErrorDiagnoser(context) {
2677
2644
  * @param node
2678
2645
  */
2679
2646
  function* checkSubLogic(node) {
2680
- const unbindVariables = env.temporarilyBindVariables([
2681
- ...(node.params || []),
2682
- ...(node.returns || []),
2683
- ...(node.variables || []),
2684
- ]);
2685
- // if (nd.nodePath?.startsWith('app.logics')) {
2647
+ env.enterScope(node);
2686
2648
  checkVariableAndReturnTypeAnnotations(node.variables, node.returns);
2687
- // }
2688
2649
  const module = node.getAncestor('Module');
2689
2650
  if (!(module?.parentKey === 'dependencies')) {
2690
2651
  if (node.params?.length) {
@@ -2710,7 +2671,7 @@ function createErrorDiagnoser(context) {
2710
2671
  });
2711
2672
  }
2712
2673
  yield* checkPlayground(node.playground);
2713
- unbindVariables();
2674
+ env.exitScope();
2714
2675
  return env.getType(node);
2715
2676
  }
2716
2677
  /**
@@ -2777,7 +2738,7 @@ function createErrorDiagnoser(context) {
2777
2738
  yield* checkVoidCallUsedAsStatement(node);
2778
2739
  const ref = env.resolveRef(node); // 前端
2779
2740
  // TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
2780
- // 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
2741
+ // 暂时不在 gQNameDefs 里,用 isBuiltInCall 简单判断了
2781
2742
  if (!ref && !isBuiltInCall(node)) {
2782
2743
  const depLibName = getExtensionLibName(node);
2783
2744
  if (depLibName) {
@@ -3245,10 +3206,7 @@ function createErrorDiagnoser(context) {
3245
3206
  * @param node
3246
3207
  */
3247
3208
  function* checkForEachStatement(node) {
3248
- const unbindVariables = env.temporarilyBindVariables([
3249
- node.item,
3250
- node.index,
3251
- ]);
3209
+ env.enterScope(node);
3252
3210
  if (ensureNodeKeyExists(node, 'each')) {
3253
3211
  yield* checkNode(node.each);
3254
3212
  }
@@ -3270,7 +3228,7 @@ function createErrorDiagnoser(context) {
3270
3228
  error(node, `ForEach:循环列表:参数类型不匹配!结束值自动推导失败。`);
3271
3229
  }
3272
3230
  }
3273
- unbindVariables();
3231
+ env.exitScope();
3274
3232
  }
3275
3233
  /**
3276
3234
  * 检查 循环分支
@@ -3904,14 +3862,14 @@ function createErrorDiagnoser(context) {
3904
3862
  */
3905
3863
  function* checkFunction(node) {
3906
3864
  if (ensureNodeKeyExists(node, 'returnExpression')) {
3907
- const unbindVariables = env.temporarilyBindVariables(node.params);
3865
+ env.enterScope(node);
3908
3866
  if (node.params?.length) {
3909
3867
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
3910
3868
  yield* checkNode(node);
3911
3869
  });
3912
3870
  }
3913
3871
  yield* checkNode(node.returnExpression);
3914
- unbindVariables();
3872
+ env.exitScope();
3915
3873
  }
3916
3874
  }
3917
3875
  /**
@@ -3919,7 +3877,7 @@ function createErrorDiagnoser(context) {
3919
3877
  * @param node
3920
3878
  */
3921
3879
  function* checkAnonymousFunction(node) {
3922
- const unbindVariables = env.temporarilyBindVariables(node.params);
3880
+ env.enterScope(node);
3923
3881
  if (node.params?.length) {
3924
3882
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.params, function* (node) {
3925
3883
  yield* checkNode(node);
@@ -3928,7 +3886,7 @@ function createErrorDiagnoser(context) {
3928
3886
  if (ensureNodeKeyExists(node, 'body')) {
3929
3887
  yield* checkNode(node.body);
3930
3888
  }
3931
- unbindVariables();
3889
+ env.exitScope();
3932
3890
  }
3933
3891
  /**
3934
3892
  * 检查 验证规则
@@ -3964,8 +3922,7 @@ function createErrorDiagnoser(context) {
3964
3922
  ensureNodeKeyExists(node, 'typeKind');
3965
3923
  if (['primitive', 'reference', 'generic'].includes(node.typeKind)) {
3966
3924
  if (ensureNodeKeyExists(node, 'typeName') && node.typeKind === 'reference') {
3967
- const qName = (0, get_q_name_1.getTokenQualifiedName)(node);
3968
- const ref = env.refMgr.gQNameDefs.get(qName);
3925
+ const ref = env.resolveRef(node);
3969
3926
  if (!ref) {
3970
3927
  error(node, `找不到类型 ${node.typeName}`);
3971
3928
  }