@lcap/nasl-language-server-core 4.0.0-beta.12 → 4.0.0-beta.14

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 (92) hide show
  1. package/out/checker.d.ts.map +1 -1
  2. package/out/checker.js +55 -25
  3. package/out/checker.js.map +1 -1
  4. package/out/module/graph.js +6 -6
  5. package/out/module/graph.js.map +1 -1
  6. package/out/module/module.d.ts.map +1 -1
  7. package/out/module/module.js +3 -6
  8. package/out/module/module.js.map +1 -1
  9. package/out/reference-manager/builtin-q-name.d.ts +8 -1
  10. package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
  11. package/out/reference-manager/builtin-q-name.js +55 -1
  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 +2 -1
  15. package/out/reference-manager/collect-q-name.js.map +1 -1
  16. package/out/reference-manager/reference-manager.d.ts +12 -6
  17. package/out/reference-manager/reference-manager.d.ts.map +1 -1
  18. package/out/reference-manager/reference-manager.js +177 -112
  19. package/out/reference-manager/reference-manager.js.map +1 -1
  20. package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
  21. package/out/reference-manager/update-nasl-fragment.js +5 -4
  22. package/out/reference-manager/update-nasl-fragment.js.map +1 -1
  23. package/out/symbol/graph.js +2 -2
  24. package/out/symbol/graph.js.map +1 -1
  25. package/out/typer/collectGlobalDefs.d.ts.map +1 -1
  26. package/out/typer/collectGlobalDefs.js +79 -15
  27. package/out/typer/collectGlobalDefs.js.map +1 -1
  28. package/out/typer/component-def-manager/component-def-manager.d.ts +11 -7
  29. package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
  30. package/out/typer/component-def-manager/component-def-manager.js +17 -6
  31. package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
  32. package/out/typer/dispatch-def.js +3 -3
  33. package/out/typer/dispatch-def.js.map +1 -1
  34. package/out/typer/dispatch-expr.d.ts.map +1 -1
  35. package/out/typer/dispatch-expr.js +32 -43
  36. package/out/typer/dispatch-expr.js.map +1 -1
  37. package/out/typer/dispatch-process.js +1 -2
  38. package/out/typer/dispatch-process.js.map +1 -1
  39. package/out/typer/dispatch-stmt.d.ts.map +1 -1
  40. package/out/typer/dispatch-stmt.js +12 -4
  41. package/out/typer/dispatch-stmt.js.map +1 -1
  42. package/out/typer/dispatch-view.d.ts.map +1 -1
  43. package/out/typer/dispatch-view.js +73 -19
  44. package/out/typer/dispatch-view.js.map +1 -1
  45. package/out/typer/incremental-update.d.ts +6 -29
  46. package/out/typer/incremental-update.d.ts.map +1 -1
  47. package/out/typer/incremental-update.js +126 -214
  48. package/out/typer/incremental-update.js.map +1 -1
  49. package/out/typer/index.d.ts +2 -3
  50. package/out/typer/index.d.ts.map +1 -1
  51. package/out/typer/index.js +2 -4
  52. package/out/typer/index.js.map +1 -1
  53. package/out/typer/sem-diag.d.ts +1 -0
  54. package/out/typer/sem-diag.d.ts.map +1 -1
  55. package/out/typer/sem-diag.js +24 -17
  56. package/out/typer/sem-diag.js.map +1 -1
  57. package/out/typer/solver.d.ts +1 -0
  58. package/out/typer/solver.d.ts.map +1 -1
  59. package/out/typer/solver.js +9 -1
  60. package/out/typer/solver.js.map +1 -1
  61. package/out/typer/subster.d.ts +3 -3
  62. package/out/typer/subster.d.ts.map +1 -1
  63. package/out/typer/subster.js +20 -9
  64. package/out/typer/subster.js.map +1 -1
  65. package/out/typer/type-manager.d.ts +1 -2
  66. package/out/typer/type-manager.d.ts.map +1 -1
  67. package/out/typer/type-manager.js +18 -12
  68. package/out/typer/type-manager.js.map +1 -1
  69. package/out/typer/typer.d.ts +15 -3
  70. package/out/typer/typer.d.ts.map +1 -1
  71. package/out/typer/typer.js +22 -6
  72. package/out/typer/typer.js.map +1 -1
  73. package/out/typer/unifier.d.ts.map +1 -1
  74. package/out/typer/unifier.js +12 -2
  75. package/out/typer/unifier.js.map +1 -1
  76. package/out/utils/parseTsClassType.d.ts +2 -0
  77. package/out/utils/parseTsClassType.d.ts.map +1 -1
  78. package/out/utils/parseTsClassType.js +4 -2
  79. package/out/utils/parseTsClassType.js.map +1 -1
  80. package/out/utils/type-operator.d.ts +1 -1
  81. package/out/utils/type-operator.d.ts.map +1 -1
  82. package/out/utils/type-operator.js +18 -3
  83. package/out/utils/type-operator.js.map +1 -1
  84. package/package.json +5 -6
  85. package/out/utils/vue-hack.d.ts +0 -25
  86. package/out/utils/vue-hack.d.ts.map +0 -1
  87. package/out/utils/vue-hack.js +0 -33
  88. package/out/utils/vue-hack.js.map +0 -1
  89. package/out/utils/vue.d.ts +0 -2
  90. package/out/utils/vue.d.ts.map +0 -1
  91. package/out/utils/vue.js +0 -10
  92. package/out/utils/vue.js.map +0 -1
