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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/out/checker.d.ts.map +1 -1
  2. package/out/checker.js +20 -13
  3. package/out/checker.js.map +1 -1
  4. package/out/index.d.ts +1 -0
  5. package/out/index.d.ts.map +1 -1
  6. package/out/index.js +1 -0
  7. package/out/index.js.map +1 -1
  8. package/out/reference-manager/collect-q-name.js +1 -1
  9. package/out/reference-manager/collect-q-name.js.map +1 -1
  10. package/out/reference-manager/get-q-name.d.ts +1 -1
  11. package/out/reference-manager/get-q-name.d.ts.map +1 -1
  12. package/out/reference-manager/get-q-name.js +4 -4
  13. package/out/reference-manager/get-q-name.js.map +1 -1
  14. package/out/reference-manager/reference-manager.d.ts +8 -8
  15. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  16. package/out/reference-manager/reference-manager.js +56 -17
  17. package/out/reference-manager/reference-manager.js.map +1 -1
  18. package/out/reference-manager/remove-q-name.js +1 -1
  19. package/out/reference-manager/remove-q-name.js.map +1 -1
  20. package/out/typer/component-def-manager/component-def-manager.d.ts +11 -3
  21. package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
  22. package/out/typer/component-def-manager/component-def-manager.js +79 -18
  23. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  24. package/out/typer/component-def-manager/utils.d.ts.map +1 -1
  25. package/out/typer/component-def-manager/utils.js +6 -0
  26. package/out/typer/component-def-manager/utils.js.map +1 -1
  27. package/out/typer/dispatch-all.js +1 -1
  28. package/out/typer/dispatch-all.js.map +1 -1
  29. package/out/typer/dispatch-def.d.ts.map +1 -1
  30. package/out/typer/dispatch-def.js +12 -5
  31. package/out/typer/dispatch-def.js.map +1 -1
  32. package/out/typer/dispatch-expr.d.ts.map +1 -1
  33. package/out/typer/dispatch-expr.js +37 -22
  34. package/out/typer/dispatch-expr.js.map +1 -1
  35. package/out/typer/dispatch-process.d.ts.map +1 -1
  36. package/out/typer/dispatch-process.js +3 -2
  37. package/out/typer/dispatch-process.js.map +1 -1
  38. package/out/typer/dispatch-stmt.js +4 -4
  39. package/out/typer/dispatch-stmt.js.map +1 -1
  40. package/out/typer/dispatch-view.d.ts.map +1 -1
  41. package/out/typer/dispatch-view.js +24 -8
  42. package/out/typer/dispatch-view.js.map +1 -1
  43. package/out/typer/incremental-update.d.ts.map +1 -1
  44. package/out/typer/incremental-update.js +104 -71
  45. package/out/typer/incremental-update.js.map +1 -1
  46. package/out/typer/subster.d.ts.map +1 -1
  47. package/out/typer/subster.js +5 -9
  48. package/out/typer/subster.js.map +1 -1
  49. package/out/typer/type-hint-manager/type-hint-manager.d.ts +1 -1
  50. package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +1 -1
  51. package/out/typer/type-hint-manager/type-hint-manager.js +4 -4
  52. package/out/typer/type-hint-manager/type-hint-manager.js.map +1 -1
  53. package/out/typer/type-manager.d.ts +2 -1
  54. package/out/typer/type-manager.d.ts.map +1 -1
  55. package/out/typer/type-manager.js +35 -3
  56. package/out/typer/type-manager.js.map +1 -1
  57. package/out/typer/type-predicate.d.ts +2 -0
  58. package/out/typer/type-predicate.d.ts.map +1 -1
  59. package/out/typer/type-predicate.js +6 -5
  60. package/out/typer/type-predicate.js.map +1 -1
  61. package/out/typer/typer.d.ts +11 -0
  62. package/out/typer/typer.d.ts.map +1 -1
  63. package/out/typer/typer.js +30 -10
  64. package/out/typer/typer.js.map +1 -1
  65. package/out/typer/unifier.d.ts +3 -1
  66. package/out/typer/unifier.d.ts.map +1 -1
  67. package/out/typer/unifier.js +26 -52
  68. package/out/typer/unifier.js.map +1 -1
  69. package/out/utils/error-boundary.d.ts +1 -1
  70. package/out/utils/error-boundary.d.ts.map +1 -1
  71. package/out/utils/error-boundary.js +14 -13
  72. package/out/utils/error-boundary.js.map +1 -1
  73. package/out/utils/file-node-cache.d.ts +12 -0
  74. package/out/utils/file-node-cache.d.ts.map +1 -0
  75. package/out/utils/file-node-cache.js +30 -0
  76. package/out/utils/file-node-cache.js.map +1 -0
  77. package/out/utils/type-operator.d.ts +5 -5
  78. package/out/utils/type-operator.d.ts.map +1 -1
  79. package/out/utils/type-operator.js +50 -26
  80. package/out/utils/type-operator.js.map +1 -1
  81. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU0F,GAAG,EAMvG,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACgE,cAAc,EAGpF,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhE,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,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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C,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,6BAA6B,aAAc,UAAU,sCAAoC,MAAM,gBAAgB,CAmC3H,CAAA;AAMD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
