@lcap/nasl-language-server-core 4.0.1-rc.1 → 4.1.0-beta.10

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 (102) hide show
  1. package/out/checker.d.ts +1 -1
  2. package/out/checker.d.ts.map +1 -1
  3. package/out/checker.js +38 -3
  4. package/out/checker.js.map +1 -1
  5. package/out/index.d.ts +2 -1
  6. package/out/index.d.ts.map +1 -1
  7. package/out/index.js +4 -1
  8. package/out/index.js.map +1 -1
  9. package/out/reference-manager/builtin-q-name.d.ts +1 -1
  10. package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
  11. package/out/reference-manager/builtin-q-name.js +14 -10
  12. package/out/reference-manager/builtin-q-name.js.map +1 -1
  13. package/out/reference-manager/collect-q-name.d.ts.map +1 -1
  14. package/out/reference-manager/collect-q-name.js +15 -13
  15. package/out/reference-manager/collect-q-name.js.map +1 -1
  16. package/out/reference-manager/get-q-name.d.ts +0 -2
  17. package/out/reference-manager/get-q-name.d.ts.map +1 -1
  18. package/out/reference-manager/get-q-name.js +30 -46
  19. package/out/reference-manager/get-q-name.js.map +1 -1
  20. package/out/reference-manager/reference-manager.d.ts +19 -10
  21. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  22. package/out/reference-manager/reference-manager.js +141 -101
  23. package/out/reference-manager/reference-manager.js.map +1 -1
  24. package/out/reference-manager/remove-q-name.d.ts.map +1 -1
  25. package/out/reference-manager/remove-q-name.js +22 -15
  26. package/out/reference-manager/remove-q-name.js.map +1 -1
  27. package/out/reference-manager/symbol-type.d.ts +3 -2
  28. package/out/reference-manager/symbol-type.d.ts.map +1 -1
  29. package/out/reference-manager/symbol-type.js +7 -1
  30. package/out/reference-manager/symbol-type.js.map +1 -1
  31. package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
  32. package/out/reference-manager/update-nasl-fragment.js +4 -4
  33. package/out/reference-manager/update-nasl-fragment.js.map +1 -1
  34. package/out/symbol/traverse/concepts/index.d.ts +1 -1
  35. package/out/symbol/traverse/concepts/index.d.ts.map +1 -1
  36. package/out/typer/collectGlobalDefs.d.ts +1 -1
  37. package/out/typer/collectGlobalDefs.d.ts.map +1 -1
  38. package/out/typer/collectGlobalDefs.js +2 -2
  39. package/out/typer/collectGlobalDefs.js.map +1 -1
  40. package/out/typer/component-def-manager/component-def-manager.js +2 -2
  41. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  42. package/out/typer/dispatch-all.d.ts +1 -1
  43. package/out/typer/dispatch-all.d.ts.map +1 -1
  44. package/out/typer/dispatch-all.js +2 -2
  45. package/out/typer/dispatch-all.js.map +1 -1
  46. package/out/typer/dispatch-expr.d.ts.map +1 -1
  47. package/out/typer/dispatch-expr.js +150 -106
  48. package/out/typer/dispatch-expr.js.map +1 -1
  49. package/out/typer/dispatch-process.js +1 -1
  50. package/out/typer/dispatch-process.js.map +1 -1
  51. package/out/typer/dispatch-view.d.ts +1 -1
  52. package/out/typer/dispatch-view.d.ts.map +1 -1
  53. package/out/typer/dispatch-view.js +13 -10
  54. package/out/typer/dispatch-view.js.map +1 -1
  55. package/out/typer/incremental-update.d.ts.map +1 -1
  56. package/out/typer/incremental-update.js +23 -39
  57. package/out/typer/incremental-update.js.map +1 -1
  58. package/out/typer/index.d.ts +2 -1
  59. package/out/typer/index.d.ts.map +1 -1
  60. package/out/typer/index.js +3 -1
  61. package/out/typer/index.js.map +1 -1
  62. package/out/typer/overload-helper.d.ts +12 -0
  63. package/out/typer/overload-helper.d.ts.map +1 -0
  64. package/out/typer/overload-helper.js +110 -0
  65. package/out/typer/overload-helper.js.map +1 -0
  66. package/out/typer/sem-diag.d.ts +5 -0
  67. package/out/typer/sem-diag.d.ts.map +1 -1
  68. package/out/typer/sem-diag.js +15 -1
  69. package/out/typer/sem-diag.js.map +1 -1
  70. package/out/typer/solver.d.ts +2 -2
  71. package/out/typer/solver.d.ts.map +1 -1
  72. package/out/typer/solver.js +17 -19
  73. package/out/typer/solver.js.map +1 -1
  74. package/out/typer/subster.js +3 -3
  75. package/out/typer/subster.js.map +1 -1
  76. package/out/typer/type-hint-manager/type-hint-manager.d.ts +1 -1
  77. package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +1 -1
  78. package/out/typer/type-manager.d.ts.map +1 -1
  79. package/out/typer/type-manager.js +3 -3
  80. package/out/typer/type-manager.js.map +1 -1
  81. package/out/typer/type-predicate.js +5 -5
  82. package/out/typer/type-predicate.js.map +1 -1
  83. package/out/typer/typer.d.ts +7 -4
  84. package/out/typer/typer.d.ts.map +1 -1
  85. package/out/typer/typer.js +24 -17
  86. package/out/typer/typer.js.map +1 -1
  87. package/out/typer/unifier.d.ts.map +1 -1
  88. package/out/typer/unifier.js +10 -4
  89. package/out/typer/unifier.js.map +1 -1
  90. package/out/utils/parseTsClassType.d.ts +2 -3
  91. package/out/utils/parseTsClassType.d.ts.map +1 -1
  92. package/out/utils/parseTsClassType.js +25 -58
  93. package/out/utils/parseTsClassType.js.map +1 -1
  94. package/out/utils/string.d.ts +4 -0
  95. package/out/utils/string.d.ts.map +1 -0
  96. package/out/utils/string.js +29 -0
  97. package/out/utils/string.js.map +1 -0
  98. package/out/utils/type-operator.d.ts +1 -1
  99. package/out/utils/type-operator.d.ts.map +1 -1
  100. package/out/utils/type-operator.js +12 -12
  101. package/out/utils/type-operator.js.map +1 -1
  102. package/package.json +10 -7
