@lcap/nasl-language-server-core 4.4.0-beta.33 → 4.4.0-beta.34

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.
@@ -1 +1 @@
1
- {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAC4C,QAAQ,EAC5B,IAAI,EAQ+E,GAAG,EAMxH,QAAQ,EAGT,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;AAYpE,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;AAOF,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,gBAA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KAAG,IAAI;;iBA6uFjD,MAAM;kBACL,MAAM;kBACN,MAAM;qBACH,MAAM;;kBAvpKF,UAAU,WAAW,MAAM,YAAY,YAAY;sCAg5D/B,IAAI,GAAG,QAAQ;2CA0yGxC,UAAU,gBACV,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,gBAC/C,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,qBACvB,MAAM,EAAE,oBACT,CAAC,YAAY,EAAE,UAAU,KAAK,UAAU,EAAE,KAC3D,kBAAkB,GAAG,IAAI;EAwF7B;AAqED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACrC,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1C;AAMD,eAAO,MAAM,6BAA6B,aAC9B,UAAU,+DAGnB,MAAM,gBAAgB,CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
package/out/checker.js CHANGED
@@ -285,6 +285,7 @@ function createErrorDiagnoser(context) {
285
285
  Param: 'getVarExistingNames',
286
286
  Return: 'getVarExistingNames',
287
287
  Variable: 'getVarExistingNames',
288
+ Identifier: 'getPropertyExistingNames',
288
289
  Enum: 'getEnumExistingNames',
289
290
  EnumItem: 'getEnumItemExistingNames',
290
291
  EnumItemInteger: 'getEnumItemExistingNames',
@@ -499,7 +500,8 @@ function createErrorDiagnoser(context) {
499
500
  conceptValidator = nasl_concepts_1.staticRules['EnumItemInteger'];
500
501
  validatorMapKey = 'EnumItemInteger';
501
502
  }
502
- else if (concept === 'StructureProperty' && node?.parentNode?.concept !== 'Structure') {
503
+ else if ((concept === 'StructureProperty' && node.parentNode?.concept !== 'Structure')
504
+ || (concept === 'Identifier' && node.parentNode?.concept === 'NewComposite')) {
503
505
  conceptValidator = nasl_concepts_1.staticRules['TypeStructureProperty'];
504
506
  validatorMapKey = 'TypeStructureProperty';
505
507
  }
@@ -792,24 +794,27 @@ function createErrorDiagnoser(context) {
792
794
  return false;
793
795
  }
794
796
  /**
795
- * 获取 ViewElement 的数据源类型(T 或 T1)
796
- * 参考 util.js 中的 getDataTypeOfViewElement 实现
797
+ * 获取 ViewElement 的数据源类型
798
+ * 基于 __ViewElementTV 中存储的 role === 'dataItem' 查找,优先返回有自有数据源的 dataItem。
797
799
  */
798
800
  function getDataSourceTypeAnnotation(viewElement) {
799
- // 向上查找定义了数据源类型的祖先组件
800
801
  let currentNode = viewElement;
801
802
  let depth = 0;
802
803
  const maxSearchDepth = 5;
803
804
  while (currentNode?.concept === 'ViewElement' && depth <= maxSearchDepth) {
804
- // 使用 __ViewElementTV 获取类型,与 IDE 前端 getDataTypeOfViewElement 保持一致
805
- if (currentNode.__TypeAnnotation && currentNode.__ViewElementTV?.length) {
806
- // 先查找 T1(动态列),若无再查找 T(普通数据源组件)
807
- const t1 = currentNode.__ViewElementTV.find((x) => x.rawName === 'T1');
808
- if (t1?.renamed)
809
- return t1.renamed;
810
- const t = currentNode.__ViewElementTV.find((x) => x.rawName === 'T');
811
- if (t?.renamed)
812
- return t.renamed;
805
+ if (currentNode.__ViewElementTV?.length) {
806
+ // 优先查找有自有数据源的 dataItem(如动态列的 T1)
807
+ for (const tv of currentNode.__ViewElementTV) {
808
+ if (tv.role === 'dataItem' && tv.hasOwnDataSource && tv.renamed) {
809
+ return tv.renamed;
810
+ }
811
+ }
812
+ // 兜底查找无自有数据源的 dataItem(如子组件继承的 T)
813
+ for (const tv of currentNode.__ViewElementTV) {
814
+ if (tv.role === 'dataItem' && tv.renamed) {
815
+ return tv.renamed;
816
+ }
817
+ }
813
818
  }
814
819
  currentNode = currentNode.parentNode;
815
820
  depth++;
@@ -4147,6 +4152,9 @@ function createErrorDiagnoser(context) {
4147
4152
  */
4148
4153
  function* checkNewList(node) {
4149
4154
  yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
4155
+ if (node.typeAnnotation) {
4156
+ yield* checkNode(node.typeAnnotation);
4157
+ }
4150
4158
  // 匿名函数返回值有可能是newList,需要过滤。代码来源:AnonymousFunction.__ts
4151
4159
  const grandParent = node.parentNode?.parentNode?.parentNode;
4152
4160
  if (isEntityUpdate(grandParent)) {
@@ -4184,6 +4192,9 @@ function createErrorDiagnoser(context) {
4184
4192
  */
4185
4193
  function* checkNewMap(node) {
4186
4194
  yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
4195
+ if (node.typeAnnotation) {
4196
+ yield* checkNode(node.typeAnnotation);
4197
+ }
4187
4198
  if (node.keys?.length) {
4188
4199
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.keys, function* (node) {
4189
4200
  yield* checkNode(node);
@@ -4222,6 +4233,9 @@ function createErrorDiagnoser(context) {
4222
4233
  */
4223
4234
  function* checkNewComposite(node) {
4224
4235
  yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
4236
+ if (node.typeAnnotation) {
4237
+ yield* checkNode(node.typeAnnotation);
4238
+ }
4225
4239
  ensureNodeKeyExists(node, 'typeAnnotation');
4226
4240
  const type = env.getType(node);
4227
4241
  if (node.properties?.length) {