package/out/checker.js CHANGED
@@ -4,6 +4,7 @@ exports.transformDiagnosticsToRecords = exports.createErrorDiagnoser = exports.S
4
4
  const decimal_js_1 = require("decimal.js");
5
5
  const nasl_concepts_1 = require("@lcap/nasl-concepts");
6
6
  const service_1 = require("@lcap/nasl-concepts/service");
7
+ const file_node_cache_1 = require("./utils/file-node-cache");
7
8
  const nasl_utils_1 = require("@lcap/nasl-utils");
8
9
  const typer_1 = require("./typer");
9
10
  const type_predicate_1 = require("./typer/type-predicate");
@@ -91,7 +92,7 @@ function getExpressionNodeName(concept) {
91
92
  function isDescendant(node, rangeNode) {
92
93
  let currentNode = node;
93
94
  while (currentNode) {
94
- if (currentNode === rangeNode) {
95
+ if (toRaw(currentNode) === toRaw(rangeNode)) {
95
96
  return true;
96
97
  }
97
98
  currentNode = currentNode.parentNode;
@@ -671,7 +672,7 @@ function createErrorDiagnoser(context) {
671
672
  // 允许在当前业务组件中访问
672
673
  businessComponent,
673
674
  ],
674
- errMsg: `“${node.name}”是私有的,只能在“${businessComponent.name}”中访问。`,
675
+ errMsg: `"${node.name}"是私有的,只能在"${businessComponent.name}"中访问。`,
675
676
  } : null;
676
677
  case 'ConfigProperty':
677
678
  return node.isPrivate ? {
@@ -1094,8 +1095,8 @@ function createErrorDiagnoser(context) {
1094
1095
  const status = getStatusOfSharedApp(node);
1095
1096
  if (status) {
1096
1097
  const msgMap = {
1097
- update: `共享数据 ${node.name} 已在“${node.provider}应用”中更新,请同步更新`,
1098
- delete: `共享数据 ${node.name} 已在“${node.provider}应用”中被删除,请同步删除`,
1098
+ update: `共享数据 ${node.name} 已在"${node.provider}应用"中更新,请同步更新`,
1099
+ delete: `共享数据 ${node.name} 已在"${node.provider}应用"中被删除,请同步删除`,
1099
1100
  };
1100
1101
  error(node, msgMap[status], {
1101
1102
  severity: Severity.WARN,
@@ -2731,19 +2732,27 @@ function createErrorDiagnoser(context) {
2731
2732
  }
2732
2733
  yield* checkVoidCallUsedAsStatement(node);
2733
2734
  const ref = env.resolvedCallInfo.get(node) ?? env.resolveRef(node);
2735
+ const typeUnresolved = ref.ret
2736
+ ? (0, type_manager_1.hasUnresolvedTyInCallInfo)(ref) // 其他
2737
+ : (0, type_predicate_1.isUnResolvedTy)(ref); // 前端页面,TODO: 需要统一处理
2734
2738
  // Handle the new FunctionDefinition structure
2735
- if (ref?.params && !(0, type_manager_1.hasUnresolvedTyInCallInfo)(ref)) {
2739
+ if (ref?.params && !typeUnresolved) {
2736
2740
  // It's a FunctionDefinition object
2737
2741
  yield* checkScopeOfUse(node, ref);
2738
2742
  yield* checkCallExpressionParameters(node, ref);
2739
2743
  }
2740
- else if (ref && !(0, type_predicate_1.isUnResolvedTy)(ref)) {
2744
+ else if (ref && !typeUnresolved) {
2741
2745
  // 检查使用范围
2742
2746
  yield* checkScopeOfUse(node, ref);
2743
2747
  yield* checkCallExpressionParameters(node, ref);
2744
2748
  }
2745
2749
  else {
2746
- error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2750
+ if (ref.depLibName) {
2751
+ error(node, `找不到依赖库 ${ref.depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2752
+ }
2753
+ else {
2754
+ error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2755
+ }
2747
2756
  return errorType;
2748
2757
  }
2749
2758
  switch (node.concept) {
@@ -3481,7 +3490,7 @@ function createErrorDiagnoser(context) {
3481
3490
  if (ensureNodeKeyExists(node, 'members')) {
3482
3491
  if (node.members?.length) {
3483
3492
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.members, function* (node) {
3484
- yield* checkNode(node);
3493
+ yield* checkNode(toRaw(node));
3485
3494
  });
3486
3495
  }
3487
3496
  }
@@ -3883,7 +3892,7 @@ function createErrorDiagnoser(context) {
3883
3892
  }
3884
3893
  // 元数据
3885
3894
  if (!metadataTypeEnable && node.typeNamespace?.endsWith('.metadataTypes')) {
3886
- error(node, '未启用元数据功能,请在“偏好设置”中启用元数据。');
3895
+ error(node, '未启用元数据功能,请在"偏好设置"中启用元数据。');
3887
3896
  }
3888
3897
  if (node.typeArguments?.length) {
3889
3898
  // 有同名的
@@ -4201,8 +4210,8 @@ function createErrorDiagnoser(context) {
4201
4210
  * @returns 清理函数
4202
4211
  */
4203
4212
  function handleFileNode(node) {
4204
- // TODO: checkNodeIsFileModuleInIde 也慢,后续可以优化
4205
- const isFileModule = fileNodes.length ? (0, service_1.checkNodeIsFileModuleInIde)(node) : true;
4213
+ // TODO: checkNodeIsFileModuleInIdeWithCache 也慢,后续可以优化
4214
+ const isFileModule = fileNodes.length ? (0, file_node_cache_1.checkNodeIsFileModuleInIdeWithCache)(node) : true;
4206
4215
  if (isFileModule) {
4207
4216
  fileNodes.push(node);
4208
4217
  let diagnostics = diagnosticMap.get(node);
@@ -4258,10 +4267,8 @@ function createErrorDiagnoser(context) {
4258
4267
  nodeNameCache.clear();
4259
4268
  if (node) {
4260
4269
  const diagnostics = diagnosticMap.get(node);
4261
- console.log(diagnosticMap);
4262
4270
  diagnostics?.forEach((value, node) => {
4263
4271
  if (node) {
4264
- console.log(node);
4265
4272
  node.tsErrorDetail = null;
4266
4273
  // 如果logic中有报错就把标识置为true
4267
4274
  if (node?.logic?.haveError) {