@@ -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,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,EA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AGD,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;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
@@ -803,7 +803,7 @@ function createErrorDiagnoser(context) {
803
803
  /**
804
804
  * 检查 调用表达式的参数
805
805
  * @param node
806
- * @param ref
806
+ *( @param r) as anyef
807
807
  */
808
808
  function* checkCallExpressionParameters(node, ref) {
809
809
  // Handle both TypeAnnotation and FunctionDefinition formats
@@ -1866,6 +1866,7 @@ function createErrorDiagnoser(context) {
1866
1866
  ...(node.variables || []),
1867
1867
  ...(node.logics || []),
1868
1868
  ]);
1869
+ checkVariableAndReturnTypeAnnotations(node.variables, [], false);
1869
1870
  const module = node.getAncestor('Module');
1870
1871
  if (!(module?.parentKey === 'dependencies')) {
1871
1872
  if (node.params?.length) {
@@ -1996,6 +1997,21 @@ function createErrorDiagnoser(context) {
1996
1997
  if (node._foldInView) {
1997
1998
  error(node, `组件${node.name}已经极速折叠`);
1998
1999
  }
2000
+ // 已知:选择器会漏报,因为 children 里是两个空 template。暂时先这样吧。
2001
+ let dsFilled = true;
2002
+ let errNode = node;
2003
+ const ds = node.bindAttrs.find(nd => nd.name === 'dataSource');
2004
+ if (ds) {
2005
+ if (ds.type === 'dynamic' && !ds.expression) {
2006
+ dsFilled = false;
2007
+ errNode = ds;
2008
+ }
2009
+ }
2010
+ const hasSubComponents = node.children.filter(c => c.tag !== 'template').length > 0 ||
2011
+ node.children.filter(c => c.tag === 'template').some(cc => cc.children.length > 0);
2012
+ if (!dsFilled && !hasSubComponents) {
2013
+ error(errNode, '数据源不能为空');
2014
+ }
1999
2015
  unbindVariables?.();
2000
2016
  }
2001
2017
  /**
@@ -2016,11 +2032,6 @@ function createErrorDiagnoser(context) {
2016
2032
  }
2017
2033
  yield* checkPlayground(node.playground);
2018
2034
  yield* checkBindExpressions(node);
2019
- if (node?.name === 'dataSource') {
2020
- if (node.type === 'dynamic' && !node.expression) {
2021
- error(node, '数据源绑定表达式不能为空');
2022
- }
2023
- }
2024
2035
  // 检查不可复制属性开启双向绑定
2025
2036
  if ((node.model || node.sync) && node.expression) {
2026
2037
  const bindExpression = node.expression;
@@ -2742,23 +2753,27 @@ function createErrorDiagnoser(context) {
2742
2753
  return;
2743
2754
  }
2744
2755
  yield* checkVoidCallUsedAsStatement(node);
2745
- const ref = env.resolvedCallInfo.get(node) ?? env.resolveRef(node);
2746
- const typeUnresolved = ref.ret
2747
- ? (0, type_manager_1.hasUnresolvedTyInCallInfo)(ref) // 其他
2748
- : (0, type_predicate_1.isUnResolvedTy)(ref); // 前端页面,TODO: 需要统一处理
2749
- if (ref) {
2750
- yield* checkScopeOfUse(node, ref);
2751
- yield* checkCallExpressionParameters(node, ref);
2752
- }
2753
- else {
2754
- if (ref.depLibName) {
2755
- error(node, `找不到依赖库 ${ref.depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2756
+ const ref = env.resolveRef(node); // 前端
2757
+ // TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
2758
+ // 暂时不在 qNameDefs 里,用 isBuiltInCall 简单判断了
2759
+ if (!ref && !isBuiltInCall(node)) {
2760
+ const depLibName = getExtensionLibName(node);
2761
+ if (depLibName) {
2762
+ error(node, `找不到依赖库 ${depLibName} 上的 ${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2756
2763
  }
2757
- else if (!typeUnresolved) { // 排除未求解出类型变元等引发的报错,这些不应该报 '找不到'
2764
+ else {
2758
2765
  error(node, `找不到${getExpressionNodeName(node.concept)} ${node.calleeName}。`);
2759
2766
  }
2760
2767
  return errorType;
2761
2768
  }
2769
+ /**
2770
+ * 目前的 callInfo:所有内置函数 + 服务端调用。前端因为有组件库调用,还没统一
2771
+ * 排除未求解出类型变元等引发的报错,这些不应该报 '找不到'
2772
+ */
2773
+ // FIXME: wudengke 帮帮忙,行行好
2774
+ const callInfo = env.resolvedCallInfo.get(node);
2775
+ yield* checkScopeOfUse(node, (callInfo ?? ref));
2776
+ yield* checkCallExpressionParameters(node, (callInfo ?? ref));
2762
2777
  switch (node.concept) {
2763
2778
  case 'CallFunction':
2764
2779
  return yield* checkCallFunction(node);
@@ -3131,18 +3146,29 @@ function createErrorDiagnoser(context) {
3131
3146
  }
3132
3147
  });
3133
3148
  }
3149
+ else if (!isOtherCase(node)) {
3150
+ // pattern 为空时,如果不是其他就报错
3151
+ error(node, '匹配分支:匹配模式不能为空', {
3152
+ titleTip: '匹配模式不能为空',
3153
+ });
3154
+ }
3134
3155
  if (node.body?.length) {
3135
3156
  yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.body, function* (node) {
3136
3157
  yield* checkNode(node);
3137
3158
  });
3138
3159
  }