@@ -1,11 +1,8 @@
1
- import { Entity, EntityProperty, Enum, Identifier, Structure, StructureProperty, type SyntaxNode, TypeAnnotation, App, EnumItem, ViewElement, ProcessElementV2 } from '@lcap/nasl-concepts';
1
+ import { Entity, EntityProperty, Enum, Identifier, Structure, StructureProperty, type SyntaxNode, TypeAnnotation, App, EnumItem, ViewElement, ProcessElementV2, View } from '@lcap/nasl-concepts';
2
2
  import { NASLObject } from '@lcap/nasl-types';
3
- import { SymbolGraph } from '../symbol';
4
3
  import { type SemEnv } from '../typer';
5
4
  import { ComponentDefManager } from '../typer/component-def-manager/component-def-manager';
6
- import { getTokenQualifiedName, getTokenQualifiedNameForMatchedExpr, getPropQName, prependNonEmptyStr } from './get-q-name';
7
5
  import { type RefConcept, type DefConcept, SupportedNamespace, QName, Operation } from './symbol-type';
8
- export { getTokenQualifiedName, getTokenQualifiedNameForMatchedExpr, getPropQName, prependNonEmptyStr as prependStr };
9
6
  /**
10
7
  * 考虑这样一个例子:
11
8
  * x = f(...)
@@ -142,9 +139,8 @@ export declare class ReferenceManager {
142
139
  static connectionNsp: string;
143
140
  constructor();
144
141
  buildQNameDefsForApp(app?: App): void;
145
- buildSymbolRefsForApp(env: SemEnv, app?: App, symbolGraph?: SymbolGraph): void;
142
+ buildSymbolRefsForApp(env: SemEnv, app?: App): void;
146
143
  static getProp: (def: Entity | Structure | Enum | TypeAnnotation, prop: string) => EntityProperty | StructureProperty | EnumItem | undefined;
147
- private buildSymbolRefsFromSymbolGraph;
148
144
  slowBuildSymbolRefsForApp: (env: SemEnv, app: App) => void;
149
145
  private fastBuildQNameDefs;
150
146
  /**
@@ -221,6 +217,7 @@ export declare class ReferenceManager {
221
217
  */
222
218
  private handleForeignKeyRef;
223
219
  private handleBusinessComponentRefs;
220
+ private handleBindRoles;
224
221
  /**
225
222
  * 无论根节点是 ref 还是 def,都要递归收集下层所有的引用节点
226
223
  * 会打散 a.b.c、A | B、x.a.b 等结构,并记录必要的信息
@@ -234,22 +231,24 @@ export declare class ReferenceManager {
234
231
  * @warning 此过程收集所有引用,包括全局符号和局部符号的,不会做过滤
235
232
  * @param env semantic environment
236
233
  * @param nd start node to collect sub refs
234
+ * @param skipSubView whether skip the collection for sub views
237
235
  * @returns [ref, qName]
238
236
  */
239
237
  private collectRefs;
240
- collectGlobalSubDefs: (nd: DefConcept) => Map<DefConcept, QName>;
241
238
  /**
242
239
  * @warning Only handle global symbols
243
240
  * 仅清除全局符号的引用。外部优先调用此接口,不要直接调用 collectRefs
244
241
  * 不是说输入是 global symbol,而是说对于任何输入,只移除内部对 global symbol 的引用
242
+ * @param skipSubView 是否跳过子页面,增量场景调用较多,增量场景默认跳过
245
243
  */
246
- removeRefsForGlobalSym: (env: SemEnv, rmNd: DefConcept) => void;
244
+ removeRefsForGlobalSym: (env: SemEnv, rmNd: DefConcept, skipSubView?: boolean) => void;
247
245
  /**
248
246
  * @warning Only handle global symbols
249
247
  * 仅收集全局符号的引用。外部优先调用此接口,不要直接调用 collectRefs
250
248
  * 不是说输入是 global symbol,而是说对于任何输入,只收集内部对 global symbol 的引用
249
+ * @param skipSubView 是否跳过子页面,增量场景调用较多,增量场景默认跳过
251
250
  */
252
- addRefsForGlobalSym: (env: SemEnv, nd: DefConcept) => void;
251
+ addRefsForGlobalSym: (env: SemEnv, nd: DefConcept, skipSubView?: boolean) => void;
253
252
  invalidateLocalSymCache: () => void;
254
253
  /**
255
254
  * 干的事太多了,只能改名 hack 了
@@ -270,6 +269,9 @@ export declare class ReferenceManager {
270
269
  */
271
270
  private splitPolyType;
272
271
  private splitQueryLike;
272
+ /**
273
+ * FieldPermissionV2 是对 Entity 和其属性的特殊引用
274
+ */
273
275
  private splitFieldPermissionV2;
274
276
  static getEntityLogicQNames(nd: Entity): string[];
275
277
  clearAll(): void;
@@ -284,7 +286,6 @@ export declare const easyGetOldQName: (qName: string, oldName: string) => string
284
286
  * 今后大概率会改成 isNonUserNode,实体逻辑只是其中之一。比如文件夹应该也是 nonUserNode 吧
285
287
  */
286
288
  export declare const isEntityLogic: (nd: SyntaxNode | null | undefined) => boolean;
287
- export declare const lowercaseFirstChar: (str: string) => string;
288
289
  /**
289
290
  * 处理 CodeWave 编译器的一些连带的自动化行为,如自动生成 { abc: Abc } 这样的匿名结构体。
290
291
  * 这里实质上是否是引用?这里不是直接引用,但是 entityX 这个名字是从 EntityX 自动生成的,也可以看作是间接引用
@@ -300,4 +301,12 @@ export declare const getDatasourceQName: (eNsp: string) => string;
300
301
  * xxx.entities 只保留 xxx
301
302
  */
302
303
  export declare const getNamespaceWithoutLast: (def: DefConcept) => string;
