@lcap/nasl 2.18.0-beta.7 → 2.19.0-beta.1

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 (265) hide show
  1. package/out/automate/template/myProcess.js +1 -1
  2. package/out/automate/template/myProcess.js.map +1 -1
  3. package/out/bak/translator.js +2 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/Command.d.ts +1 -0
  6. package/out/common/Command.js +5 -1
  7. package/out/common/Command.js.map +1 -1
  8. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  9. package/out/concepts/AnonymousFunction__.js +40 -2
  10. package/out/concepts/AnonymousFunction__.js.map +1 -1
  11. package/out/concepts/App__.d.ts +10 -0
  12. package/out/concepts/App__.js +132 -0
  13. package/out/concepts/App__.js.map +1 -1
  14. package/out/concepts/Assignee__.js +4 -3
  15. package/out/concepts/Assignee__.js.map +1 -1
  16. package/out/concepts/BatchAssignment__.d.ts +2 -0
  17. package/out/concepts/BatchAssignment__.js +45 -1
  18. package/out/concepts/BatchAssignment__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +8 -1
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/CallFunction__.js +51 -18
  22. package/out/concepts/CallFunction__.js.map +1 -1
  23. package/out/concepts/CallInterface__.js +6 -4
  24. package/out/concepts/CallInterface__.js.map +1 -1
  25. package/out/concepts/CallLogic__.js +87 -15
  26. package/out/concepts/CallLogic__.js.map +1 -1
  27. package/out/concepts/CallQueryComponent__.js +4 -1
  28. package/out/concepts/CallQueryComponent__.js.map +1 -1
  29. package/out/concepts/DataSource__.d.ts +2 -0
  30. package/out/concepts/DataSource__.js +55 -1
  31. package/out/concepts/DataSource__.js.map +1 -1
  32. package/out/concepts/ForEachStatement__.js +2 -0
  33. package/out/concepts/ForEachStatement__.js.map +1 -1
  34. package/out/concepts/Identifier__.d.ts +1 -0
  35. package/out/concepts/Identifier__.js +18 -7
  36. package/out/concepts/Identifier__.js.map +1 -1
  37. package/out/concepts/LogicItem__.d.ts +1 -1
  38. package/out/concepts/LogicItem__.js.map +1 -1
  39. package/out/concepts/Logic__.d.ts +1 -0
  40. package/out/concepts/Logic__.js +27 -14
  41. package/out/concepts/Logic__.js.map +1 -1
  42. package/out/concepts/Match__.js +13 -8
  43. package/out/concepts/Match__.js.map +1 -1
  44. package/out/concepts/NewComposite__.d.ts +345 -0
  45. package/out/concepts/NewComposite__.js +1067 -0
  46. package/out/concepts/NewComposite__.js.map +1 -0
  47. package/out/concepts/NewList__.d.ts +130 -0
  48. package/out/concepts/NewList__.js +353 -0
  49. package/out/concepts/NewList__.js.map +1 -0
  50. package/out/concepts/NewMap__.d.ts +221 -0
  51. package/out/concepts/NewMap__.js +492 -0
  52. package/out/concepts/NewMap__.js.map +1 -0
  53. package/out/concepts/New__.d.ts +19 -0
  54. package/out/concepts/New__.js +66 -0
  55. package/out/concepts/New__.js.map +1 -0
  56. package/out/concepts/Param__.d.ts +2 -0
  57. package/out/concepts/Param__.js +40 -3
  58. package/out/concepts/Param__.js.map +1 -1
  59. package/out/concepts/ProcessElement__.js +31 -10
  60. package/out/concepts/ProcessElement__.js.map +1 -1
  61. package/out/concepts/ProcessOutcome__.js +1 -1
  62. package/out/concepts/ProcessOutcome__.js.map +1 -1
  63. package/out/concepts/ProcessOutcomes__.d.ts +30 -0
  64. package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
  65. package/out/concepts/ProcessOutcomes__.js.map +1 -0
  66. package/out/concepts/Return__.js +2 -1
  67. package/out/concepts/Return__.js.map +1 -1
  68. package/out/concepts/SelectMembers__.js +3 -3
  69. package/out/concepts/SelectMembers__.js.map +1 -1
  70. package/out/concepts/StringInterpolation__.js +12 -2
  71. package/out/concepts/StringInterpolation__.js.map +1 -1
  72. package/out/concepts/TypeAnnotation__.d.ts +4 -0
  73. package/out/concepts/TypeAnnotation__.js +66 -12
  74. package/out/concepts/TypeAnnotation__.js.map +1 -1
  75. package/out/concepts/ValidationRule__.js +1 -1
  76. package/out/concepts/ValidationRule__.js.map +1 -1
  77. package/out/concepts/Variable__.js +2 -1
  78. package/out/concepts/Variable__.js.map +1 -1
  79. package/out/concepts/ViewElement__.js +12 -0
  80. package/out/concepts/ViewElement__.js.map +1 -1
  81. package/out/concepts/View__.d.ts +1 -0
  82. package/out/concepts/View__.js +9 -0
  83. package/out/concepts/View__.js.map +1 -1
  84. package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
  85. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  86. package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
  87. package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
  88. package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
  89. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  90. package/out/concepts/basics/stdlib/nasl.util.js +151 -19
  91. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  92. package/out/concepts/index__.d.ts +5 -0
  93. package/out/concepts/index__.js +5 -0
  94. package/out/concepts/index__.js.map +1 -1
  95. package/out/enums/KEYWORDS.js +1 -0
  96. package/out/enums/KEYWORDS.js.map +1 -1
  97. package/out/generator/genMetaData.js +1 -6
  98. package/out/generator/genMetaData.js.map +1 -1
  99. package/out/generator/genReleaseBody.d.ts +2 -0
  100. package/out/generator/genReleaseBody.js +18 -1
  101. package/out/generator/genReleaseBody.js.map +1 -1
  102. package/out/generator/index.d.ts +1 -0
  103. package/out/generator/index.js +1 -0
  104. package/out/generator/index.js.map +1 -1
  105. package/out/generator/permission.d.ts +9 -0
  106. package/out/generator/permission.js +235 -0
  107. package/out/generator/permission.js.map +1 -0
  108. package/out/index.d.ts +1 -1
  109. package/out/index.js +2 -1
  110. package/out/index.js.map +1 -1
  111. package/out/server/entity2LogicNamespace.js +69 -9
  112. package/out/server/entity2LogicNamespace.js.map +1 -1
  113. package/out/server/extendBaseNode.js +7 -3
  114. package/out/server/extendBaseNode.js.map +1 -1
  115. package/out/server/formatTsUtils.js +6 -0
  116. package/out/server/formatTsUtils.js.map +1 -1
  117. package/out/server/getLogics.d.ts +2 -1
  118. package/out/server/getLogics.js +11 -0
  119. package/out/server/getLogics.js.map +1 -1
  120. package/out/server/getMemberIdentifier.js +1 -1
  121. package/out/server/getMemberIdentifier.js.map +1 -1
  122. package/out/server/naslServer.d.ts +1 -1
  123. package/out/server/naslServer.js +161 -22
  124. package/out/server/naslServer.js.map +1 -1
  125. package/out/server/process2LogicNamespace.js +8 -0
  126. package/out/server/process2LogicNamespace.js.map +1 -1
  127. package/out/server/translator.js +53 -8
  128. package/out/server/translator.js.map +1 -1
  129. package/out/service/creator/add.configs.js +4 -0
  130. package/out/service/creator/add.configs.js.map +1 -1
  131. package/out/service/datasource/api.d.ts +12 -0
  132. package/out/service/datasource/api.js +14 -0
  133. package/out/service/datasource/api.js.map +1 -0
  134. package/out/service/datasource/index.d.ts +2 -0
  135. package/out/service/datasource/index.js +10 -0
  136. package/out/service/datasource/index.js.map +1 -0
  137. package/out/service/storage/init.js +8 -1
  138. package/out/service/storage/init.js.map +1 -1
  139. package/out/templator/genEditTableBlock.js +4 -5
  140. package/out/templator/genEditTableBlock.js.map +1 -1
  141. package/out/templator/genGetBlock.js +4 -3
  142. package/out/templator/genGetBlock.js.map +1 -1
  143. package/out/templator/genGridViewBlock.js +16 -14
  144. package/out/templator/genGridViewBlock.js.map +1 -1
  145. package/out/templator/genListViewBlock.js +5 -5
  146. package/out/templator/genListViewBlock.js.map +1 -1
  147. package/out/templator/genTableBlock.js +6 -10
  148. package/out/templator/genTableBlock.js.map +1 -1
  149. package/package.json +1 -1
  150. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  151. package/sandbox/stdlib/nasl.auth.ts +1 -1
  152. package/sandbox/stdlib/nasl.core.ts +4 -0
  153. package/sandbox/stdlib/nasl.logging.ts +4 -4
  154. package/sandbox/stdlib/nasl.util.ts +13 -4
  155. package/src/automate/template/myProcess.js +1 -1
  156. package/src/bak/translator.js +4 -1
  157. package/src/common/Command.ts +4 -0
  158. package/src/concepts/AnonymousFunction__.ts +48 -2
  159. package/src/concepts/App__.ts +140 -41
  160. package/src/concepts/Assignee__.ts +4 -3
  161. package/src/concepts/BatchAssignment__.ts +45 -1
  162. package/src/concepts/BindAttribute__.ts +9 -2
  163. package/src/concepts/CallFunction__.ts +65 -31
  164. package/src/concepts/CallInterface__.ts +6 -22
  165. package/src/concepts/CallLogic__.ts +62 -13
  166. package/src/concepts/CallQueryComponent__.ts +4 -1
  167. package/src/concepts/DataSource__.ts +56 -1
  168. package/src/concepts/ForEachStatement__.ts +2 -0
  169. package/src/concepts/Identifier__.ts +18 -7
  170. package/src/concepts/LogicItem__.ts +1 -1
  171. package/src/concepts/Logic__.ts +48 -32
  172. package/src/concepts/Match__.ts +12 -8
  173. package/src/concepts/NewComposite__.ts +1356 -0
  174. package/src/concepts/NewList__.ts +444 -0
  175. package/src/concepts/NewMap__.ts +678 -0
  176. package/src/concepts/New__.ts +73 -0
  177. package/src/concepts/Param__.ts +238 -199
  178. package/src/concepts/ProcessElement__.ts +32 -10
  179. package/src/concepts/ProcessOutcome__.ts +1 -1
  180. package/src/concepts/ProcessOutcomes__.ts +90 -0
  181. package/src/concepts/Return__.ts +4 -1
  182. package/src/concepts/SelectMembers__.ts +3 -3
  183. package/src/concepts/StringInterpolation__.ts +21 -11
  184. package/src/concepts/TypeAnnotation__.ts +71 -50
  185. package/src/concepts/ValidationRule__.ts +19 -1
  186. package/src/concepts/Variable__.ts +4 -1
  187. package/src/concepts/ViewElement__.ts +38 -1
  188. package/src/concepts/View__.ts +12 -2
  189. package/src/concepts/basics/stdlib/dist/nasl.util.js +133 -34
  190. package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
  191. package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
  192. package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
  193. package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
  194. package/src/concepts/dist/BindAttribute__.js +760 -0
  195. package/src/concepts/dist/BindEvent__.js +732 -0
  196. package/src/concepts/dist/CallFunction__.js +21 -7
  197. package/src/concepts/dist/CallLogic__.js +50 -10
  198. package/src/concepts/dist/Identifier__.js +311 -0
  199. package/src/concepts/dist/StringInterpolation__.js +231 -0
  200. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  201. package/src/concepts/dist/ViewElement__.js +12 -0
  202. package/src/concepts/dist/View__.js +1601 -0
  203. package/src/concepts/index__.ts +5 -0
  204. package/src/enums/KEYWORDS.ts +1 -0
  205. package/src/generator/dist/genMetaData.js +1 -5
  206. package/src/generator/dist/permission.js +392 -0
  207. package/src/generator/genMetaData.ts +1 -6
  208. package/src/generator/genReleaseBody.ts +21 -3
  209. package/src/generator/index.ts +1 -0
  210. package/src/generator/permission.ts +271 -0
  211. package/src/index.ts +1 -1
  212. package/src/server/dist/naslServer.js +385 -269
  213. package/src/server/entity2LogicNamespace.ts +70 -10
  214. package/src/server/extendBaseNode.ts +7 -3
  215. package/src/server/formatTsUtils.ts +6 -0
  216. package/src/server/getLogics.ts +13 -1
  217. package/src/server/getMemberIdentifier.ts +1 -1
  218. package/src/server/naslServer.ts +162 -29
  219. package/src/server/process2LogicNamespace.ts +8 -0
  220. package/src/server/translator.ts +52 -9
  221. package/src/service/creator/add.configs.js +4 -0
  222. package/src/service/dataSource/api.js +11 -0
  223. package/src/service/dataSource/index.js +6 -0
  224. package/src/service/storage/dist/init.js +8 -1
  225. package/src/service/storage/init.ts +9 -2
  226. package/src/service/video/VideoTranscribe.js +1 -0
  227. package/src/templator/dist/genEditTableBlock.js +204 -0
  228. package/src/templator/dist/genGridViewBlock.js +265 -0
  229. package/src/templator/dist/genListViewBlock.js +84 -0
  230. package/src/templator/dist/genTableBlock.js +209 -0
  231. package/src/templator/dist/utils.js +527 -0
  232. package/src/templator/genEditTableBlock.ts +8 -16
  233. package/src/templator/genGetBlock.ts +18 -19
  234. package/src/templator/genGridViewBlock.ts +18 -18
  235. package/src/templator/genListViewBlock.ts +8 -11
  236. package/src/templator/genTableBlock.ts +6 -10
  237. package/ts-worker/dist/webpack.config.dev.js +1 -3
  238. package/ts-worker/lib/tsserver.js +8 -1
  239. package/out/automate/engine/2.14-components.d.ts +0 -1115
  240. package/out/automate/engine/2.14-components.js +0 -1087
  241. package/out/automate/engine/2.14-components.js.map +0 -1
  242. package/out/concepts/ConstructArgument__.d.ts +0 -40
  243. package/out/concepts/ConstructArgument__.js.map +0 -1
  244. package/out/concepts/Construct__.d.ts +0 -189
  245. package/out/concepts/Construct__.js +0 -340
  246. package/out/concepts/Construct__.js.map +0 -1
  247. package/out/concepts/MatchExpression__.d.ts +0 -97
  248. package/out/concepts/MatchExpression__.js +0 -281
  249. package/out/concepts/MatchExpression__.js.map +0 -1
  250. package/out/templator/sql-parser/index.d.ts +0 -1
  251. package/out/templator/sql-parser/index.js +0 -228
  252. package/out/templator/sql-parser/index.js.map +0 -1
  253. package/out/templator/sql-parser/parser.js +0 -26664
  254. package/out/templator/sql-parser/parser.js.map +0 -1
  255. package/src/concepts/dist/Anchor__.js +0 -179
  256. package/src/concepts/dist/Assignment__.js +0 -301
  257. package/src/concepts/dist/CallInterface__.js +0 -533
  258. package/src/concepts/dist/ForEachStatement__.js +0 -426
  259. package/src/concepts/dist/MatchCase__.js +0 -587
  260. package/src/concepts/dist/Match__.js +0 -631
  261. package/src/concepts/dist/MemberExpression__.js +0 -348
  262. package/src/concepts/dist/Param__.js +0 -538
  263. package/src/concepts/dist/Return__.js +0 -494
  264. package/src/concepts/dist/Variable__.js +0 -537
  265. package/src/server/dist/formatTsUtils.js +0 -683