3139
- if (match?.isExpression && node.body.length === 0) {
3140
- // 如果不是其他就标红
3141
- if (node?.getIndexOfParent() !== (match?.cases?.length || 0) - 1) {
3142
- error(node, '匹配分支:返回内容不能为空', {
3143
- titleTip: '返回内容不能为空',
3144
- });
3160
+ if (match?.isExpression && node.body.length === 0 && !isOtherCase(node)) {
3161
+ // 如果不是其他就报错
3162
+ error(node, '匹配分支:返回内容不能为空', {
3163
+ titleTip: '返回内容不能为空',
3164
+ });
3165
+ }
3166
+ function isOtherCase(node) {
3167
+ const indexInParent = node.getIndexOfParent();
3168
+ if (indexInParent === -1) {
3169
+ return false;
3145
3170
  }
3171
+ return indexInParent === match.cases.length - 1;
3146
3172
  }
3147
3173
  }
3148
3174
  /**
@@ -4257,7 +4283,7 @@ function createErrorDiagnoser(context) {
4257
4283
  function setMetadataTypeEnable(enable) {
4258
4284
  metadataTypeEnable = enable;
4259
4285
  }
4260
- const checkVariableAndReturnTypeAnnotations = (variables, returns) => {
4286
+ const checkVariableAndReturnTypeAnnotations = (variables, returns, inLogic = true) => {
4261
4287
  for (const v of variables) {
4262
4288
  if (v.typeAnnotation)
4263
4289
  continue;
@@ -4368,4 +4394,8 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
4368
4394
  exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
4369
4395
  // @ts-expect-error
4370
4396
  const toRaw = (nd) => nd.__v_raw ?? nd;
4397
+ // 是否来自系统内置
4398
+ const isBuiltInCall = (nd) => nd.calleeNamespace.startsWith('nasl.');
4399
+ // 是否来自依赖库
4400
+ const getExtensionLibName = (nd) => nd.calleeNamespace.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
4371
4401
  //# sourceMappingURL=checker.js.map