304
+ export declare const cheapTestLocalSymbol: (qName: string) => boolean;
305
+ /**
306
+ * 一个 FileNode 下面还可以有其他 FileNode 哦,其实没什么神秘的。
307
+ * @warning 只会返回下属的 FileNode,不包含自己
308
+ * @param node
309
+ * @returns 下属 FileNodes,不包含自己
310
+ */
311
+ export declare const getSubViews: (node: SyntaxNode) => Array<View>;
303
312
  //# sourceMappingURL=reference-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference-manager.d.ts","sourceRoot":"","sources":["../../src/reference-manager/reference-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,EACN,cAAc,EACd,IAAI,EACJ,UAAU,EAOV,SAAS,EACT,iBAAiB,EACjB,KAAK,UAAU,EACf,cAAc,EAId,GAAG,EACH,QAAQ,EACR,WAAW,EAWX,gBAAgB,EAKnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAwBxC,OAAO,EAAoC,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAkC,MAAM,sDAAsD,CAAC;AAC3H,OAAO,EAAE,qBAAqB,EAAE,mCAAmC,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC5H,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAe,kBAAkB,EAAE,KAAK,EAAgG,SAAS,EAAuB,MAAM,eAAe,CAAC;AASvO,OAAO,EAAE,qBAAqB,EAAE,mCAAmC,EAAE,YAAY,EAAE,kBAAkB,IAAI,UAAU,EAAE,CAAC;AAKtH;;;;;;;;;;;;GAYG;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DE;AAIF;;;;;;;GAOG;AAEH;;GAEG;AAKH;;;;;GAKG;AAEH;;;;;;GAMG;AACH,qBAAa,gBAAgB;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OAGG;IACH,OAAO,CAAC,mBAAmB,CAY1B;IAED,OAAO,CAAC,2BAA2B,CASlC;IAED;;;;;;OAMG;IACH;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAmFlB;IAEM,oBAAoB,OAAQ,UAAU,KAAG,IAAI,UAAU,EAAE,KAAK,CAAC,CAerE;IAED;;;;OAIG;IACI,sBAAsB,QAAS,MAAM,QAAQ,UAAU,UAkC7D;IAED;;;;OAIG;IACI,mBAAmB,QAAS,MAAM,MAAM,UAAU,UAsBxD;IAEM,uBAAuB,aAE7B;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW,CAiIlB;IAED;;;;;;OAMG;IACH,OAAO,CAAC,aAAa,CAuBpB;IAGD,OAAO,CAAC,cAAc,CAuCpB;IAEF,OAAO,CAAC,sBAAsB,CAoB5B;IAEF,MAAM,CAAC,oBAAoB,CAAC,EAAE,EAAE,MAAM;IAS/B,QAAQ;IAYf;;OAEG;IACH,cAAc,4BAgDb;IAEM,oBAAoB,6BAA8B,CAAC,KAAG,CAAC,CAsB7D;CACJ;AAgGD,eAAO,MAAM,eAAe,UAAW,MAAM,WAAW,MAAM,KAAG,MAWhE,CAAC;AAkBF;;GAEG;AACH,eAAO,MAAM,aAAa,OAAQ,UAAU,GAAG,IAAI,GAAG,SAAS,KAAG,OACuB,CAAC;AAE1F,eAAO,MAAM,kBAAkB,QAAS,MAAM,WAK7C,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,OACxB,cAAc,YACR,iBAAiB,GAAG,SAAS,SAChC,UAAU,KAClB,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,SAQxB,CAAA;AAsCD,eAAO,MAAM,kBAAkB,SAAU,MAAM,WAErC,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAS,UAAU,WActD,CAAA"}
1
+ {"version":3,"file":"reference-manager.d.ts","sourceRoot":"","sources":["../../src/reference-manager/reference-manager.ts"],"names":[],"mappings":"A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KAAG,CAAC,CAsB7D;CACJ;AAgGD,eAAO,MAAM,eAAe,UAAW,MAAM,WAAW,MAAM,KAAG,MAWhE,CAAC;AAkBF;;GAEG;AACH,eAAO,MAAM,aAAa,OAAQ,UAAU,GAAG,IAAI,GAAG,SAAS,KAAG,OACuB,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,OACxB,cAAc,YACR,iBAAiB,GAAG,SAAS,SAChC,UAAU,KAClB,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,SAQxB,CAAA;AAsCD,eAAO,MAAM,kBAAkB,SAAU,MAAM,WAErC,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAS,UAAU,WActD,CAAA;AAKD,eAAO,MAAM,oBAAoB,UAAW,MAAM,YAgBjD,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAU,UAAU,KAAG,MAAM,IAAI,CAWxD,CAAA"}
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNamespaceWithoutLast = exports.getDatasourceQName = exports.handleEntityAutoRef = exports.lowercaseFirstChar = exports.isEntityLogic = exports.easyGetOldQName = exports.ReferenceManager = exports.prependStr = exports.getPropQName = exports.getTokenQualifiedNameForMatchedExpr = exports.getTokenQualifiedName = void 0;
3
+ exports.getSubViews = exports.cheapTestLocalSymbol = exports.getNamespaceWithoutLast = exports.getDatasourceQName = exports.handleEntityAutoRef = exports.isEntityLogic = exports.easyGetOldQName = exports.ReferenceManager = void 0;
4
4
  const nasl_concepts_1 = require("@lcap/nasl-concepts");
5
+ const mnemonist_1 = require("mnemonist");
5
6
  const fp_macros_1 = require("../utils/fp-macros");
6
7
  const console_1 = require("console");
7
8
  const builtin_q_name_1 = require("./builtin-q-name");
@@ -11,17 +12,14 @@ const type_predicate_1 = require("../typer/type-predicate");
11
12
  const helper_1 = require("../typer/helper");
12
13
  const component_def_manager_1 = require("../typer/component-def-manager/component-def-manager");
13
14
  const get_q_name_1 = require("./get-q-name");