@@ -175,8 +175,38 @@ var NaslServer = /** @class */ (function () {
175
175
  // 收集到一个行为集合
176
176
  var eventValue = $event.value;
177
177
  eventValue.forEach(function (item) { return __awaiter(_this, void 0, void 0, function () {
178
+ var changeEvent, changeNode, fileNode_1, findIndex;
179
+ var _this = this;
178
180
  return __generator(this, function (_a) {
179
- this.changeStackList.push(item.originEvent);
181
+ /**
182
+ * 多个行为进行合并
183
+ * 合并规则是
184
+ * 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c的时候,如果他们不都是file级别的节点
185
+ * 就可以前面的内容去掉,只保留最后一个
186
+ * 2.[a,b,c,b,c] 在bc已存在,又来了bc 这就都要保留,因为可能顺序有相关性,不能去掉
187
+ * 理论上只处理同时几个操作 合并,
188
+ * 3.有field的也直接保留
189
+ */
190
+ try {
191
+ changeEvent = item.originEvent;
192
+ changeNode = changeEvent.target;
193
+ fileNode_1 = this.getCurrentSource(changeNode).fileNode;
194
+ if (changeNode !== fileNode_1 || !changeEvent.field) {
195
+ findIndex = this.changeStackList.findIndex(function (changeStackItem) {
196
+ var target = changeStackItem.target;
197
+ var targetFileNode = _this.getCurrentSource(target).fileNode;
198
+ return targetFileNode === fileNode_1;
199
+ });
200
+ if (findIndex === this.changeStackList.length - 1) {
201
+ this.changeStackList.pop();
202
+ }
203
+ }
204
+ this.changeStackList.push(item.originEvent);
205
+ }
206
+ catch (err) {
207
+ console.log(err);
208
+ this.changeStackList.push(item.originEvent);
209
+ }
180
210
  return [2 /*return*/];
181
211
  });
182
212
  }); });
@@ -947,7 +977,8 @@ var NaslServer = /** @class */ (function () {
947
977
  // record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
948
978
  // }
949
979
  record.suggestionDiagnostics = record.suggestionDiagnostics
950
- .filter(function (item) { return ["'__LogicEmpty' is declared but its value is never read.", "'__destinationEmpty__' is declared but its value is never read."].includes(item.text); })
980
+ .filter(function (item) { return ["'__LogicEmpty' is declared but its value is never read.", "'__destinationEmpty__' is declared but its value is never read.",
981
+ "'__UpdateNoProperty__' is declared but its value is never read."].includes(item.text); })
951
982
  .map(function (diag) { return _this._resolveDiagnostic(diag, node, record); })
952
983
  .filter(function (diag) { return !!diag; });
953
984
  (_b = record.suggestionDiagnostics).push.apply(_b, _this._attachSuggestionDiagnostics(node));
@@ -963,7 +994,6 @@ var NaslServer = /** @class */ (function () {
963
994
  * @returns 诊断结果
964
995
  */
965
996
  NaslServer.prototype._attachSuggestionDiagnostics = function (fileNode) {
966
- var _this = this;
967
997
  var diagnostics = [];
968
998
  if (fileNode instanceof concepts_1.Logic || fileNode instanceof concepts_1.View) {
969
999
  // 判断逻辑是否已经删除
@@ -982,140 +1012,132 @@ var NaslServer = /** @class */ (function () {
982
1012
  }
983
1013
  if (removed)
984
1014
  return diagnostics;
985
- fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) { return __awaiter(_this, void 0, void 0, function () {
986
- var _a, cases_1, expression_1, typeAnnotationMap_1, maxTypeAnnotationInfo_1, maxTypeAnnotation_1, sortedTypeKey, _b, typeAnnotation, cases_2;
987
- var _this = this;
988
- return __generator(this, function (_c) {
989
- if (node instanceof concepts_1.Match) {
990
- _a = node || {}, cases_1 = _a.cases, expression_1 = _a.expression;
991
- typeAnnotationMap_1 = {};
992
- maxTypeAnnotationInfo_1 = {
993
- typeAnnotation: null,
994
- count: 0
995
- };
996
- if (Array.isArray(cases_1)) {
997
- cases_1.forEach(function (caseItem, index) { return __awaiter(_this, void 0, void 0, function () {
998
- var isDisabled, enumerableItems, currTypeAnnotation, _a, typeKind, typeNamespace, typeName, typeArguments, nameArr, typeNode, enums, children, map_1, enumerableKeys, typeAnnotation, sortedTypeKey, typeAnnotationInfo, count;
999
- var _b, _c;
1000
- return __generator(this, function (_d) {
1001
- isDisabled = false;
1002
- // 是最后一项
1003
- if (index === cases_1.length - 1) {
1004
- enumerableItems = [];
1005
- currTypeAnnotation = expression_1 === null || expression_1 === void 0 ? void 0 : expression_1.__TypeAnnotation;
1006
- _a = currTypeAnnotation || {}, typeKind = _a.typeKind, typeNamespace = _a.typeNamespace, typeName = _a.typeName, typeArguments = _a.typeArguments;
1007
- if (typeKind === 'union' && Array.isArray(typeArguments)) {
1008
- enumerableItems = typeArguments.map(function (typeArg) {
1009
- var typeArgJson = typeArg;
1010
- if (typeArg instanceof concepts_1.TypeAnnotation) {
1011
- typeArgJson = typeArg.toJSON();
1012
- }
1013
- return new concepts_1.TypeAnnotation(typeArgJson);
1014
- });
1015
- }
1016
- else if (typeKind === 'reference') {
1017
- nameArr = [typeName];
1018
- if (typeNamespace) {
1019
- nameArr.unshift(typeNamespace);
1020
- }
1021
- typeNode = ((_c = (_b = node.app) === null || _b === void 0 ? void 0 : _b.findNodeByCompleteName) === null || _c === void 0 ? void 0 : _c.call(_b, nameArr.join('.'))) || {};
1022
- if (typeNode.concept === 'Enum') {
1023
- enums = getMemberIdentifier_1.formatEnums([typeNode]);
1024
- children = ((enums === null || enums === void 0 ? void 0 : enums[0]) || {}).children;
1025
- if (Array.isArray(children)) {
1026
- enumerableItems = children.map(function (child) { return child === null || child === void 0 ? void 0 : child.expression; });
1027
- }
1028
- }
1015
+ fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) {
1016
+ if (node instanceof concepts_1.Match) {
1017
+ var _a = node || {}, cases_1 = _a.cases, expression_1 = _a.expression;
1018
+ var typeAnnotationMap_1 = {};
1019
+ // 最多数的类型
1020
+ var maxTypeAnnotationInfo_1 = {
1021
+ typeAnnotation: null,
1022
+ count: 0
1023
+ };
1024
+ if (Array.isArray(cases_1)) {
1025
+ cases_1.forEach(function (caseItem, index) {
1026
+ var _a, _b;
1027
+ var isDisabled = false;
1028
+ // 是最后一项
1029
+ if (index === cases_1.length - 1) {
1030
+ var enumerableItems = [];
1031
+ var currTypeAnnotation = expression_1 === null || expression_1 === void 0 ? void 0 : expression_1.__TypeAnnotation;
1032
+ var _c = currTypeAnnotation || {}, typeKind = _c.typeKind, typeNamespace = _c.typeNamespace, typeName = _c.typeName, typeArguments = _c.typeArguments;
1033
+ if (typeKind === 'union' && Array.isArray(typeArguments)) {
1034
+ enumerableItems = typeArguments.map(function (typeArg) {
1035
+ var typeArgJson = typeArg;
1036
+ if (typeArg instanceof concepts_1.TypeAnnotation) {
1037
+ typeArgJson = typeArg.toJSON();
1029
1038
  }
1030
- else if (typeKind === 'primitive' && typeNamespace === 'nasl.core' && typeName === 'Boolean') {
1031
- enumerableItems = [
1032
- new concepts_1.BooleanLiteral({
1033
- value: 'true'
1034
- }),
1035
- new concepts_1.BooleanLiteral({
1036
- value: 'false'
1037
- }),
1038
- ];
1039
+ return new concepts_1.TypeAnnotation(typeArgJson);
1040
+ });
1041
+ }
1042
+ else if (typeKind === 'reference') {
1043
+ var nameArr = [typeName];
1044
+ if (typeNamespace) {
1045
+ nameArr.unshift(typeNamespace);
1046
+ }
1047
+ var typeNode = ((_b = (_a = node.app) === null || _a === void 0 ? void 0 : _a.findNodeByCompleteName) === null || _b === void 0 ? void 0 : _b.call(_a, nameArr.join('.'))) || {};
1048
+ if (typeNode.concept === 'Enum') {
1049
+ var enums = getMemberIdentifier_1.formatEnums([typeNode]);
1050
+ var children = ((enums === null || enums === void 0 ? void 0 : enums[0]) || {}).children;
1051
+ if (Array.isArray(children)) {
1052
+ enumerableItems = children.map(function (child) { return child === null || child === void 0 ? void 0 : child.expression; });
1039
1053
  }
1040
- if (Array.isArray(enumerableItems) && enumerableItems.length) {
1041
- map_1 = {};
1042
- cases_1.forEach(function (caseItem) {
1043
- var patterns = (caseItem || {}).patterns;
1044
- if (Array.isArray(patterns)) {
1045
- patterns.forEach(function (pattern) {
1046
- if (pattern instanceof concepts_1.TypeAnnotation) {
1047
- var patternTypeKey = pattern.typeKey;
1048
- map_1[patternTypeKey] = true;
1049
- }
1050
- else if (pattern instanceof concepts_1.MemberExpression || pattern instanceof concepts_1.BooleanLiteral) {
1051
- var patternValue = pattern.getValue();
1052
- map_1[patternValue] = true;
1053
- }
1054
- });
1054
+ }
1055
+ }
1056
+ else if (typeKind === 'primitive' && typeNamespace === 'nasl.core' && typeName === 'Boolean') {
1057
+ enumerableItems = [
1058
+ new concepts_1.BooleanLiteral({
1059
+ value: 'true'
1060
+ }),
1061
+ new concepts_1.BooleanLiteral({
1062
+ value: 'false'
1063
+ }),
1064
+ ];
1065
+ }
1066
+ if (Array.isArray(enumerableItems) && enumerableItems.length) {
1067
+ var map_1 = {};
1068
+ cases_1.forEach(function (caseItem) {
1069
+ var patterns = (caseItem || {}).patterns;
1070
+ if (Array.isArray(patterns)) {
1071
+ patterns.forEach(function (pattern) {
1072
+ if (pattern instanceof concepts_1.TypeAnnotation) {
1073
+ var patternTypeKey = pattern.typeKey;
1074
+ map_1[patternTypeKey] = true;
1075
+ }
1076
+ else if (pattern instanceof concepts_1.MemberExpression || pattern instanceof concepts_1.BooleanLiteral) {
1077
+ var patternValue = pattern.getValue();
1078
+ map_1[patternValue] = true;
1055
1079
  }
1056
1080
  });
1057
- enumerableKeys = Object.keys(map_1);
1058
- if (enumerableKeys.length === enumerableItems.length) {
1059
- isDisabled = true;
1060
- }
1061
1081
  }
1082
+ });
1083
+ var enumerableKeys = Object.keys(map_1);
1084
+ if (enumerableKeys.length === enumerableItems.length) {
1085
+ isDisabled = true;
1062
1086
  }
1063
- if (!isDisabled) {
1064
- typeAnnotation = caseItem.__TypeAnnotation;
1065
- // 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
1066
- if (typeAnnotation) {
1067
- sortedTypeKey = typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey;
1068
- if (!typeAnnotationMap_1[sortedTypeKey]) {
1069
- typeAnnotationMap_1[sortedTypeKey] = {
1070
- typeAnnotation: typeAnnotation,
1071
- cases: [],
1072
- count: 0
1073
- };
1074
- }
1075
- typeAnnotationInfo = typeAnnotationMap_1[sortedTypeKey];
1076
- typeAnnotationInfo.cases.push(caseItem);
1077
- typeAnnotationInfo.count++;
1078
- count = typeAnnotationInfo.count;
1079
- if (maxTypeAnnotationInfo_1.count < count) {
1080
- maxTypeAnnotationInfo_1 = {
1081
- typeAnnotation: typeAnnotation,
1082
- count: count
1083
- };
1084
- }
1085
- return [2 /*return*/, typeAnnotation];
1086
- }
1087
+ }
1088
+ }
1089
+ if (!isDisabled) {
1090
+ var typeAnnotation = caseItem.__TypeAnnotation;
1091
+ // 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
1092
+ if (typeAnnotation) {
1093
+ var sortedTypeKey = typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey;
1094
+ if (!typeAnnotationMap_1[sortedTypeKey]) {
1095
+ typeAnnotationMap_1[sortedTypeKey] = {
1096
+ typeAnnotation: typeAnnotation,
1097
+ cases: [],
1098
+ count: 0
1099
+ };
1087
1100
  }
1088
- return [2 /*return*/];
1089
- });
1090
- }); });
1091
- }
1092
- maxTypeAnnotation_1 = maxTypeAnnotationInfo_1.typeAnnotation;
1093
- for (sortedTypeKey in typeAnnotationMap_1) {
1094
- _b = typeAnnotationMap_1[sortedTypeKey], typeAnnotation = _b.typeAnnotation, cases_2 = _b.cases;
1095
- if ((maxTypeAnnotation_1 === null || maxTypeAnnotation_1 === void 0 ? void 0 : maxTypeAnnotation_1.sortedTypeKey) !== (typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey)) {
1096
- if (Array.isArray(cases_2)) {
1097
- cases_2.forEach(function (caseItem) {
1098
- var body = (caseItem || {}).body;
1099
- var diagnostic = {
1100
- node: caseItem,
1101
- severity: 'warning',
1102
- message: '分支类型不一致'
1101
+ var typeAnnotationInfo = typeAnnotationMap_1[sortedTypeKey];
1102
+ typeAnnotationInfo.cases.push(caseItem);
1103
+ typeAnnotationInfo.count++;
1104
+ var count = typeAnnotationInfo.count;
1105
+ if (maxTypeAnnotationInfo_1.count < count) {
1106
+ maxTypeAnnotationInfo_1 = {
1107
+ typeAnnotation: typeAnnotation,
1108
+ count: count
1103
1109
  };
1104
- if (Array.isArray(body) && body.length) {
1105
- var lastExpression = body[body.length - 1];
1106
- diagnostic.node = lastExpression;
1107
- diagnostic.message = (lastExpression === null || lastExpression === void 0 ? void 0 : lastExpression.toUI()) + "\u671F\u671B\u7684\u7C7B\u578B\u662F" + (maxTypeAnnotation_1 === null || maxTypeAnnotation_1 === void 0 ? void 0 : maxTypeAnnotation_1.headTitle);
1108
- lastExpression.tsErrorDetail = diagnostic;
1109
- diagnostics.push(diagnostic);
1110
- }
1111
- });
1110
+ }
1111
+ return typeAnnotation;
1112
1112
  }
1113
1113
  }
1114
+ });
1115
+ }
1116
+ var maxTypeAnnotation_1 = maxTypeAnnotationInfo_1.typeAnnotation;
1117
+ for (var sortedTypeKey in typeAnnotationMap_1) {
1118
+ var _b = typeAnnotationMap_1[sortedTypeKey], typeAnnotation = _b.typeAnnotation, cases_2 = _b.cases;
1119
+ if ((maxTypeAnnotation_1 === null || maxTypeAnnotation_1 === void 0 ? void 0 : maxTypeAnnotation_1.sortedTypeKey) !== (typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey)) {
1120
+ if (Array.isArray(cases_2)) {
1121
+ cases_2.forEach(function (caseItem) {
1122
+ var body = (caseItem || {}).body;
1123
+ var diagnostic = {
1124
+ node: caseItem,
1125
+ severity: 'warning',
1126
+ message: '分支类型不一致'
1127
+ };
1128
+ if (Array.isArray(body) && body.length) {
1129
+ var lastExpression = body[body.length - 1];
1130
+ diagnostic.node = lastExpression;
1131
+ diagnostic.message = (lastExpression === null || lastExpression === void 0 ? void 0 : lastExpression.toUI()) + "\u671F\u671B\u7684\u7C7B\u578B\u662F" + (maxTypeAnnotation_1 === null || maxTypeAnnotation_1 === void 0 ? void 0 : maxTypeAnnotation_1.headTitle);
1132
+ lastExpression.tsErrorDetail = diagnostic;
1133
+ diagnostics.push(diagnostic);
1134
+ }
1135
+ });
1136
+ }
1114
1137
  }
1115
1138
  }
1116
- return [2 /*return*/];
1117
- });
1118
- }); });
1139
+ }
1140
+ });
1119
1141
  }
1120
1142
  return diagnostics;
1121
1143
  };
@@ -1142,104 +1164,101 @@ var NaslServer = /** @class */ (function () {
1142
1164
  }
1143
1165
  if (removed)
1144
1166
  return diagnostics;
1145
- fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) { return __awaiter(_this, void 0, void 0, function () {
1146
- var nodeTypeName_1, msg_1, diagnostic;
1147
- return __generator(this, function (_a) {
1148
- if (node instanceof concepts_1.ViewElement && node.view === fileNode) {
1149
- if (node.tag) {
1150
- node.bindAttrs.forEach(function (bindAttr) {
1151
- if ((bindAttr.model || bindAttr.sync) && bindAttr.expression) {
1152
- var bindExpression = bindAttr.expression;
1153
- var diagnostic = void 0;
1154
- if (bindExpression.concept !== 'Identifier' && bindExpression.concept !== 'MemberExpression') {
1167
+ fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) {
1168
+ if (node instanceof concepts_1.ViewElement && node.view === fileNode) {
1169
+ if (node.tag) {
1170
+ node.bindAttrs.forEach(function (bindAttr) {
1171
+ if ((bindAttr.model || bindAttr.sync) && bindAttr.expression) {
1172
+ var bindExpression = bindAttr.expression;
1173
+ var diagnostic = void 0;
1174
+ if (bindExpression.concept !== 'Identifier' && bindExpression.concept !== 'MemberExpression') {
1175
+ diagnostic = {
1176
+ node: bindAttr,
1177
+ severity: 'error',
1178
+ message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。'
1179
+ };
1180
+ }
1181
+ else {
1182
+ if (bindExpression.isEnum()) {
1155
1183
  diagnostic = {
1156
1184
  node: bindAttr,
1157
1185
  severity: 'error',
1158
1186
  message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。'
1159
1187
  };
1160
1188
  }
1161
- else {
1162
- if (bindExpression.isEnum()) {
1163
- diagnostic = {
1164
- node: bindAttr,
1165
- severity: 'error',
1166
- message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。'
1167
- };
1168
- }
1169
- }
1170
- if (diagnostic) {
1171
- bindAttr.tsErrorDetail = diagnostic;
1172
- diagnostics.push(diagnostic);
1173
- }
1174
1189
  }
1175
- });
1176
- }
1190
+ if (diagnostic) {
1191
+ bindAttr.tsErrorDetail = diagnostic;
1192
+ diagnostics.push(diagnostic);
1193
+ }
1194
+ }
1195
+ });
1177
1196
  }
1178
- else if ((node instanceof concepts_1.Variable || node instanceof concepts_1.Return) && node.view === fileNode) {
1179
- if (!node.typeAnnotation && !node.__TypeAnnotation) {
1180
- nodeTypeName_1 = node.concept === 'Return' ? '输出参数' : '局部变量';
1181
- fileNode.traverseChildren(function (nodeIn) {
1182
- var _a, _b, _c, _d;
1183
- if (nodeIn && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && ((_a = nodeIn.left) === null || _a === void 0 ? void 0 : _a.name)))) {
1184
- // 子页面内部逻辑过滤
1185
- if (nodeIn.view !== fileNode)
1186
- return;
1187
- // 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
1188
- if (node.logic && node.logic !== nodeIn.logic)
1189
- return;
1190
- // 跟变量无关的赋值过滤
1191
- var jsCode_1 = nodeIn.toJS();
1192
- if (!jsCode_1.includes(node.name + " = "))
1197
+ }
1198
+ else if ((node instanceof concepts_1.Variable || node instanceof concepts_1.Return) && node.view === fileNode) {
1199
+ if (!node.typeAnnotation && !node.__TypeAnnotation) {
1200
+ var nodeTypeName_1 = node.concept === 'Return' ? '输出参数' : '局部变量';
1201
+ var msg_1;
1202
+ fileNode.traverseChildren(function (nodeIn) {
1203
+ var _a, _b, _c, _d;
1204
+ if (nodeIn && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && ((_a = nodeIn.left) === null || _a === void 0 ? void 0 : _a.name)))) {
1205
+ // 子页面内部逻辑过滤
1206
+ if (nodeIn.view !== fileNode)
1207
+ return;
1208
+ // 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
1209
+ if (node.logic && node.logic !== nodeIn.logic)
1210
+ return;
1211
+ // 跟变量无关的赋值过滤
1212
+ var jsCode_1 = nodeIn.toJS();
1213
+ if (!jsCode_1.includes(node.name + " = "))
1214
+ return;
1215
+ // 页面局部变量
1216
+ if (node instanceof concepts_1.Variable && node.parentNode instanceof concepts_1.View) {
1217
+ // 跟页面局部变量无关的赋值过滤
1218
+ if (!jsCode_1.includes("this." + node.name + " = "))
1193
1219
  return;
1194
- // 页面局部变量
1195
- if (node instanceof concepts_1.Variable && node.parentNode instanceof concepts_1.View) {
1196
- // 跟页面局部变量无关的赋值过滤
1197
- if (!jsCode_1.includes("this." + node.name + " = "))
1198
- return;
1199
- // 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
1200
- if (((_b = nodeIn.logic) === null || _b === void 0 ? void 0 : _b.params.find(function (param) { return jsCode_1.includes(param.name); })) || ((_c = nodeIn.logic) === null || _c === void 0 ? void 0 : _c.virtualParams.find(function (vParam) { return jsCode_1.includes(vParam.name); }))
1201
- || ((_d = nodeIn.logic) === null || _d === void 0 ? void 0 : _d.variables.find(function (variable) { return jsCode_1.includes(variable.name); }))) {
1202
- if (!nodeIn.tsErrorDetail) {
1203
- var diagnostic_2 = {
1204
- node: nodeIn,
1205
- severity: 'error',
1206
- message: "\u9875\u9762" + nodeTypeName_1 + " " + node.name + " \u8D4B\u503C\u9875\u9762\u903B\u8F91\u5185\u5C40\u90E8\u53D8\u91CF\u6216\u8F93\u5165\u53C2\u6570\u65F6\uFF0C\u7CFB\u7EDF\u65E0\u6CD5\u63A8\u5BFC\u7C7B\u578B\u3002"
1207
- };
1208
- nodeIn.tsErrorDetail = diagnostic_2;
1209
- diagnostics.push(diagnostic_2);
1210
- }
1211
- msg_1 = '系统无法推断类型。';
1220
+ // 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
1221
+ if (((_b = nodeIn.logic) === null || _b === void 0 ? void 0 : _b.params.find(function (param) { return jsCode_1.includes(param.name); })) || ((_c = nodeIn.logic) === null || _c === void 0 ? void 0 : _c.virtualParams.find(function (vParam) { return jsCode_1.includes(vParam.name); }))
1222
+ || ((_d = nodeIn.logic) === null || _d === void 0 ? void 0 : _d.variables.find(function (variable) { return jsCode_1.includes(variable.name); }))) {
1223
+ if (!nodeIn.tsErrorDetail) {
1224
+ var diagnostic_2 = {
1225
+ node: nodeIn,
1226
+ severity: 'error',
1227
+ message: "\u9875\u9762" + nodeTypeName_1 + " " + node.name + " \u8D4B\u503C\u9875\u9762\u903B\u8F91\u5185\u5C40\u90E8\u53D8\u91CF\u6216\u8F93\u5165\u53C2\u6570\u65F6\uFF0C\u7CFB\u7EDF\u65E0\u6CD5\u63A8\u5BFC\u7C7B\u578B\u3002"
1228
+ };
1229
+ nodeIn.tsErrorDetail = diagnostic_2;
1230
+ diagnostics.push(diagnostic_2);
1212
1231
  }
1232
+ msg_1 = '系统无法推断类型。';
1213
1233
  }
1214
- if (!nodeIn.tsErrorDetail) {
1215
- var diagnostic_3 = {
1216
- node: nodeIn,
1217
- severity: 'error',
1218
- message: nodeIn.label + "\u5DE6\u8FB9 " + node.name + " \u672A\u8BBE\u7F6E\u7C7B\u578B\uFF0C\u53F3\u8FB9\u5FC5\u987B\u4E3A\u6709\u8FD4\u56DE\u503C\u7684\u5185\u5BB9\u3002"
1219
- };
1220
- nodeIn.tsErrorDetail = diagnostic_3;
1221
- diagnostics.push(diagnostic_3);
1222
- }
1223
- msg_1 = '必须赋值有返回值的内容。';
1224
1234
  }
1225
- });
1226
- if (!msg_1)
1227
- msg_1 = '未设置类型或未赋值,直接赋值系统会自动推断类型。';
1228
- diagnostic = {
1229
- node: node,
1230
- severity: 'error',
1231
- message: nodeTypeName_1 + " " + node.name + " " + msg_1
1232
- };
1233
- node.tsErrorDetail = diagnostic;
1234
- diagnostics.push(diagnostic);
1235
- }
1236
- }
1237
- else {
1238
- this.checkNodeError(node, diagnostics);
1235
+ if (!nodeIn.tsErrorDetail) {
1236
+ var diagnostic_3 = {
1237
+ node: nodeIn,
1238
+ severity: 'error',
1239
+ message: nodeIn.label + "\u5DE6\u8FB9 " + node.name + " \u672A\u8BBE\u7F6E\u7C7B\u578B\uFF0C\u53F3\u8FB9\u5FC5\u987B\u4E3A\u6709\u8FD4\u56DE\u503C\u7684\u5185\u5BB9\u3002"
1240
+ };
1241
+ nodeIn.tsErrorDetail = diagnostic_3;
1242
+ diagnostics.push(diagnostic_3);
1243
+ }
1244
+ msg_1 = '必须赋值有返回值的内容。';
1245
+ }
1246
+ });
1247
+ if (!msg_1)
1248
+ msg_1 = '未设置类型或未赋值,直接赋值系统会自动推断类型。';
1249
+ var diagnostic = {
1250
+ node: node,
1251
+ severity: 'error',
1252
+ message: nodeTypeName_1 + " " + node.name + " " + msg_1
1253
+ };
1254
+ node.tsErrorDetail = diagnostic;
1255
+ diagnostics.push(diagnostic);
1239
1256
  }
1240
- return [2 /*return*/];
1241
- });
1242
- }); });
1257
+ }
1258
+ else {
1259
+ _this.checkNodeError(node, diagnostics);
1260
+ }
1261
+ });
1243
1262
  }
1244
1263
  if (fileNode instanceof concepts_1.DataSource) {
1245
1264
  var dataSourceGroup = (_a = fileNode.rootNode.configuration) === null || _a === void 0 ? void 0 : _a.getGroup('dataSource');
@@ -1263,6 +1282,44 @@ var NaslServer = /** @class */ (function () {
1263
1282
  };
1264
1283
  diagnostics.push(diagnostic);
1265
1284
  }
1285
+ else if (propertyValue.value) {
1286
+ var dataSource = fileNode;
1287
+ // 数据源有连接错误
1288
+ var envText = void 0;
1289
+ if (propertyValue.env === 'dev') {
1290
+ if (dataSource.__devConnectError) {
1291
+ envText = '开发';
1292
+ }
1293
+ else if (dataSource.__devConnectError === false) {
1294
+ return;
1295
+ }
1296
+ }
1297
+ else if (propertyValue.env === 'online') {
1298
+ if (dataSource.__onlineConnectError) {
1299
+ envText = '生产';
1300
+ }
1301
+ else if (dataSource.__onlineConnectError === false) {
1302
+ return;
1303
+ }
1304
+ }
1305
+ // 手动插入报错
1306
+ if (envText) {
1307
+ var diagnostic = {
1308
+ node: fileNode,
1309
+ severity: 'error',
1310
+ message: "\u6570\u636E\u6E90\u914D\u7F6E\uFF1A\u6570\u636E\u6E90 " + property_1.name + " " + envText + "\u73AF\u5883\u6570\u636E\u6E90\u8FDE\u63A5\u4E0D\u901A\uFF0C\u8BF7\u5148\u68C0\u67E5" + envText + "\u73AF\u5883\u6570\u636E\u6E90\u914D\u7F6E",
1311
+ // 保留原来的内容方便查询一些问题
1312
+ originalDiagnostic: {
1313
+ fileName: '',
1314
+ start: null,
1315
+ end: null,
1316
+ category: 'error',
1317
+ text: "DataSource connection error"
1318
+ }
1319
+ };
1320
+ return diagnostics.push(diagnostic);
1321
+ }
1322
+ }
1266
1323
  });
1267
1324
  }
1268
1325
  }
@@ -1271,69 +1328,71 @@ var NaslServer = /** @class */ (function () {
1271
1328
  // 判断逻辑是否已经删除
1272
1329
  if (fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
1273
1330
  return diagnostics;
1274
- fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) { return __awaiter(_this, void 0, void 0, function () {
1275
- var diagnostic, nodeTypeName, used_1, msg, diagnostic;
1276
- return __generator(this, function (_a) {
1277
- // SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
1278
- if ((node instanceof concepts_1.OqlQueryComponent || node instanceof concepts_1.SqlQueryComponent) && node.getTypeBanError()) {
1279
- diagnostic = {
1331
+ fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) {
1332
+ //OQL支持返回复合类型数据了
1333
+ // SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
1334
+ // if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
1335
+ // const diagnostic = {
1336
+ // node,
1337
+ // severity: 'error',
1338
+ // message: 'SQL查询:返回类型内部,不支持复杂类型。',
1339
+ // };
1340
+ // node.tsErrorDetail = diagnostic;
1341
+ // diagnostics.push(diagnostic);
1342
+ // }
1343
+ if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
1344
+ if (!node.typeAnnotation && !node.__TypeAnnotation) {
1345
+ var nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
1346
+ var used_1 = false;
1347
+ fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (valueIn, nodeIn) {
1348
+ var _a;
1349
+ if (!used_1 && nodeIn
1350
+ && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && ((_a = nodeIn.left) === null || _a === void 0 ? void 0 : _a.name)))
1351
+ && nodeIn.toJS().includes(node.name + " = ")) {
1352
+ used_1 = true;
1353
+ if (!nodeIn.tsErrorDetail) {
1354
+ var diagnostic_4 = {
1355
+ node: nodeIn,
1356
+ severity: 'error',
1357
+ message: nodeIn.label + "\u5DE6\u8FB9 " + node.name + " \u672A\u8BBE\u7F6E\u7C7B\u578B\uFF0C\u53F3\u8FB9\u5FC5\u987B\u4E3A\u6709\u8FD4\u56DE\u503C\u7684\u5185\u5BB9\u3002"
1358
+ };
1359
+ nodeIn.tsErrorDetail = diagnostic_4;
1360
+ diagnostics.push(diagnostic_4);
1361
+ }
1362
+ }
1363
+ });
1364
+ var msg = used_1 ? '必须赋值有返回值的内容。' : '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
1365
+ var diagnostic = {
1280
1366
  node: node,
1281
1367
  severity: 'error',
1282
- message: 'SQL查询:返回类型内部,不支持复杂类型。'
1368
+ message: nodeTypeName + " " + node.name + " " + msg
1283
1369
  };
1284
1370
  node.tsErrorDetail = diagnostic;
1285
1371
  diagnostics.push(diagnostic);
1286
1372
  }
1287
- if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
1288
- if (!node.typeAnnotation && !node.__TypeAnnotation) {
1289
- nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
1290
- used_1 = false;
1291
- fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (valueIn, nodeIn) {
1292
- var _a;
1293
- if (!used_1 && nodeIn
1294
- && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && ((_a = nodeIn.left) === null || _a === void 0 ? void 0 : _a.name)))
1295
- && nodeIn.toJS().includes(node.name + " = ")) {
1296
- used_1 = true;
1297
- if (!nodeIn.tsErrorDetail) {
1298
- var diagnostic_4 = {
1299
- node: nodeIn,
1300
- severity: 'error',
1301
- message: nodeIn.label + "\u5DE6\u8FB9 " + node.name + " \u672A\u8BBE\u7F6E\u7C7B\u578B\uFF0C\u53F3\u8FB9\u5FC5\u987B\u4E3A\u6709\u8FD4\u56DE\u503C\u7684\u5185\u5BB9\u3002"
1302
- };
1303
- nodeIn.tsErrorDetail = diagnostic_4;
1304
- diagnostics.push(diagnostic_4);
1305
- }
1306
- }
1307
- });
1308
- msg = used_1 ? '必须赋值有返回值的内容。' : '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
1309
- diagnostic = {
1310
- node: node,
1311
- severity: 'error',
1312
- message: nodeTypeName + " " + node.name + " " + msg
1313
- };
1314
- node.tsErrorDetail = diagnostic;
1315
- diagnostics.push(diagnostic);
1316
- }
1317
- else {
1318
- node.tsErrorDetail = undefined;
1319
- }
1373
+ else {
1374
+ node.tsErrorDetail = undefined;
1320
1375
  }
1321
- this.checkNodeError(node, diagnostics);
1322
- return [2 /*return*/];
1323
- });
1324
- }); });
1376
+ }
1377
+ _this.checkNodeError(node, diagnostics);
1378
+ });
1379
+ }
1380
+ if (fileNode instanceof concepts_1.Process) {
1381
+ fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap.forEach(function (value, node) {
1382
+ _this.checkNodeError(node, diagnostics);
1383
+ });
1325
1384
  }
1326
1385
  return diagnostics;
1327
1386
  };
1328
1387
  NaslServer.prototype.checkNodeError = function (node, diagnostics) {
1329
- var _a, _b, _c, _d, _e;
1388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1330
1389
  if (!node)
1331
1390
  return;
1332
1391
  // 如果节点是match的看看节点里是不是有重复的
1333
1392
  if (node instanceof concepts_1.Match) {
1334
1393
  var typeMap_1 = {};
1335
1394
  if ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.__TypeAnnotation) {
1336
- var _f = node.expression.__TypeAnnotation, typeName = _f.typeName, typeNamespace = _f.typeNamespace;
1395
+ var _k = node.expression.__TypeAnnotation, typeName = _k.typeName, typeNamespace = _k.typeNamespace;
1337
1396
  if (typeName === 'Union' || typeName === 'Boolean' || (typeNamespace === null || typeNamespace === void 0 ? void 0 : typeNamespace.endsWith('enums'))) {
1338
1397
  node.cases.forEach(function (item) {
1339
1398
  if (Array.isArray(item.patterns)) {
@@ -1405,9 +1464,32 @@ var NaslServer = /** @class */ (function () {
1405
1464
  node.tsErrorDetail = diagnostic;
1406
1465
  diagnostics.push(diagnostic);
1407
1466
  }
1467
+ // 如果TypeAnnotation 还存在,但是本身已经不是union类型,就是已经从union换别的类型了就都要报错
1468
+ }
1469
+ else if (node instanceof concepts_1.TypeAnnotation && (matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeKind) !== 'union') {
1470
+ var diagnostic = {
1471
+ node: node,
1472
+ severity: 'error',
1473
+ message: '匹配:选择类型不存在',
1474
+ titleTip: '该类型已被删除'
1475
+ };
1476
+ node.tsErrorDetail = diagnostic;
1477
+ diagnostics.push(diagnostic);
1478
+ // 如果可枚举变量的 ,变量 还存在,但是本身已经是union类型,就是已经从别的类型 换了union就都要报错
1479
+ }
1480
+ else if (!(node instanceof concepts_1.TypeAnnotation) && (matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeKind) === 'union') {
1481
+ var diagnostic = {
1482
+ node: node,
1483
+ severity: 'error',
1484
+ message: '匹配:选择值不存在',
1485
+ titleTip: '该值无法匹配,请重新选择类型'
1486
+ };
1487
+ node.tsErrorDetail = diagnostic;
1488
+ diagnostics.push(diagnostic);
1408
1489
  }
1409
1490
  if (node.tsErrorDetail) {
1410
- if ((_d = matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeNamespace) === null || _d === void 0 ? void 0 : _d.includes('enums')) {
1491
+ // 如果父级是枚举,而且子集选的是变量,就提示枚举值已被删除
1492
+ if (((_d = matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeNamespace) === null || _d === void 0 ? void 0 : _d.includes('enums')) && (node instanceof concepts_1.MemberExpression)) {
1411
1493
  node.tsErrorDetail.titleTip = '该枚举值已被删除';
1412
1494
  }
1413
1495
  else if (!node.tsErrorDetail.titleTip) {
@@ -1425,6 +1507,25 @@ var NaslServer = /** @class */ (function () {
1425
1507
  node.tsErrorDetail = diagnostic;
1426
1508
  diagnostics.push(diagnostic);
1427
1509
  }
1510
+ /**
1511
+ * 如果节点是内置函数
1512
+ * 穷举在线上的情况,不在线上就void报错, calllogic 和 callinterface 因为原来有报错,所以就忽略掉
1513
+ * && 他在父级中,不在body
1514
+ * && 也不再 if的线上
1515
+ * && 也不再 switch的线上consequent
1516
+ * && 也不再草稿区域
1517
+ * && 不在 parentNode.parentNode(只用处理两层的,超过两层上就需要报错,只用直接是参数位第一层的需要) 是 callfunction 和 callInfterfase中,因为这两本身有强制类型,内置函数或者一些带T的声明那种,
1518
+ * && 而且也没有类型,就说明在槽位里,就需要报错
1519
+ */
1520
+ if (node instanceof concepts_1.CallFunction && node.parentKey !== 'body' && node.parentKey !== 'alternate' && node.parentKey !== 'playground' && node.parentKey !== 'consequent' && ((_g = (_f = node.parentNode) === null || _f === void 0 ? void 0 : _f.parentNode) === null || _g === void 0 ? void 0 : _g.concept) !== 'CallLogic' && ((_j = (_h = node.parentNode) === null || _h === void 0 ? void 0 : _h.parentNode) === null || _j === void 0 ? void 0 : _j.concept) !== 'CallInterface' && !node.__TypeAnnotation) {
1521
+ var diagnostic = {
1522
+ node: node,
1523
+ severity: 'error',
1524
+ message: "\u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u4F20\u5165\u7C7B\u578B\uFF1Avoid"
1525
+ };
1526
+ node.tsErrorDetail = diagnostic;
1527
+ diagnostics.push(diagnostic);
1528
+ }
1428
1529
  };
1429
1530
  /* 接口导入查找 */
1430
1531
  NaslServer.prototype.existStructureFix = function (semanticDiagnostics, node, that) {
@@ -1568,7 +1669,7 @@ var NaslServer = /** @class */ (function () {
1568
1669
  */
1569
1670
  NaslServer.prototype._isHaveRef = function (node) {
1570
1671
  return __awaiter(this, void 0, void 0, function () {
1571
- var _a, currentSource, fileNode, refsList, newRefs, lists, moduleName_2, item, fileNode_1, newRefs, logicNode, currentSource_1, parentRefs, viewNode, currentSource_2, code, viewIndex, viewRefs, filterViewRefs, code, prefix, prefixIndex, methodsNameIndex, methods, methodRefs_1;
1672
+ var _a, currentSource, fileNode, refsList, newRefs, lists, moduleName_2, item, fileNode_2, newRefs, logicNode, currentSource_1, parentRefs, viewNode, currentSource_2, code, viewIndex, viewRefs, filterViewRefs, code, prefix, prefixIndex, methodsNameIndex, methods, methodRefs_1;
1572
1673
  var _this = this;
1573
1674
  return __generator(this, function (_b) {
1574
1675
  switch (_b.label) {
@@ -1591,10 +1692,10 @@ var NaslServer = /** @class */ (function () {
1591
1692
  moduleName_2 = fileNode.getEmbeddedFilePath();
1592
1693
  if (!lists.length) return [3 /*break*/, 4];
1593
1694
  item = lists[0];
1594
- fileNode_1 = this.getCurrentSource(item).fileNode;
1595
- if (!fileNode_1) return [3 /*break*/, 4];
1695
+ fileNode_2 = this.getCurrentSource(item).fileNode;
1696
+ if (!fileNode_2) return [3 /*break*/, 4];
1596
1697
  return [4 /*yield*/, this.references({
1597
- file: fileNode_1.getEmbeddedFilePath(),
1698
+ file: fileNode_2.getEmbeddedFilePath(),
1598
1699
  line: 1,
1599
1700
  offset: 22
1600
1701
  })];
@@ -2479,7 +2580,7 @@ var NaslServer = /** @class */ (function () {
2479
2580
  */
2480
2581
  NaslServer.prototype.getCurrentNodeKnownTypeAnnotation = function (node) {
2481
2582
  var _a;
2482
- if (node.concept === 'StringLiteral' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
2583
+ if (node.concept === 'StringLiteral' || node.concept === 'StringInterpolation' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
2483
2584
  var type = 'String';
2484
2585
  switch (node.concept) {
2485
2586
  case 'NullLiteral':
@@ -2496,7 +2597,7 @@ var NaslServer = /** @class */ (function () {
2496
2597
  return concepts_1.TypeAnnotation.createPrimitive('Boolean');
2497
2598
  }
2498
2599
  // Convert和new都是自身携带类型的,就不进行修改
2499
- if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && (node.calleeName === 'Convert' || node.calleeName === 'New')) {
2600
+ if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && (['Convert', 'New', 'FromString'].includes(node.calleeName))) {
2500
2601
  if (node.typeArguments.length) {
2501
2602
  return node.typeArguments[0];
2502
2603
  }
@@ -2578,6 +2679,9 @@ var NaslServer = /** @class */ (function () {
2578
2679
  'Return',
2579
2680
  'Variable',
2580
2681
  'Match',
2682
+ 'NewComposite',
2683
+ 'NewList',
2684
+ 'NewMap',
2581
2685
  ].includes(node.concept))
2582
2686
  return;
2583
2687
  // 要去ls那边获取的
@@ -2629,6 +2733,13 @@ var NaslServer = /** @class */ (function () {
2629
2733
  newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
2630
2734
  fileDetail.offset = newCode.length + 'return '.length;
2631
2735
  }
2736
+ else if (['NewComposite', 'NewList', 'NewMap'].includes(node.concept)) {
2737
+ fileDetail.line = item.range.end.line;
2738
+ var indexOf = item.code.indexOf('return __newComposite');
2739
+ var newCode = item.code.substring(0, indexOf);
2740
+ newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
2741
+ fileDetail.offset = newCode.length + 'return '.length;
2742
+ }
2632
2743
  args.push(fileDetail);
2633
2744
  });
2634
2745
  console.time('请求');
@@ -2689,6 +2800,10 @@ var NaslServer = /** @class */ (function () {
2689
2800
  node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
2690
2801
  }
2691
2802
  }
2803
+ else {
2804
+ // 清空原来已经赋值上去的类型,可能原来有现在没有了
2805
+ node.__TypeAnnotation = null;
2806
+ }
2692
2807
  }
2693
2808
  catch (err) {
2694
2809
  if (globalThis.window) {
@@ -2985,7 +3100,8 @@ var NaslServer = /** @class */ (function () {
2985
3100
  option: { defaultValue: param.defaultValue }
2986
3101
  };
2987
3102
  };
2988
- NaslServer.prototype.getCurrentTypeAnnotation = function (node) {
3103
+ NaslServer.prototype.getCurrentTypeAnnotation = function (node, outTime) {
3104
+ if (outTime === void 0) { outTime = 600; }
2989
3105
  return __awaiter(this, void 0, void 0, function () {
2990
3106
  return __generator(this, function (_a) {
2991
3107
  if (node.__TypeAnnotation) {
@@ -3002,7 +3118,7 @@ var NaslServer = /** @class */ (function () {
3002
3118
  else {
3003
3119
  resolve(null);
3004
3120
  }
3005
- }, 600);
3121
+ }, outTime);
3006
3122
  var mySetInterval = setInterval(function () {
3007
3123
  if (node.__isCorrectTypeAnnotation) {
3008
3124
  resolve(node.__TypeAnnotation);
@@ -3153,7 +3269,7 @@ var NaslServer = /** @class */ (function () {
3153
3269
  NaslServer.prototype.handleRename = function (fileNode, targetNode, result, oldFilePath) {
3154
3270
  var _a, _b, _c, _d, _e, _f;
3155
3271
  return __awaiter(this, void 0, void 0, function () {
3156
- var outputFiles, oldRefs, newRefs, newRefFileList_1, newRefs2, _g, currentSource, fileNode_2, oldRefs, newRefs2;
3272
+ var outputFiles, oldRefs, newRefs, newRefFileList_1, newRefs2, _g, currentSource, fileNode_3, oldRefs, newRefs2;
3157
3273
  return __generator(this, function (_h) {
3158
3274
  switch (_h.label) {
3159
3275
  case 0:
@@ -3215,10 +3331,10 @@ var NaslServer = /** @class */ (function () {
3215
3331
  newRefs2.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3216
3332
  return [3 /*break*/, 11];
3217
3333
  case 7:
3218
- _g = this.getCurrentSource(targetNode), currentSource = _g.currentSource, fileNode_2 = _g.fileNode;
3334
+ _g = this.getCurrentSource(targetNode), currentSource = _g.currentSource, fileNode_3 = _g.fileNode;
3219
3335
  if (!currentSource) return [3 /*break*/, 11];
3220
3336
  return [4 /*yield*/, this.references({
3221
- file: fileNode_2.getEmbeddedFilePath(),
3337
+ file: fileNode_3.getEmbeddedFilePath(),
3222
3338
  line: translator_1.lsp2tspNumber(currentSource.range.start.line),
3223
3339
  offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
3224
3340
  })];
@@ -3231,7 +3347,7 @@ var NaslServer = /** @class */ (function () {
3231
3347
  // 更新文件之后
3232
3348
  _h.sent();
3233
3349
  return [4 /*yield*/, this.references({
3234
- file: fileNode_2.getEmbeddedFilePath(),
3350
+ file: fileNode_3.getEmbeddedFilePath(),
3235
3351
  line: translator_1.lsp2tspNumber(currentSource.range.start.line),
3236
3352
  offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
3237
3353
  })];