14
- Object.defineProperty(exports, "getTokenQualifiedName", { enumerable: true, get: function () { return get_q_name_1.getTokenQualifiedName; } });
15
- Object.defineProperty(exports, "getTokenQualifiedNameForMatchedExpr", { enumerable: true, get: function () { return get_q_name_1.getTokenQualifiedNameForMatchedExpr; } });
16
- Object.defineProperty(exports, "getPropQName", { enumerable: true, get: function () { return get_q_name_1.getPropQName; } });
17
- Object.defineProperty(exports, "prependStr", { enumerable: true, get: function () { return get_q_name_1.prependNonEmptyStr; } });
15
+ const string_1 = require("../utils/string");
18
16
  const symbol_type_1 = require("./symbol-type");
19
17
  const update_nasl_fragment_1 = require("./update-nasl-fragment");
20
18
  const nasl_predicate_1 = require("../typer/nasl-predicate");
21
19
  const type_manager_1 = require("../typer/type-manager");
22
20
  const oql_1 = require("../utils/oql");
23
21
  const parseTsClassType_1 = require("../utils/parseTsClassType");
24
- const mnemonist_1 = require("mnemonist");
22
+ const string_2 = require("../utils/string");
25
23
  /**
26
24
  * 考虑这样一个例子:
27
25
  * x = f(...)
@@ -193,12 +191,6 @@ class ReferenceManager {
193
191
  this.localQNameRefs = new Map();
194
192
  // 当前文件节点
195
193
  this.curFileNode = undefined;
196
- this.buildSymbolRefsFromSymbolGraph = (symbolGraph) => {
197
- const m = this.symbolRefs; // Using private property directly for internal function
198
- Array.from(symbolGraph.getSymbols()).forEach(sym => sym.declaration
199
- && symbol_type_1.globalDefConcept.includes(sym.declaration.concept)
200
- && m.set(sym.declaration, new Set(sym.references)));
201
- };
202
194
  // 约 20 万节点 200ms
203
195
  this.slowBuildSymbolRefsForApp = (env, app) => {
204
196
  this.modeForCollect = "create" /* Operation.Create */;
@@ -256,8 +248,8 @@ class ReferenceManager {
256
248
  // for (const preference of app.preferenceMap) {
257
249
  // allRefs.push(...this.collectRefs(env, preference as any as ValidExtInp));
258
250
  // }
259
- app.integration && allRefs.push(...this.collectRefs(env, app.integration));
260
- app.backend && allRefs.push(...this.collectRefs(env, app.backend));
251
+ app.integration && allRefs.push(...this.collectRefs(env, app.integration, false));
252
+ app.backend && allRefs.push(...this.collectRefs(env, app.backend, false));
261
253
  allRefs.forEach(([ref, qName]) => {
262
254
  if (!ref) {
263
255
  return;
@@ -270,24 +262,11 @@ class ReferenceManager {
270
262
  else {
271
263
  // Cache reference for future relinking
272
264
  // FIXME:这里有问题,脏脏的,比如局部变量、入参等都扔到这里面了,虽然暂时可能没有太大的正确性问题,但有内存泄漏
273
- if (!cheapTestLocalSymbol(qName)) {
265
+ if (!(0, exports.cheapTestLocalSymbol)(qName)) {
274
266
  (0, helper_1.createSetOnPush)(this.cachedQNameSymbolRefs, qName, ref);
275
267
  }
276
268
  }
277
269
  });
278
- // 如果 QA 说查找引用要能看到实体逻辑里的类型啥的,再给注释去掉
279
- // 处理一下实体逻辑
280
- // app.dataSources.forEach(ds => {
281
- // ds.entities.forEach(e => {
282
- // e.logics.forEach((l: Logic) => {
283
- // const refsInLogic = this.collectRefs(env, l);
284
- // refsInLogic.forEach((qName, ref) => {
285
- // console.log('xx')
286
- // allRefs.set(ref, qName);
287
- // });
288
- // });
289
- // });
290
- // });
291
270
  // 暂时特殊处理一下流程,应该不会太慢
292
271
  for (const p of app.processV2s) {
293
272
  this.addRefsForGlobalSym(env, p);
@@ -301,7 +280,8 @@ class ReferenceManager {
301
280
  }
302
281
  for (const fe of fet.frontends) {
303
282
  for (const v of fe.views) {
304
- this.addRefsForGlobalSym(env, v);
283
+ // 包括子页面
284
+ this.addRefsForGlobalSym(env, v, false);
305
285
  }
306
286
  for (const be of fe.bindEvents) {
307
287
  this.addRefsForGlobalSym(env, be);
@@ -442,10 +422,14 @@ class ReferenceManager {
442
422
  // nd = this.qNameDefs.get(getTokenQualifiedName(nd)!)!;
443
423
  // ==> 好像也不行,很多依赖库逻辑调用又挂了,这也不行,那也不行
444
424
  // 全局符号直接查找
445
- // if (nd.concept === 'ProcessV2') {
446
- // } else
447
425
  if (isGlobalDef(nd)) {
448
- res = this.getSymbolRefs(nd);
426
+ res = this.getSymbolRefs(nd) ?? new Set();
427
+ if (nd.concept === 'Entity') {
428
+ // 加上所有实体逻辑调用的引用(实体逻辑可看做无定义,但要修改调用处的 namespace:实体名是 namespace 的一部分)
429
+ for (const l of nd.logics) {
430
+ res = mnemonist_1.set.union(res, this.getSymbolRefs(l) ?? new Set());
431
+ }
432
+ }
449
433
  }
450
434
  else { // 局部符号才需要即时获取
451
435
  const boundary = toRaw(getBoundary(nd));
@@ -460,12 +444,28 @@ class ReferenceManager {
460
444
  (endTime - startTime > 200) && console.log(`Get reference: all time: ${endTime - startTime}ms`);
461
445
  }
462
446
  }
447
+ // 这个东西很特殊……查三代
448
+ if (nd.concept === 'BusinessLogic') {
449
+ // 上面已经找到了业务组件内部对业务组件逻辑的内用
450
+ // 现在再找出所有 业务组件逻辑 所属的业务组件的外部引用
451
+ const bs = toRaw((0, nasl_concepts_1.getCtxViewLike)(nd));
452
+ if (bs?.concept === 'BusinessComponent') {
453
+ const bsRefs = this.getSymbolRefs(bs) ?? new Set();
454
+ let bsRefsRefs = new Array(); // 业务组件(在页面的引用)的引用
455
+ // 再对每个实例找到所有引用
456
+ for (const bsInst of bsRefs) {
457
+ bsRefsRefs.push(...this.getViewElementRefs(env, bsInst));
458
+ }
459
+ // 再从引用中过滤出找到当前业务逻辑的调用
460
+ res = mnemonist_1.set.union(res, new Set(bsRefsRefs.filter(r => r.concept === 'CallLogic' && r.calleeName === nd.name))); // amazing!
461
+ }
462
+ }
463
463
  return res ? Array.from(res) : [];
464
464
  };
465
465
  // 建立所有局部引用,先处理上一次的缓存
466
466
  this.clearRebuildLocalCache = (env, nd_) => {
467
467
  this.localQNameRefs.clear();
468
- return this.buildLocalQNameRefs(env, toRaw(nd_));
468
+ return this.buildLocalQNameRefs(env, toRaw(nd_)) ?? new Set();
469
469
  };
470
470
  // 给类似 FileNode 级别的定义建立局部索引
471
471
  // 修改后:不写入 env map 了,不做缓存,直接返回数据
@@ -482,12 +482,12 @@ class ReferenceManager {
482
482
  }
483
483
  if (boundary.concept === 'View' || boundary.concept === 'BusinessComponent') {
484
484
  viewVars = (0, nasl_concepts_1.getViewVars)(nd).map(toRaw);
485
- logicVars = (0, nasl_concepts_1.getViewLikeLogics)(nd).map(toRaw);
485
+ logicVars.push(...(0, nasl_concepts_1.getCtxLogicLike)(nd)?.variables?.map(toRaw) ?? []);
486
486
  logics = (0, nasl_concepts_1.getViewLikeLogics)(nd).map(toRaw);
487
487
  }
488
488
  else if (boundary.concept === 'ProcessDefinitionV2') {
489
489
  processVars = (0, nasl_concepts_1.getProcessVars)(nd).map(toRaw);
490
- logicVars = (0, nasl_concepts_1.getProcessLikeLogics)(nd).map(toRaw);
490
+ logicVars.push(...(0, nasl_concepts_1.getCtxLogicLike)(nd)?.variables?.map(toRaw) ?? []);
491
491
  logics = (0, nasl_concepts_1.getProcessLikeLogics)(nd).map(toRaw);
492
492
  }
493
493
  else if ((0, nasl_predicate_1.isCallableNaslLogic)(boundary) || (0, nasl_predicate_1.isCallableNaslInterface)(boundary)) {
@@ -501,7 +501,7 @@ class ReferenceManager {
501
501
  this.localQNameRefs.set(qName, new Set());
502
502
  }
503
503
  });
504
- let subRefs = this.collectRefs(env, boundary);
504
+ let subRefs = this.collectRefs(env, boundary, true);
505
505
  this.lastBoundary = boundary;
506
506
  subRefs?.forEach(([rf, qName]) => {
507
507
  // 不存在则表示不是局部符号
@@ -563,7 +563,7 @@ class ReferenceManager {
563
563
  return result;
564
564
  }
565
565
  const nd = toRaw(__nd);
566
- const ctxProcLike = (0, nasl_concepts_1.getCtxProcessLike)(nd);
566
+ const ctxProcLike = toRaw((0, nasl_concepts_1.getCtxProcessLike)(nd));
567
567
  if (!ctxProcLike) {
568
568
  return result;
569
569
  }
@@ -581,6 +581,7 @@ class ReferenceManager {
581
581
  }
582
582
  };
583
583
  visitChildrenWith(ctxProcLike, lam);
584
+ // 重命名时不需要处理 sourceRef targetRef,好像其他逻辑已经处理掉了
584
585
  return result;
585
586
  };
586
587
  /**
@@ -767,7 +768,7 @@ class ReferenceManager {
767
768
  res.push([typeAnnotation, tyQName]);
768
769
  const parentConcept = (0, type_predicate_1.isEntityTy)(typeAnnotation) ? 'Entity' : 'Structure';
769
770
  for (const prop of nd.properties) {
770
- const propQName = (0, get_q_name_1.getPropQName)(tyQName, prop.name, parentConcept);
771
+ const propQName = (0, string_2.getPropQName)(tyQName, prop.name, parentConcept);
771
772
  res.push([prop, propQName]);
772
773
  }
773
774
  };
@@ -784,7 +785,7 @@ class ReferenceManager {
784
785
  }
785
786
  const relEntityQName = `${relNsp}.${relEntity}`;
786
787
  this.handleRefOp(env, this.modeForCollect, nd, relEntityQName);
787
- const relPropQName = (0, get_q_name_1.getPropQName)(`${relNsp}.${relEntity}`, `${relProperty}`, 'Entity');
788
+ const relPropQName = (0, string_2.getPropQName)(`${relNsp}.${relEntity}`, `${relProperty}`, 'Entity');
788
789
  this.handleRefOp(env, this.modeForCollect, nd, relPropQName);
789
790
  };
790
791
  this.handleBusinessComponentRefs = (env, nd) => {
@@ -797,6 +798,12 @@ class ReferenceManager {
797
798
  }
798
799
  this.handleRefOp(env, this.modeForCollect, nd, (0, get_q_name_1.getTokenQualifiedName)(bsDef));
799
800
  };
801
+ this.handleBindRoles = (env, nd) => {
802
+ for (const roleName of nd.bindRoles ?? nd.roles) {
803
+ const qName = (0, symbol_type_1.wrapRoleToQName)(roleName);
804
+ this.handleRefOp(env, this.modeForCollect, nd, qName);
805
+ }
806
+ };
800
807
  /**
801
808
  * 无论根节点是 ref 还是 def,都要递归收集下层所有的引用节点
802
809
  * 会打散 a.b.c、A | B、x.a.b 等结构,并记录必要的信息
@@ -810,16 +817,34 @@ class ReferenceManager {
810
817
  * @warning 此过程收集所有引用,包括全局符号和局部符号的,不会做过滤
811
818
  * @param env semantic environment
812
819
  * @param nd start node to collect sub refs
820
+ * @param skipSubView whether skip the collection for sub views
813
821
  * @returns [ref, qName]
814
822
  */
815
- this.collectRefs = (env, nd) => {
823
+ this.collectRefs = (env, nd, skipSubView = true) => {
824
+ // 有的 nd 没实例化,上面没有 traverseStrictChildren 方法,比如 ApplyAnnotation 大哥
825
+ if (nd.traverseStrictChildren === undefined) {
826
+ return [];
827
+ }
828
+ // extract views
829
+ const views = new Array();
830
+ nd.concept === 'View' && views.push(nd);
831
+ !skipSubView && views.push(...(0, exports.getSubViews)(nd));
832
+ if (nd.concept === 'View' || nd.concept === 'BusinessComponent') {
833
+ this.curFileNode = nd;
834
+ env.viewAssocProcess = env.processV2ViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(nd)) ?? null;
835
+ }
816
836
  const res = new Array(); // 使用数组而不是 Map
817
837
  // specialization for speeding up
818
838
  const normalCb = (n) => {
819
839
  // 隐式引用 - 来自 __TypeAnnotation
820
840
  this.handleSymbolImplicitRefs(n);
821
- n.concept === 'ViewElement' && n.tag.startsWith('bs-') && this.handleBusinessComponentRefs(env, n);
841
+ if (n.concept === 'ViewElement') {
842
+ n.tag.startsWith('bs-') && this.handleBusinessComponentRefs(env, n);
843
+ n.bindRoles.length && this.handleBindRoles(env, n);
844
+ }
845
+ // 都特殊,样样都特殊
822
846
  n.concept === 'EntityProperty' && this.handleForeignKeyRef(env, n);
847
+ n.concept === 'AssigneeV2' && this.handleBindRoles(env, n);
823
848
  if (!symbol_type_1.refConcept.includes(n.concept)) {
824
849
  return;
825
850
  }
@@ -837,7 +862,9 @@ class ReferenceManager {
837
862
  n.concept === 'OqlQueryComponent' ||
838
863
  n.concept === 'FieldPermissionV2' ||
839
864
  // @ts-expect-error 临时 hack,下个版本应该把左侧 concept 改一改
840
- n.concept === 'NewComposite';
865
+ n.concept === 'NewComposite' ||
866
+ // 跳过子页面,但不能跳过自己
867
+ (skipSubView && n.concept === 'View' && n !== nd);
841
868
  // 会终止子树迭代
842
869
  const compositeNodeCb = (n) => {
843
870
  let qNameRefs = new Array();
@@ -857,7 +884,7 @@ class ReferenceManager {
857
884
  this.handleNewCompositeNode(n, res);
858
885
  // 右侧构成的引用
859
886
  qNameRefs = n.rights
860
- .flatMap(r => this.collectRefs(env, r));
887
+ .flatMap(r => this.collectRefs(env, r, true));
861
888
  break;
862
889
  case 'OqlQueryComponent':
863
890
  for (const qName of (0, oql_1.extractSymbolsFromOqlQueryComponent)(n)) {
@@ -878,8 +905,25 @@ class ReferenceManager {
878
905
  res.push([ref, qName]);
879
906
  }
880
907
  };
881
- // @ts-expect-error contra-variance errors
882
- visitChildrenWith(nd, normalCb, compositeNodePred, compositeNodeCb);
908
+ // 逐个处理嵌套的页面
909
+ if (views.length > 0) {
910
+ for (const v of views) {
911
+ v.bindRoles.length && this.handleBindRoles(env, v);
912
+ const lastViewAssocProcess = env.viewAssocProcess;
913
+ env.viewAssocProcess = env.processV2ViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(v)) ?? null;
914
+ const lastCurFileNode = this.curFileNode;
915
+ this.curFileNode = v;
916
+ // @ts-expect-error contra-variance errors
917
+ visitChildrenWith(v, normalCb, compositeNodePred, compositeNodeCb);
918
+ this.curFileNode = lastCurFileNode;
919
+ env.viewAssocProcess = lastViewAssocProcess;
920
+ }
921
+ }
922
+ else {
923
+ // 处理非页面
924
+ // @ts-expect-error contra-variance errors
925
+ visitChildrenWith(nd, normalCb, compositeNodePred, compositeNodeCb);
926
+ }
883
927
  // QFE 实在是没办法一致性处理
884
928
  if (nd.concept !== 'QueryFieldExpression') {
885
929
  // 过滤掉根节点
@@ -887,38 +931,20 @@ class ReferenceManager {
887
931
  }
888
932
  return res;
889
933
  };
890
- this.collectGlobalSubDefs = (nd) => {
891
- const res = new Map();
892
- res.set(nd, (0, get_q_name_1.getTokenQualifiedName)(nd));
893
- const cb = (n) => {
894
- if (!symbol_type_1.globalDefConcept.includes(n.concept)) {
895
- return;
896
- }
897
- const qName = (0, get_q_name_1.getTokenQualifiedName)(n);
898
- if (!qName) {
899
- return;
900
- }
901
- res.set(n, qName);
902
- };
903
- visitChildrenWith(nd, cb);
904
- return res;
905
- };
906
934
  /**
907
935
  * @warning Only handle global symbols
908
936
  * 仅清除全局符号的引用。外部优先调用此接口,不要直接调用 collectRefs
909
937
  * 不是说输入是 global symbol,而是说对于任何输入,只移除内部对 global symbol 的引用
938
+ * @param skipSubView 是否跳过子页面,增量场景调用较多,增量场景默认跳过
910
939
  */
911
- this.removeRefsForGlobalSym = (env, rmNd) => {
940
+ this.removeRefsForGlobalSym = (env, rmNd, skipSubView = true) => {
912
941
  this.curFileNode = rmNd;
913
942
  this.modeForCollect = "delete" /* Operation.Remove */;
914
- if (rmNd.concept === 'View' || rmNd.concept === 'BusinessComponent') {
915
- env.viewAssocProcess = env.processViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(rmNd)) ?? null;
916
- }
917
943
  if (rmNd.concept === 'ProcessV2') {
918
- env.processAssocBind = rmNd.bind;
944
+ env.processAssocEntity = rmNd.bind;
919
945
  }
920
946
  // const localVars = env.localVars.get(rmNd as any) ?? [];
921
- const refAndQNames = this.collectRefs(env, rmNd);
947
+ const refAndQNames = this.collectRefs(env, rmNd, skipSubView);
922
948
  for (const [ref, qName] of refAndQNames) {
923
949
  // if (localVars.includes(qName) || cheapTestLocalSymbol(qName)) {
924
950
  // continue;
@@ -939,36 +965,31 @@ class ReferenceManager {
939
965
  else if (rmNd.concept === 'BindAttribute' && !rmNd.expression && (0, update_nasl_fragment_1.isSpecialStringRefField)(rmNd.name)) {
940
966
  (0, update_nasl_fragment_1.removeBindAttrRef)(this, rmNd);
941
967
  }
942
- env.viewAssocProcess = null;
943
- env.processAssocBind = null;
968
+ env.processAssocEntity = null;
944
969
  };
945
970
  /**
946
971
  * @warning Only handle global symbols
947
972
  * 仅收集全局符号的引用。外部优先调用此接口,不要直接调用 collectRefs
948
973
  * 不是说输入是 global symbol,而是说对于任何输入,只收集内部对 global symbol 的引用
974
+ * @param skipSubView 是否跳过子页面,增量场景调用较多,增量场景默认跳过
949
975
  */
950
- this.addRefsForGlobalSym = (env, nd) => {
976
+ this.addRefsForGlobalSym = (env, nd, skipSubView = true) => {
951
977
  this.curFileNode = nd;
952
978
  this.modeForCollect = "create" /* Operation.Create */;
953
- if (nd.concept === 'View' || nd.concept === 'BusinessComponent') {
954
- // 如果是 null,则设置为 null,否则会报错
955
- env.viewAssocProcess = env.processViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(nd)) ?? null;
956
- }
957
979
  if (nd.concept === 'ProcessV2') {
958
- env.processAssocBind = nd.bind;
980
+ env.processAssocEntity = nd.bind;
959
981
  }
960
- const refAndQNames = this.collectRefs(env, nd);
982
+ const refAndQNames = this.collectRefs(env, nd, skipSubView);
961
983
  const localVars = env.localVars.get(nd) ?? [];
962
984
  for (const [ref, qName] of refAndQNames) {
963
- if (localVars.includes(qName) || cheapTestLocalSymbol(qName)) {
985
+ if (localVars.includes(qName) || (0, exports.cheapTestLocalSymbol)(qName)) {
964
986
  continue;
965
987
  }
966
988
  this.handleRefOp(env, "create" /* Operation.Create */, ref, qName);
967
989
  }
968
990
  this.modeForCollect = null;
969
991
  this.curFileNode = undefined;
970
- env.viewAssocProcess = null;
971
- env.processAssocBind = null;
992
+ env.processAssocEntity = null;
972
993
  };
973
994
  this.invalidateLocalSymCache = () => {
974
995
  this.isLocalCacheValid = false;
@@ -1031,8 +1052,8 @@ class ReferenceManager {
1031
1052
  if (qName) {
1032
1053
  // Handle process reference in view
1033
1054
  if (env.viewAssocProcess && env.viewAssocProcess.name === ids[0].name) {
1034
- const ctxLogic = (0, nasl_concepts_1.getCtxLogicLike)(nd);
1035
- const ctxViewLike = (0, nasl_concepts_1.getCtxViewLike)(nd);
1055
+ const ctxLogic = toRaw((0, nasl_concepts_1.getCtxLogicLike)(nd));
1056
+ const ctxViewLike = toRaw((0, nasl_concepts_1.getCtxViewLike)(nd));
1036
1057
  const logicVars = env.localVars.get(ctxLogic);
1037
1058
  const viewVars = env.localVars.get(ctxViewLike);
1038
1059
  // 哇,是 Process.data.XXX 特殊引用 && avoid shadowing
@@ -1052,7 +1073,7 @@ class ReferenceManager {
1052
1073
  }
1053
1074
  }
1054
1075
  }
1055
- const objDefQNames = this.collectRefs(env, id0); // 第一个可能是复杂表达式,再收集一次
1076
+ const objDefQNames = this.collectRefs(env, id0, false); // 第一个可能是复杂表达式,再收集一次
1056
1077
  objDefQNames.forEach(([ref, qName]) => {
1057
1078
  // @ts-expect-error
1058
1079
  res.push([ref, qName]);
@@ -1067,12 +1088,15 @@ class ReferenceManager {
1067
1088
  // 是这样的,为了兼容 processVariable.variable1,前面的是匿名数据结构,只需要 variable1 的引用就行了
1068
1089
  let ndDef = this.getNodeDef(ty);
1069
1090
  if (ndDef && (ndDef.concept === 'Entity' || ndDef.concept === 'Structure' || ndDef.concept === 'Enum')) {
1070
- const propQName = (0, get_q_name_1.getPropQName)(`${ty.typeNamespace}.${ty.typeName}`, ids[i + 1].name, 'Entity');
1091
+ const propQName = (0, string_2.getPropQName)(`${ty.typeNamespace}.${ty.typeName}`, ids[i + 1].name, 'Entity');
1071
1092
  res.push([ids[i + 1], propQName]); // type reference
1072
1093
  }
1073
1094
  else {
1074
- const propQName = (0, get_q_name_1.prependNonEmptyStr)((0, get_q_name_1.prependNonEmptyStr)(ty.typeNamespace, ty.typeName), ids[i + 1].name);
1075
- res.push([ids[i + 1], propQName]);
1095
+ // 局部无 namespace 的定义应该不可能通过 a.x.y 这种成员访问引用到
1096
+ if (ty.typeNamespace && ty.typeName) {
1097
+ const propQName = (0, string_1.prependNonEmptyStr)((0, string_1.prependNonEmptyStr)(ty.typeNamespace, ty.typeName), ids[i + 1].name);
1098
+ res.push([ids[i + 1], propQName]);
1099
+ }
1076
1100
  }
1077
1101
  // update next ty and nextProp name
1078
1102
  let nextProp = undefined;
@@ -1147,7 +1171,7 @@ class ReferenceManager {
1147
1171
  const entityDef = this.qNameDefs.get(`${eNsp}.${eAsName}`);
1148
1172
  entityDef && res.push([nd, entityQName]);
1149
1173
  if (entityDef && pName) {
1150
- const propQName = (0, get_q_name_1.getPropQName)(entityQName, pName, 'Entity');
1174
+ const propQName = (0, string_2.getPropQName)(entityQName, pName, 'Entity');
1151
1175
  const prop = getEntityProp(pName, entityDef);
1152
1176
  prop && res.push([nd, propQName]);
1153
1177
  }
@@ -1162,9 +1186,12 @@ class ReferenceManager {
1162
1186
  }
1163
1187
  return res;
1164
1188
  };
1189
+ /**
1190
+ * FieldPermissionV2 是对 Entity 和其属性的特殊引用
1191
+ */
1165
1192
  this.splitFieldPermissionV2 = (env, nd) => {
1166
1193
  const res = [];
1167
- const bind = env.processAssocBind;
1194
+ const bind = env.processAssocEntity;
1168
1195
  if (!bind) {
1169
1196
  return res;
1170
1197
  }
@@ -1176,7 +1203,7 @@ class ReferenceManager {
1176
1203
  ? (0, get_q_name_1.getTokenQualifiedName)(entityRef.typeAnnotation) // data 是 Entity
1177
1204
  : (0, get_q_name_1.getTokenQualifiedName)(entityRef.typeAnnotation.typeArguments[0]); // relation_data 是 List<Entity>
1178
1205
  for (const sub of nd.subFieldPermissions) {
1179
- res.push([sub, (0, get_q_name_1.getPropQName)(entityQName, sub.propertyName, 'Entity')]);
1206
+ res.push([sub, (0, string_2.getPropQName)(entityQName, sub.propertyName, 'Entity')]);
1180
1207
  }
1181
1208
  return res;
1182
1209
  };
@@ -1263,7 +1290,7 @@ class ReferenceManager {
1263
1290
  this.fastBuildQNameDefs(toRaw(app));
1264
1291
  console.timeEnd('\x1b[44m\x1b[97m Reference manager: Build Qualified Name to Definition Map \x1b[0m');
1265
1292
  }
1266
- buildSymbolRefsForApp(env, app, symbolGraph) {
1293
+ buildSymbolRefsForApp(env, app) {
1267
1294
  console.time('\x1b[44m\x1b[97m Reference manager: Build Symbol to Reference Map \x1b[0m');
1268
1295
  // symbolGraph && this.buildSymbolRefsFromSymbolGraph(symbolGraph); // 方舟的,后面可能不好修 bug 和维护
1269
1296
  app && this.slowBuildSymbolRefsForApp(env, toRaw(app));
@@ -1410,13 +1437,6 @@ const isEntitiesLogicsPath = (str) => {
1410
1437
  */
1411
1438
  const isEntityLogic = (nd) => nd?.concept === 'Logic' && nd.getNamespace && isEntitiesLogicsPath(nd.getNamespace());
1412
1439
  exports.isEntityLogic = isEntityLogic;
1413
- const lowercaseFirstChar = (str) => {
1414
- if (str.length === 0) {
1415
- return str; // Return an empty string if the input is empty
1416
- }
1417
- return str.charAt(0).toLowerCase() + str.slice(1);
1418
- };
1419
- exports.lowercaseFirstChar = lowercaseFirstChar;
1420
1440
  /**
1421
1441
  * 处理 CodeWave 编译器的一些连带的自动化行为,如自动生成 { abc: Abc } 这样的匿名结构体。
1422
1442
  * 这里实质上是否是引用?这里不是直接引用,但是 entityX 这个名字是从 EntityX 自动生成的,也可以看作是间接引用
@@ -1426,7 +1446,7 @@ exports.lowercaseFirstChar = lowercaseFirstChar;
1426
1446
  const handleEntityAutoRef = (ty, nextProp, ident) => {
1427
1447
  const nextTy = nextProp?.typeAnnotation;
1428
1448
  if (ty.typeKind === 'anonymousStructure' &&
1429
- nextProp?.name === (0, exports.lowercaseFirstChar)(nextTy?.typeName ?? '')) {
1449
+ nextProp?.name === (0, string_1.lowercaseFirstChar)(nextTy?.typeName ?? '')) {
1430
1450
  const entityQName = `${nextTy?.typeNamespace}.${nextTy?.typeName}`;
1431
1451
  return [ident, entityQName];
1432
1452
  }
@@ -1498,13 +1518,33 @@ const cheapTestLocalSymbol = (qName) => {
1498
1518
  qName.startsWith('nasl.collection')) {
1499
1519
  return true;
1500
1520
  }
1501
- // 页面下引用的 Process 的 qName
1502
- // if (qName.startsWith('Process_')) {
1503
- // return false;
1504
- // }
1521
+ // 页面下引用的 Process 的 qName,一般是 Process_uniqueKey 的 hash
1522
+ if (qName.startsWith('Process_')) {
1523
+ return false;
1524
+ }
1505
1525
  if (qName.indexOf('.') === -1) {
1506
1526
  return true;
1507
1527
  }
1508
1528
  return false;
1509
1529
  };
1530
+ exports.cheapTestLocalSymbol = cheapTestLocalSymbol;
1531
+ /**
1532
+ * 一个 FileNode 下面还可以有其他 FileNode 哦,其实没什么神秘的。
1533
+ * @warning 只会返回下属的 FileNode,不包含自己
1534
+ * @param node
1535
+ * @returns 下属 FileNodes,不包含自己
1536
+ */
1537
+ const getSubViews = (node) => {
1538
+ const result = [];
1539
+ if (node.concept === 'View') {
1540
+ node.children?.forEach((nd) => {
1541
+ if (nd.concept === 'View') {
1542
+ result.push(nd);
1543
+ result.push(...(0, exports.getSubViews)(nd));
1544
+ }
1545
+ });
1546
+ }
1547
+ return result;
1548
+ };
1549
+ exports.getSubViews = getSubViews;
1510
1550
  //# sourceMappingURL=reference-manager.js.map