@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3

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 (380) hide show
  1. package/out/automate/upgrader/2.20.js.map +1 -1
  2. package/out/bak/translator.js +52 -1
  3. package/out/bak/translator.js.map +1 -1
  4. package/out/breakpoint/shared/utils.js +0 -2
  5. package/out/breakpoint/shared/utils.js.map +1 -1
  6. package/out/common/Command.d.ts +1 -0
  7. package/out/common/Command.js +9 -1
  8. package/out/common/Command.js.map +1 -1
  9. package/out/concepts/Abort__.js +2 -1
  10. package/out/concepts/Abort__.js.map +1 -1
  11. package/out/concepts/Anchor__.js +1 -1
  12. package/out/concepts/Anchor__.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.js +2 -2
  14. package/out/concepts/AnonymousFunction__.js.map +1 -1
  15. package/out/concepts/Argument__.js +1 -1
  16. package/out/concepts/Argument__.js.map +1 -1
  17. package/out/concepts/Assignee__.js.map +1 -1
  18. package/out/concepts/AssignmentLine__.js +1 -1
  19. package/out/concepts/AssignmentLine__.js.map +1 -1
  20. package/out/concepts/Assignment__.js +2 -2
  21. package/out/concepts/Assignment__.js.map +1 -1
  22. package/out/concepts/BackendVariable__.js +1 -1
  23. package/out/concepts/BackendVariable__.js.map +1 -1
  24. package/out/concepts/Backend__.js +1 -1
  25. package/out/concepts/Backend__.js.map +1 -1
  26. package/out/concepts/BatchAssignment__.js +2 -2
  27. package/out/concepts/BatchAssignment__.js.map +1 -1
  28. package/out/concepts/BinaryExpression__.js +2 -2
  29. package/out/concepts/BinaryExpression__.js.map +1 -1
  30. package/out/concepts/BindAttribute__.d.ts +2 -0
  31. package/out/concepts/BindAttribute__.js +79 -4
  32. package/out/concepts/BindAttribute__.js.map +1 -1
  33. package/out/concepts/BindDirective__.js +1 -1
  34. package/out/concepts/BindDirective__.js.map +1 -1
  35. package/out/concepts/BindEvent__.d.ts +2 -1
  36. package/out/concepts/BindEvent__.js +44 -37
  37. package/out/concepts/BindEvent__.js.map +1 -1
  38. package/out/concepts/BindStyle__.js +1 -1
  39. package/out/concepts/BindStyle__.js.map +1 -1
  40. package/out/concepts/BooleanLiteral__.js +1 -1
  41. package/out/concepts/BooleanLiteral__.js.map +1 -1
  42. package/out/concepts/CallAuthInterface__.js +1 -1
  43. package/out/concepts/CallAuthInterface__.js.map +1 -1
  44. package/out/concepts/CallConnector__.js +1 -1
  45. package/out/concepts/CallConnector__.js.map +1 -1
  46. package/out/concepts/CallFunction__.js +2 -2
  47. package/out/concepts/CallFunction__.js.map +1 -1
  48. package/out/concepts/CallInterface__.js +2 -2
  49. package/out/concepts/CallInterface__.js.map +1 -1
  50. package/out/concepts/CallLogic__.js +69 -12
  51. package/out/concepts/CallLogic__.js.map +1 -1
  52. package/out/concepts/CallQueryComponent__.d.ts +1 -1
  53. package/out/concepts/CallQueryComponent__.js +1 -1
  54. package/out/concepts/CallQueryComponent__.js.map +1 -1
  55. package/out/concepts/Comment__.js +1 -1
  56. package/out/concepts/Comment__.js.map +1 -1
  57. package/out/concepts/ConfigProperty__.js +1 -1
  58. package/out/concepts/ConfigProperty__.js.map +1 -1
  59. package/out/concepts/Connection__.js +9 -10
  60. package/out/concepts/Connection__.js.map +1 -1
  61. package/out/concepts/Constant__.js +1 -1
  62. package/out/concepts/Constant__.js.map +1 -1
  63. package/out/concepts/DataSource__.js +1 -1
  64. package/out/concepts/DataSource__.js.map +1 -1
  65. package/out/concepts/Destination__.js +2 -2
  66. package/out/concepts/Destination__.js.map +1 -1
  67. package/out/concepts/End__.js +1 -1
  68. package/out/concepts/End__.js.map +1 -1
  69. package/out/concepts/EntityIndex__.js +1 -1
  70. package/out/concepts/EntityIndex__.js.map +1 -1
  71. package/out/concepts/EntityProperty__.js +2 -2
  72. package/out/concepts/EntityProperty__.js.map +1 -1
  73. package/out/concepts/Entity__.js +2 -2
  74. package/out/concepts/Entity__.js.map +1 -1
  75. package/out/concepts/EnumItem__.js +2 -2
  76. package/out/concepts/EnumItem__.js.map +1 -1
  77. package/out/concepts/Enum__.js +2 -2
  78. package/out/concepts/Enum__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +27 -37
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Frontend__.js +1 -1
  82. package/out/concepts/Frontend__.js.map +1 -1
  83. package/out/concepts/Function__.js +2 -2
  84. package/out/concepts/Function__.js.map +1 -1
  85. package/out/concepts/Identifier__.js +1 -1
  86. package/out/concepts/Identifier__.js.map +1 -1
  87. package/out/concepts/IfStatement__.js +2 -2
  88. package/out/concepts/IfStatement__.js.map +1 -1
  89. package/out/concepts/Interface__.js +1 -1
  90. package/out/concepts/Interface__.js.map +1 -1
  91. package/out/concepts/JSBlock__.js +1 -1
  92. package/out/concepts/JSBlock__.js.map +1 -1
  93. package/out/concepts/JavaLogic__.js +1 -1
  94. package/out/concepts/JavaLogic__.js.map +1 -1
  95. package/out/concepts/LogicItem__.js +3 -2
  96. package/out/concepts/LogicItem__.js.map +1 -1
  97. package/out/concepts/Logic__.js +2 -1
  98. package/out/concepts/Logic__.js.map +1 -1
  99. package/out/concepts/MatchCase__.js +1 -1
  100. package/out/concepts/MatchCase__.js.map +1 -1
  101. package/out/concepts/Match__.js +2 -2
  102. package/out/concepts/Match__.js.map +1 -1
  103. package/out/concepts/MemberExpression__.d.ts +1 -0
  104. package/out/concepts/MemberExpression__.js +117 -2
  105. package/out/concepts/MemberExpression__.js.map +1 -1
  106. package/out/concepts/Module__.d.ts +1 -1
  107. package/out/concepts/Module__.js +34 -35
  108. package/out/concepts/Module__.js.map +1 -1
  109. package/out/concepts/NewComposite__.js +2 -2
  110. package/out/concepts/NewComposite__.js.map +1 -1
  111. package/out/concepts/NewList__.js +2 -2
  112. package/out/concepts/NewList__.js.map +1 -1
  113. package/out/concepts/NewMap__.js +2 -2
  114. package/out/concepts/NewMap__.js.map +1 -1
  115. package/out/concepts/New__.js +1 -1
  116. package/out/concepts/New__.js.map +1 -1
  117. package/out/concepts/NullLiteral__.js +1 -1
  118. package/out/concepts/NullLiteral__.js.map +1 -1
  119. package/out/concepts/NumericLiteral__.js +1 -1
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/OqlQueryComponent__.js +2 -2
  122. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  123. package/out/concepts/Param__.js +1 -1
  124. package/out/concepts/Param__.js.map +1 -1
  125. package/out/concepts/ProcessElement__.js +1 -1
  126. package/out/concepts/ProcessElement__.js.map +1 -1
  127. package/out/concepts/ProcessOutcome__.js +1 -1
  128. package/out/concepts/ProcessOutcome__.js.map +1 -1
  129. package/out/concepts/ProcessOutcomes__.js +1 -1
  130. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  131. package/out/concepts/Process__.js +1 -1
  132. package/out/concepts/Process__.js.map +1 -1
  133. package/out/concepts/QueryAggregateExpression__.js +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  135. package/out/concepts/QueryFieldExpression__.js +1 -1
  136. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  137. package/out/concepts/QueryFromExpression__.js +1 -1
  138. package/out/concepts/QueryFromExpression__.js.map +1 -1
  139. package/out/concepts/QueryJoinExpression__.js +1 -1
  140. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  141. package/out/concepts/QueryLimitExpression__.js +1 -1
  142. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  143. package/out/concepts/QueryOrderByExpression__.js +1 -1
  144. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  145. package/out/concepts/Return__.js +2 -2
  146. package/out/concepts/Return__.js.map +1 -1
  147. package/out/concepts/Role__.js +1 -1
  148. package/out/concepts/Role__.js.map +1 -1
  149. package/out/concepts/SelectMembers__.js +1 -1
  150. package/out/concepts/SelectMembers__.js.map +1 -1
  151. package/out/concepts/SqlQueryComponent__.js +2 -2
  152. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  153. package/out/concepts/Start__.js +1 -1
  154. package/out/concepts/Start__.js.map +1 -1
  155. package/out/concepts/StringInterpolation__.js +2 -2
  156. package/out/concepts/StringInterpolation__.js.map +1 -1
  157. package/out/concepts/StringLiteral__.js +1 -1
  158. package/out/concepts/StringLiteral__.js.map +1 -1
  159. package/out/concepts/StructureProperty__.js +2 -2
  160. package/out/concepts/StructureProperty__.js.map +1 -1
  161. package/out/concepts/Structure__.js +2 -2
  162. package/out/concepts/Structure__.js.map +1 -1
  163. package/out/concepts/SwitchCase__.js +1 -1
  164. package/out/concepts/SwitchCase__.js.map +1 -1
  165. package/out/concepts/SwitchStatement__.js +2 -2
  166. package/out/concepts/SwitchStatement__.js.map +1 -1
  167. package/out/concepts/TriggerLauncher__.js +1 -1
  168. package/out/concepts/TriggerLauncher__.js.map +1 -1
  169. package/out/concepts/TypeAnnotation__.d.ts +4 -3
  170. package/out/concepts/TypeAnnotation__.js +116 -75
  171. package/out/concepts/TypeAnnotation__.js.map +1 -1
  172. package/out/concepts/TypeParam__.js +1 -1
  173. package/out/concepts/TypeParam__.js.map +1 -1
  174. package/out/concepts/UnaryExpression__.js +2 -2
  175. package/out/concepts/UnaryExpression__.js.map +1 -1
  176. package/out/concepts/ValidationRule__.d.ts +14 -14
  177. package/out/concepts/ValidationRule__.js +28 -24
  178. package/out/concepts/ValidationRule__.js.map +1 -1
  179. package/out/concepts/Variable__.js +2 -2
  180. package/out/concepts/Variable__.js.map +1 -1
  181. package/out/concepts/ViewElement__.d.ts +88 -87
  182. package/out/concepts/ViewElement__.js +268 -204
  183. package/out/concepts/ViewElement__.js.map +1 -1
  184. package/out/concepts/View__.d.ts +6 -0
  185. package/out/concepts/View__.js +254 -11
  186. package/out/concepts/View__.js.map +1 -1
  187. package/out/concepts/WhileStatement__.js +2 -2
  188. package/out/concepts/WhileStatement__.js.map +1 -1
  189. package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
  190. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.event.js +2 -0
  192. package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
  193. package/out/generator/genBundleFiles.js +90 -1
  194. package/out/generator/genBundleFiles.js.map +1 -1
  195. package/out/generator/genReleaseBody.js +1 -1
  196. package/out/generator/genReleaseBody.js.map +1 -1
  197. package/out/generator/permission.js +3 -3
  198. package/out/generator/permission.js.map +1 -1
  199. package/out/index.d.ts +1 -0
  200. package/out/index.js +1 -0
  201. package/out/index.js.map +1 -1
  202. package/out/natural/genNaturalTS.js +7 -3
  203. package/out/natural/genNaturalTS.js.map +1 -1
  204. package/out/natural/knowledgeMap.js +12 -12
  205. package/out/natural/knowledgeMap.js.map +1 -1
  206. package/out/natural/transformTSCode.d.ts +1 -1
  207. package/out/natural/transformTSCode.js +115 -141
  208. package/out/natural/transformTSCode.js.map +1 -1
  209. package/out/server/extendBaseNode.js +69 -44
  210. package/out/server/extendBaseNode.js.map +1 -1
  211. package/out/server/formatTsUtils.js +72 -63
  212. package/out/server/formatTsUtils.js.map +1 -1
  213. package/out/server/getLogics.js +20 -23
  214. package/out/server/getLogics.js.map +1 -1
  215. package/out/server/getMemberIdentifier.d.ts +1 -0
  216. package/out/server/getMemberIdentifier.js +149 -1
  217. package/out/server/getMemberIdentifier.js.map +1 -1
  218. package/out/server/naslServer.d.ts +3 -3
  219. package/out/server/naslServer.js +182 -132
  220. package/out/server/naslServer.js.map +1 -1
  221. package/out/server/translator.js +43 -33
  222. package/out/server/translator.js.map +1 -1
  223. package/out/service/defaultErrorMessage.json +6 -6
  224. package/out/service/storage/init.js +16 -0
  225. package/out/service/storage/init.js.map +1 -1
  226. package/out/templator/genCreateBlock.js +5 -3
  227. package/out/templator/genCreateBlock.js.map +1 -1
  228. package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
  229. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  230. package/out/templator/genCurdMultipleKeyBlock.js +8 -7
  231. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  232. package/out/templator/genEditTableBlock.d.ts +1 -1
  233. package/out/templator/genEditTableBlock.js +12 -6
  234. package/out/templator/genEditTableBlock.js.map +1 -1
  235. package/out/templator/genEnumSelectBlock.js +2 -2
  236. package/out/templator/genEnumSelectBlock.js.map +1 -1
  237. package/out/templator/genGetBlock.js +1 -1
  238. package/out/templator/genGetBlock.js.map +1 -1
  239. package/out/templator/genGridViewBlock.d.ts +2 -2
  240. package/out/templator/genGridViewBlock.js +20 -7
  241. package/out/templator/genGridViewBlock.js.map +1 -1
  242. package/out/templator/genListViewBlock.d.ts +2 -2
  243. package/out/templator/genListViewBlock.js +13 -5
  244. package/out/templator/genListViewBlock.js.map +1 -1
  245. package/out/templator/genSelectBlock.d.ts +2 -2
  246. package/out/templator/genSelectBlock.js +8 -6
  247. package/out/templator/genSelectBlock.js.map +1 -1
  248. package/out/templator/genTableBlock.d.ts +1 -1
  249. package/out/templator/genTableBlock.js +10 -5
  250. package/out/templator/genTableBlock.js.map +1 -1
  251. package/out/templator/genUpdateBlock.js +5 -3
  252. package/out/templator/genUpdateBlock.js.map +1 -1
  253. package/package.json +3 -1
  254. package/sandbox/stdlib/nasl.auth.ts +40 -44
  255. package/sandbox/stdlib/nasl.core.ts +8 -1
  256. package/sandbox/stdlib/nasl.http.ts +22 -22
  257. package/sandbox-natural/stdlib/nasl.util.ts +74 -15
  258. package/src/automate/upgrader/2.20.js +17 -13
  259. package/src/bak/translator.js +50 -1
  260. package/src/breakpoint/shared/utils.ts +0 -2
  261. package/src/common/Command.ts +8 -0
  262. package/src/concepts/Abort__.ts +2 -2
  263. package/src/concepts/Anchor__.ts +2 -2
  264. package/src/concepts/AnonymousFunction__.ts +3 -3
  265. package/src/concepts/Argument__.ts +2 -2
  266. package/src/concepts/Assignee__.ts +1 -1
  267. package/src/concepts/AssignmentLine__.ts +2 -2
  268. package/src/concepts/Assignment__.ts +3 -3
  269. package/src/concepts/BackendVariable__.ts +2 -2
  270. package/src/concepts/Backend__.ts +1 -1
  271. package/src/concepts/BatchAssignment__.ts +3 -3
  272. package/src/concepts/BinaryExpression__.ts +3 -3
  273. package/src/concepts/BindAttribute__.ts +69 -4
  274. package/src/concepts/BindDirective__.ts +2 -2
  275. package/src/concepts/BindEvent__.ts +44 -64
  276. package/src/concepts/BindStyle__.ts +2 -2
  277. package/src/concepts/BooleanLiteral__.ts +2 -2
  278. package/src/concepts/CallAuthInterface__.ts +2 -2
  279. package/src/concepts/CallConnector__.ts +2 -2
  280. package/src/concepts/CallFunction__.ts +3 -3
  281. package/src/concepts/CallInterface__.ts +3 -3
  282. package/src/concepts/CallLogic__.ts +69 -13
  283. package/src/concepts/CallQueryComponent__.ts +2 -2
  284. package/src/concepts/Comment__.ts +2 -2
  285. package/src/concepts/ConfigProperty__.ts +2 -2
  286. package/src/concepts/Connection__.ts +15 -21
  287. package/src/concepts/Constant__.ts +2 -2
  288. package/src/concepts/DataSource__.ts +1 -1
  289. package/src/concepts/Destination__.ts +3 -3
  290. package/src/concepts/End__.ts +2 -2
  291. package/src/concepts/EntityIndex__.ts +2 -2
  292. package/src/concepts/EntityProperty__.ts +3 -3
  293. package/src/concepts/Entity__.ts +2 -2
  294. package/src/concepts/EnumItem__.ts +3 -3
  295. package/src/concepts/Enum__.ts +2 -2
  296. package/src/concepts/ForEachStatement__.ts +35 -46
  297. package/src/concepts/Frontend__.ts +1 -1
  298. package/src/concepts/Function__.ts +3 -3
  299. package/src/concepts/Identifier__.ts +2 -2
  300. package/src/concepts/IfStatement__.ts +3 -3
  301. package/src/concepts/Interface__.ts +1 -1
  302. package/src/concepts/JSBlock__.ts +2 -2
  303. package/src/concepts/JavaLogic__.ts +2 -2
  304. package/src/concepts/LogicItem__.ts +3 -3
  305. package/src/concepts/Logic__.ts +2 -1
  306. package/src/concepts/MatchCase__.ts +2 -2
  307. package/src/concepts/Match__.ts +3 -3
  308. package/src/concepts/MemberExpression__.ts +112 -4
  309. package/src/concepts/Module__.ts +41 -58
  310. package/src/concepts/NewComposite__.ts +3 -3
  311. package/src/concepts/NewList__.ts +3 -3
  312. package/src/concepts/NewMap__.ts +3 -3
  313. package/src/concepts/New__.ts +2 -2
  314. package/src/concepts/NullLiteral__.ts +2 -2
  315. package/src/concepts/NumericLiteral__.ts +2 -2
  316. package/src/concepts/OqlQueryComponent__.ts +3 -3
  317. package/src/concepts/Param__.ts +2 -2
  318. package/src/concepts/ProcessElement__.ts +2 -2
  319. package/src/concepts/ProcessOutcome__.ts +2 -2
  320. package/src/concepts/ProcessOutcomes__.ts +2 -2
  321. package/src/concepts/Process__.ts +1 -1
  322. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  323. package/src/concepts/QueryFieldExpression__.ts +2 -2
  324. package/src/concepts/QueryFromExpression__.ts +2 -2
  325. package/src/concepts/QueryJoinExpression__.ts +2 -2
  326. package/src/concepts/QueryLimitExpression__.ts +2 -2
  327. package/src/concepts/QueryOrderByExpression__.ts +2 -2
  328. package/src/concepts/Return__.ts +3 -3
  329. package/src/concepts/Role__.ts +1 -1
  330. package/src/concepts/SelectMembers__.ts +2 -2
  331. package/src/concepts/SqlQueryComponent__.ts +3 -3
  332. package/src/concepts/Start__.ts +2 -2
  333. package/src/concepts/StringInterpolation__.ts +3 -3
  334. package/src/concepts/StringLiteral__.ts +2 -2
  335. package/src/concepts/StructureProperty__.ts +3 -3
  336. package/src/concepts/Structure__.ts +2 -2
  337. package/src/concepts/SwitchCase__.ts +2 -2
  338. package/src/concepts/SwitchStatement__.ts +3 -3
  339. package/src/concepts/TriggerLauncher__.ts +1 -1
  340. package/src/concepts/TypeAnnotation__.ts +145 -125
  341. package/src/concepts/TypeParam__.ts +2 -2
  342. package/src/concepts/UnaryExpression__.ts +3 -3
  343. package/src/concepts/ValidationRule__.ts +554 -524
  344. package/src/concepts/Variable__.ts +3 -3
  345. package/src/concepts/ViewElement__.ts +2445 -2498
  346. package/src/concepts/View__.ts +258 -10
  347. package/src/concepts/WhileStatement__.ts +3 -3
  348. package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
  349. package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
  350. package/src/generator/genBundleFiles.ts +91 -1
  351. package/src/generator/genReleaseBody.ts +1 -1
  352. package/src/generator/permission.ts +3 -3
  353. package/src/index.ts +1 -0
  354. package/src/natural/genNaturalTS.ts +8 -4
  355. package/src/natural/knowledgeMap.ts +12 -12
  356. package/src/natural/transformTSCode.ts +139 -151
  357. package/src/server/extendBaseNode.ts +71 -45
  358. package/src/server/formatTsUtils.ts +64 -64
  359. package/src/server/getLogics.ts +23 -30
  360. package/src/server/getMemberIdentifier.ts +143 -0
  361. package/src/server/naslServer.ts +174 -148
  362. package/src/server/translator.ts +40 -39
  363. package/src/service/defaultErrorMessage.json +6 -6
  364. package/src/service/storage/init.ts +17 -0
  365. package/src/templator/genCreateBlock.ts +5 -3
  366. package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
  367. package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
  368. package/src/templator/genEditTableBlock.ts +12 -7
  369. package/src/templator/genEnumSelectBlock.ts +2 -2
  370. package/src/templator/genGetBlock.ts +6 -6
  371. package/src/templator/genGridViewBlock.ts +22 -9
  372. package/src/templator/genListViewBlock.ts +14 -5
  373. package/src/templator/genSelectBlock.ts +8 -6
  374. package/src/templator/genTableBlock.ts +10 -9
  375. package/src/templator/genUpdateBlock.ts +5 -3
  376. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
  377. package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
  378. package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
  379. package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
  380. package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
@@ -37,11 +37,11 @@ exports.NaslServer = exports.getDisplayString2Type = void 0;
37
37
  const fs = __importStar(require("fs-extra"));
38
38
  const path = __importStar(require("path"));
39
39
  const worker_threads_1 = require("worker_threads");
40
- const decimal_js_1 = require("decimal.js");
40
+ /// #endif
41
41
  const config_1 = require("../config");
42
42
  const sentry_1 = require("../sentry");
43
43
  const Messager_1 = __importDefault(require("../common/Messager"));
44
- const getMemberIdentifier_1 = require("./getMemberIdentifier");
44
+ const getMemberIdentifier_1 = require("../server/getMemberIdentifier");
45
45
  const concepts_1 = require("../concepts");
46
46
  const translator_1 = require("../translator");
47
47
  const storage_1 = __importDefault(require("../service/storage"));
@@ -57,6 +57,7 @@ const jsoner = __importStar(require("../service/storage/jsoner"));
57
57
  const EventEmitter_1 = require("../common/EventEmitter");
58
58
  const utils_1 = require("../utils");
59
59
  const decorators_1 = require("../decorators");
60
+ const decimal_js_1 = require("decimal.js");
60
61
  const utils_2 = require("../automate/engine/utils");
61
62
  const EmbeddedTSFileLineMap = {
62
63
  Entity: 3,
@@ -69,9 +70,9 @@ const EmbeddedTSFileOffsetMap = {
69
70
  ConfigProperty: 12,
70
71
  };
71
72
  const SentryMessager = (0, sentry_1.sentryMonitorTSWorkerMessager)(Messager_1.default);
72
- let isChangeInterface = false; // 判断是否导入接口
73
- let actionArr = []; // 用于导入接口收集更改的节点
74
- let timer = null; // 超时器用于收集导入接口相关
73
+ let isChangeInterface = false; //判断是否导入接口
74
+ let actionArr = []; //用于导入接口收集更改的节点
75
+ let timer = null; //超时器用于收集导入接口相关
75
76
  const __naslStdlibFileCacheMap = new Map(); // naslStdlib文件缓存
76
77
  // 联合类型切割取出类型
77
78
  function getDisplayString2Type(displayString) {
@@ -90,17 +91,19 @@ function getDisplayString2Type(displayString) {
90
91
  if (/<([^()]+)>/g.exec(item)) {
91
92
  return item;
92
93
  }
93
- if (item.includes(' ')) {
94
+ else if (item.includes(' ')) {
94
95
  const strs = item.split(' ');
95
96
  const type = strs[strs.length - 1];
96
97
  return type;
97
98
  }
98
- if (item.includes('.')) {
99
+ else if (item.includes('.')) {
99
100
  const strs = item.split('.');
100
101
  const type = strs[strs.length - 1];
101
102
  return type;
102
103
  }
103
- return item;
104
+ else {
105
+ return item;
106
+ }
104
107
  });
105
108
  if (targetType) {
106
109
  return typeList.filter((item) => item !== targetType);
@@ -187,7 +190,7 @@ let NaslServer = class NaslServer {
187
190
  // 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
188
191
  // @ts-ignore
189
192
  const findLastIndex = this.changeStackList.findLastIndex((changeStackItem) => {
190
- const { target } = changeStackItem;
193
+ const target = changeStackItem.target;
191
194
  const { fileNode: targetFileNode } = this.getCurrentSource(target);
192
195
  return targetFileNode === fileNode;
193
196
  });
@@ -198,8 +201,10 @@ let NaslServer = class NaslServer {
198
201
  // 如果当前列表里有,这个文件节点,最后一个是field的话,直接return掉,不用塞这个update了
199
202
  return;
200
203
  }
201
- // 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
202
- this.changeStackList.pop();
204
+ else {
205
+ // 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
206
+ this.changeStackList.pop();
207
+ }
203
208
  }
204
209
  this.changeStackList.push(item.originEvent);
205
210
  }
@@ -229,7 +234,7 @@ let NaslServer = class NaslServer {
229
234
  }, { cache: true });
230
235
  Object.keys(naslStdlibMap_1.default).forEach(async (libFileName) => {
231
236
  await this.addFile({
232
- file: `/${libFileName}`,
237
+ file: '/' + libFileName,
233
238
  fileContent: naslStdlibMap_1.default[libFileName],
234
239
  }, { cache: true });
235
240
  });
@@ -449,7 +454,7 @@ let NaslServer = class NaslServer {
449
454
  });
450
455
  }
451
456
  if (module instanceof concepts_1.App) {
452
- module.connections.forEach((connection) => {
457
+ module.connections?.forEach?.((connection) => {
453
458
  try {
454
459
  const result = connection.toEmbeddedTSFile();
455
460
  results.push(result);
@@ -459,7 +464,7 @@ let NaslServer = class NaslServer {
459
464
  }
460
465
  catch (err) { }
461
466
  });
462
- module.triggerLaunchers.forEach((triggerLauncher) => {
467
+ module.triggerLaunchers?.forEach?.((triggerLauncher) => {
463
468
  try {
464
469
  const result = triggerLauncher.toEmbeddedTSFile();
465
470
  results.push(result);
@@ -556,7 +561,7 @@ let NaslServer = class NaslServer {
556
561
  cacheFile(options) {
557
562
  __naslStdlibFileCacheMap.set(options.file, options);
558
563
  }
559
- /** u
564
+ /**u
560
565
  * 只新增文件
561
566
  * @param {*} files
562
567
  */
@@ -585,15 +590,15 @@ let NaslServer = class NaslServer {
585
590
  }
586
591
  /// #if process.env.NODE_ENV === 'development'
587
592
  // 首次尝试请求
588
- await storage_1.default.post(`/api/App/debugEmbedded?id=${app.id}`, openFiles[0]).catch(() => (openDebugEmbedded = false));
593
+ await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, openFiles[0]).catch(() => (openDebugEmbedded = false));
589
594
  if (openDebugEmbedded && globalThis.window) {
590
595
  // For TS build
591
596
  try {
592
597
  let canDebug = true;
593
- await storage_1.default.post(`/api/App/debugEmbedded?id=${app.id}`, openFiles[0]).catch(() => (canDebug = false));
598
+ await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, openFiles[0]).catch(() => (canDebug = false));
594
599
  if (canDebug) {
595
600
  await Promise.all(openFiles.map(async (file) => {
596
- const res = await storage_1.default.post(`/api/App/debugEmbedded?id=${app.id}`, file);
601
+ const res = await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, file);
597
602
  return res.data;
598
603
  }));
599
604
  }
@@ -642,7 +647,9 @@ let NaslServer = class NaslServer {
642
647
  noFilterList,
643
648
  });
644
649
  }
645
- console.log('没找到节点', node, currentSource, fileNode);
650
+ else {
651
+ console.log('没找到节点', node, currentSource, fileNode);
652
+ }
646
653
  }
647
654
  _getValueSelectCompletion(args) {
648
655
  return this.messager.requestCommand('getValueSelectCompletion', args);
@@ -686,7 +693,9 @@ let NaslServer = class NaslServer {
686
693
  if (!res.length) {
687
694
  return [];
688
695
  }
689
- return [{ title: '基础类型', children: res }];
696
+ else {
697
+ return [{ title: '基础类型', children: res }];
698
+ }
690
699
  }
691
700
  }
692
701
  catch (err) {
@@ -732,7 +741,7 @@ let NaslServer = class NaslServer {
732
741
  .replace(/__name:"AStructure_\w{8}";/g, '')
733
742
  .replace(/dataSources.([^.]+).entities.([^;]+)/g, ($1, $2, $3) => `${$3}(${$2})`);
734
743
  }
735
- if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
744
+ else if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
736
745
  /**
737
746
  * {
738
747
  text: nasl.core.String;
@@ -785,7 +794,7 @@ let NaslServer = class NaslServer {
785
794
  return;
786
795
  const types = /<([^()]+)>/g.exec(displayString);
787
796
  const typeStr = types && types[1];
788
- const { app } = node;
797
+ const app = node.app;
789
798
  if (typeStr.includes('__name: "AStructure_')) {
790
799
  const properties = [];
791
800
  typeStr.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
@@ -807,7 +816,7 @@ let NaslServer = class NaslServer {
807
816
  });
808
817
  return concepts_1.TypeAnnotation.createTypeAnonymousStructure(properties);
809
818
  }
810
- if (typeStr.startsWith('structures'))
819
+ else if (typeStr.startsWith('structures'))
811
820
  return app.findNodeByCompleteName(`app.${typeStr}`);
812
821
  }
813
822
  }
@@ -865,7 +874,9 @@ let NaslServer = class NaslServer {
865
874
  noFilterList,
866
875
  });
867
876
  }
868
- console.log('没找到节点', currentSource, fileNode);
877
+ else {
878
+ console.log('没找到节点', currentSource, fileNode);
879
+ }
869
880
  }
870
881
  _getSelectNextCompletion(args) {
871
882
  return this.messager.requestCommand('getSelectNextCompletion', args);
@@ -893,7 +904,7 @@ let NaslServer = class NaslServer {
893
904
  await this.IncrementalAnnotationJSON(records);
894
905
  }
895
906
  await Promise.all(records.map(async (record) => {
896
- const { node } = record;
907
+ const node = record.node;
897
908
  if (!node)
898
909
  return;
899
910
  // 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
@@ -947,7 +958,7 @@ let NaslServer = class NaslServer {
947
958
  record.suggestionDiagnostics.push(diagnostic);
948
959
  return null;
949
960
  }
950
- if (currentNode.concept === 'OqlQueryComponent') {
961
+ else if (currentNode.concept === 'OqlQueryComponent') {
951
962
  // OQL别名错误降级为警告
952
963
  if (diagnostic.originalDiagnostic && diagnostic.originalDiagnostic?.text.includes('__OQL_ALIAS_WARNING__')) {
953
964
  // 重置 图标和错误等级
@@ -991,7 +1002,7 @@ let NaslServer = class NaslServer {
991
1002
  return diag;
992
1003
  // 一些已知警告的单独处理
993
1004
  }
994
- if ([
1005
+ else if ([
995
1006
  `'__LogicEmpty' is declared but its value is never read.`,
996
1007
  `'__destinationEmpty__' is declared but its value is never read.`,
997
1008
  `'__devConfigValueEmpty' is declared but its value is never read.`,
@@ -1000,7 +1011,7 @@ let NaslServer = class NaslServer {
1000
1011
  ].includes(diag.text)) {
1001
1012
  return this._resolveDiagnostic(diag, record.node, record);
1002
1013
  }
1003
- if (diag.text.includes(` is declared but its value is never read.`)) {
1014
+ else if (diag.text.includes(` is declared but its value is never read.`)) {
1004
1015
  // 局部变量和输入变量未使用的警告
1005
1016
  const fromModule = record.node.parentNode.concept === 'Module';
1006
1017
  const fromConnector = record.node.parentNode.concept === 'Connector';
@@ -1028,7 +1039,7 @@ let NaslServer = class NaslServer {
1028
1039
  };
1029
1040
  return diagnostic;
1030
1041
  }
1031
- if (minRange.node instanceof concepts_1.Variable) {
1042
+ else if (minRange.node instanceof concepts_1.Variable) {
1032
1043
  const diagnostic = {
1033
1044
  node: minRange.node,
1034
1045
  severity: 'warning',
@@ -1209,7 +1220,7 @@ let NaslServer = class NaslServer {
1209
1220
  const typeAnnotation = item.__TypeAnnotation;
1210
1221
  // 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
1211
1222
  if (typeAnnotation) {
1212
- const { sortedTypeKey } = typeAnnotation;
1223
+ const sortedTypeKey = typeAnnotation.sortedTypeKey;
1213
1224
  if (!typeAnnotationMap[sortedTypeKey]) {
1214
1225
  typeAnnotationMap[sortedTypeKey] = {
1215
1226
  typeAnnotation,
@@ -1263,7 +1274,7 @@ let NaslServer = class NaslServer {
1263
1274
  const typeAnnotation = value.__TypeAnnotation;
1264
1275
  // 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
1265
1276
  if (typeAnnotation) {
1266
- const { sortedTypeKey } = typeAnnotation;
1277
+ const sortedTypeKey = typeAnnotation.sortedTypeKey;
1267
1278
  if (!typeAnnotationMap[sortedTypeKey]) {
1268
1279
  typeAnnotationMap[sortedTypeKey] = {
1269
1280
  typeAnnotation,
@@ -1535,17 +1546,17 @@ let NaslServer = class NaslServer {
1535
1546
  catch (err) {
1536
1547
  console.log(err);
1537
1548
  }
1538
- if (!jsCode.includes(`${node.name} = `))
1549
+ if (!jsCode.startsWith(`${node.name} = `))
1539
1550
  return;
1540
1551
  // 页面局部变量
1541
1552
  if (node instanceof concepts_1.Variable && node.parentNode instanceof concepts_1.View) {
1542
1553
  // 跟页面局部变量无关的赋值过滤
1543
- if (!jsCode.includes(`this.${node.name} = `))
1554
+ if (!jsCode.startsWith(`this.${node.name} = `))
1544
1555
  return;
1545
1556
  // 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
1546
- if (nodeIn.logic?.params.find((param) => jsCode.includes(param.name)) ||
1547
- nodeIn.logic?.virtualParams.find((vParam) => jsCode.includes(vParam.name)) ||
1548
- nodeIn.logic?.variables.find((variable) => jsCode.includes(variable.name))) {
1557
+ if (nodeIn.logic?.params.find((param) => jsCode.startsWith(param.name)) ||
1558
+ nodeIn.logic?.virtualParams.find((vParam) => jsCode.startsWith(vParam.name)) ||
1559
+ nodeIn.logic?.variables.find((variable) => jsCode.startsWith(variable.name))) {
1549
1560
  if (!nodeIn.tsErrorDetail) {
1550
1561
  const diagnostic = {
1551
1562
  node: nodeIn,
@@ -1585,17 +1596,17 @@ let NaslServer = class NaslServer {
1585
1596
  if (Array.isArray(node.bindExpressions)) {
1586
1597
  const exp = node.bindExpressions.find((bindExpression) => this.hasComponentLogics(bindExpression));
1587
1598
  if (exp) {
1588
- // const element: any = node.getAncestor('ViewElement');
1589
- // const api = config.allNodesAPI[element?.tag];
1590
- // const attr = api?.attrs?.find?.((attr) => {
1599
+ //const element: any = node.getAncestor('ViewElement');
1600
+ //const api = config.allNodesAPI[element?.tag];
1601
+ //const attr = api?.attrs?.find?.((attr) => {
1591
1602
  // return attr.name === node.name;
1592
- // });
1603
+ //});
1593
1604
  const map = {
1594
1605
  BindAttribute: '属性',
1595
1606
  BindDirective: '指令',
1596
1607
  BindStyle: '样式属性',
1597
1608
  };
1598
- // “${attr?.title || node.title || node.name}”
1609
+ //“${attr?.title || node.title || node.name}”
1599
1610
  const diagnostic = {
1600
1611
  node,
1601
1612
  severity: 'error',
@@ -1767,7 +1778,7 @@ let NaslServer = class NaslServer {
1767
1778
  const { default: defaultVal } = precisionOption || {};
1768
1779
  const precision = databaseTypeAnnotation ? databaseTypeAnnotation.arguments?.precision : defaultVal;
1769
1780
  const ruleScale = typeAnnotation?.ruleMap?.scale;
1770
- const scale = ruleScale !== undefined ? `${ruleScale}` : '';
1781
+ const scale = ruleScale !== undefined ? ruleScale + '' : '';
1771
1782
  let ensureScale = true;
1772
1783
  switch (typeName) {
1773
1784
  case 'String': {
@@ -1866,7 +1877,7 @@ let NaslServer = class NaslServer {
1866
1877
  // 储存小数部分
1867
1878
  const memoryScaleStr = memoryStr.slice(0, +(scale || '0'));
1868
1879
  // 储存绝对值
1869
- const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ? `.${memoryScaleStr}` : '');
1880
+ const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ? '.' + memoryScaleStr : '');
1870
1881
  const decimalMemoryAbsVal = new decimal_js_1.Decimal(memoryAbsVal);
1871
1882
  [
1872
1883
  {
@@ -1934,7 +1945,7 @@ let NaslServer = class NaslServer {
1934
1945
  diagnostics.push(diagnostic);
1935
1946
  }
1936
1947
  fileNode?.sourceMap.forEach((value, node) => {
1937
- // OQL支持返回复合类型数据了
1948
+ //OQL支持返回复合类型数据了
1938
1949
  // SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
1939
1950
  // if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
1940
1951
  // const diagnostic = {
@@ -1950,7 +1961,7 @@ let NaslServer = class NaslServer {
1950
1961
  const typeAnnotation = (0, formatTsUtils_1.type2TypeAnnotation)(node.__nodeType);
1951
1962
  if (!node.typeAnnotation && typeAnnotation) {
1952
1963
  if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
1953
- const { typeArguments } = typeAnnotation;
1964
+ const typeArguments = typeAnnotation.typeArguments;
1954
1965
  if (typeArguments.length && typeArguments[0].isComplexType()) {
1955
1966
  const diagnostic = {
1956
1967
  node,
@@ -1976,7 +1987,7 @@ let NaslServer = class NaslServer {
1976
1987
  catch (err) {
1977
1988
  console.log(err);
1978
1989
  }
1979
- if (jsCode.includes(`${node.name} = `)) {
1990
+ if (jsCode.startsWith(`${node.name} = `)) {
1980
1991
  used = true;
1981
1992
  if (!nodeIn.tsErrorDetail) {
1982
1993
  const diagnostic = {
@@ -2157,6 +2168,17 @@ let NaslServer = class NaslServer {
2157
2168
  node.tsErrorDetail = diagnostic;
2158
2169
  diagnostics.push(diagnostic);
2159
2170
  }
2171
+ if (node instanceof concepts_1.ForEachStatement && !node.end && node.each) {
2172
+ if (!['List'].includes(node.each.__TypeAnnotation?.typeName)) {
2173
+ const diagnostic = {
2174
+ node,
2175
+ severity: 'error',
2176
+ message: `ForEac1:循环列表:参数类型不匹配!结束值自动推导失败。`,
2177
+ };
2178
+ node.tsErrorDetail = diagnostic;
2179
+ diagnostics.push(diagnostic);
2180
+ }
2181
+ }
2160
2182
  /**
2161
2183
  * 如果节点是内置函数
2162
2184
  * 穷举在线上的情况,不在线上就void报错, callinterface 因为原来有报错,所以就忽略掉
@@ -2235,7 +2257,7 @@ let NaslServer = class NaslServer {
2235
2257
  if (excludeList.includes(leftType.sortedTypeKey) && excludeList.includes(rightType.sortedTypeKey)) {
2236
2258
  return null;
2237
2259
  }
2238
- if (excludeList2.includes(leftType.sortedTypeKey) || excludeList2.includes(rightType.sortedTypeKey)) {
2260
+ else if (excludeList2.includes(leftType.sortedTypeKey) || excludeList2.includes(rightType.sortedTypeKey)) {
2239
2261
  return null;
2240
2262
  }
2241
2263
  const diagnostic = {
@@ -2272,7 +2294,7 @@ let NaslServer = class NaslServer {
2272
2294
  if (typeKeyArr[0] === 'apis') {
2273
2295
  const structureName = typeKeyArr[3];
2274
2296
  const moduleName = typeKeyArr[1];
2275
- const { app } = typeAnnotation.upperNode;
2297
+ const app = typeAnnotation.upperNode.app;
2276
2298
  if (!app) {
2277
2299
  return null;
2278
2300
  }
@@ -2289,13 +2311,15 @@ let NaslServer = class NaslServer {
2289
2311
  }
2290
2312
  return null;
2291
2313
  }
2292
- return diag;
2314
+ else {
2315
+ return diag;
2316
+ }
2293
2317
  });
2294
2318
  if (actionArr.length) {
2295
2319
  if (timer)
2296
2320
  return;
2297
2321
  timer = window.setTimeout(() => {
2298
- const { app } = actionArr[0].target;
2322
+ const app = actionArr[0].target.app;
2299
2323
  app.emit('collect:start', {
2300
2324
  actionMsg: '设置导入接口数据类型错误',
2301
2325
  });
@@ -2357,7 +2381,9 @@ let NaslServer = class NaslServer {
2357
2381
  */
2358
2382
  _findMinRange(diagnostic, fileNode) {
2359
2383
  let minRange;
2360
- const { sourceMap } = fileNode;
2384
+ const sourceMap = fileNode.sourceMap;
2385
+ // 是否找到了行内准确的,是的话,就不走多行的
2386
+ let haveLineNode = false;
2361
2387
  for (const [node, item] of sourceMap.entries()) {
2362
2388
  /**
2363
2389
  * 当前内容的开始行 <= 诊断开始的行 &&
@@ -2375,6 +2401,7 @@ let NaslServer = class NaslServer {
2375
2401
  // if for的内容也是包括当前的所以会重新赋值
2376
2402
  if (!minRange || item.code.length < minRange.item.code.length) {
2377
2403
  minRange = { item, node };
2404
+ haveLineNode = true;
2378
2405
  }
2379
2406
  }
2380
2407
  }
@@ -2384,28 +2411,32 @@ let NaslServer = class NaslServer {
2384
2411
  if (!minRange) {
2385
2412
  minRange = { node, item };
2386
2413
  }
2387
- else if ((0, translator_1.lsp2tspNumber)(item.range.start.line) === diagnostic.start.line &&
2388
- diagnostic.start.offset >= (0, translator_1.lsp2tspNumber)(item.range.start.character)) {
2389
- // 如果当前遍历的内容的行和列都 小于之前的, 而且是有效的
2390
- // 如果两个内容位置行数是一样的,就比较下找到内容的位置信息
2391
- // 找到的内容的开始位置, 要大于申明内容开始的位置,要不就不包含在内了
2392
- if (diagnostic.start.offset - item.range.start.character <= diagnostic.start.offset - minRange.item.range.start.character) {
2393
- minRange = { node, item };
2394
- }
2395
- else if (diagnostic.start.offset < (0, translator_1.lsp2tspNumber)(minRange.item.range.start.character)) {
2396
- minRange = { node, item };
2397
- }
2398
- }
2399
- else if (item.range.end.line - item.range.start.line <= minRange.item.range.end.line - minRange.item.range.start.line) {
2400
- // 行都一致 ,比较列
2401
- if (minRange.item.range.start.line === item.range.start.line && minRange.item.range.end.line === item.range.end.line) {
2402
- // 如果两个起始和结束的行都一样,那么就比较开始列, 要比原来大,说明更精准
2403
- if (item.range.start.character > minRange.item.range.start.character) {
2414
+ else if (!haveLineNode) {
2415
+ if ((0, translator_1.lsp2tspNumber)(item.range.start.line) === diagnostic.start.line &&
2416
+ diagnostic.start.offset >= (0, translator_1.lsp2tspNumber)(item.range.start.character)) {
2417
+ // 如果当前遍历的内容的行和列都 小于之前的, 而且是有效的
2418
+ // 如果两个内容位置行数是一样的,就比较下找到内容的位置信息
2419
+ // 找到的内容的开始位置, 要大于申明内容开始的位置,要不就不包含在内了
2420
+ if (diagnostic.start.offset - item.range.start.character <= diagnostic.start.offset - minRange.item.range.start.character) {
2404
2421
  minRange = { node, item };
2405
2422
  }
2423
+ else {
2424
+ if (diagnostic.start.offset < (0, translator_1.lsp2tspNumber)(minRange.item.range.start.character)) {
2425
+ minRange = { node, item };
2426
+ }
2427
+ }
2406
2428
  }
2407
- else {
2408
- minRange = { node, item };
2429
+ else if (item.range.end.line - item.range.start.line <= minRange.item.range.end.line - minRange.item.range.start.line) {
2430
+ // 行都一致 ,比较列
2431
+ if (minRange.item.range.start.line === item.range.start.line && minRange.item.range.end.line === item.range.end.line) {
2432
+ // 如果两个起始和结束的行都一样,那么就比较开始列, 要比原来大,说明更精准
2433
+ if (item.range.start.character > minRange.item.range.start.character) {
2434
+ minRange = { node, item };
2435
+ }
2436
+ }
2437
+ else {
2438
+ minRange = { node, item };
2439
+ }
2409
2440
  }
2410
2441
  }
2411
2442
  }
@@ -2438,21 +2469,23 @@ let NaslServer = class NaslServer {
2438
2469
  });
2439
2470
  refsList = [...newRefs.refs];
2440
2471
  }
2441
- else if (node instanceof concepts_1.Module) {
2442
- const lists = node.logics || node.structures || node.enums;
2443
- const moduleName = fileNode.getEmbeddedFilePath();
2444
- if (lists.length) {
2445
- const item = lists[0];
2446
- const { fileNode } = this.getCurrentSource(item);
2447
- if (fileNode) {
2448
- const newRefs = await this.references({
2449
- file: fileNode.getEmbeddedFilePath(),
2450
- line: 1,
2451
- offset: 22, // 固定的位置,module的位置信息
2452
- });
2453
- refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
2454
- // 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
2455
- refsList.unshift(newRefs.refs[0]);
2472
+ else {
2473
+ if (node instanceof concepts_1.Module) {
2474
+ const lists = node.logics || node.structures || node.enums;
2475
+ const moduleName = fileNode.getEmbeddedFilePath();
2476
+ if (lists.length) {
2477
+ const item = lists[0];
2478
+ const { fileNode } = this.getCurrentSource(item);
2479
+ if (fileNode) {
2480
+ const newRefs = await this.references({
2481
+ file: fileNode.getEmbeddedFilePath(),
2482
+ line: 1,
2483
+ offset: 22, //固定的位置,module的位置信息
2484
+ });
2485
+ refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
2486
+ // 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
2487
+ refsList.unshift(newRefs.refs[0]);
2488
+ }
2456
2489
  }
2457
2490
  }
2458
2491
  }
@@ -2511,7 +2544,7 @@ let NaslServer = class NaslServer {
2511
2544
  const groupByLength = callQueryComponent.groupBy.filter((item) => item.groupElement?.propertyName && item.groupElement.asName).length;
2512
2545
  if (!groupByLength && !aggregateLength && callQueryComponentTypeAnnotation.typeKind === 'anonymousStructure') {
2513
2546
  // 拿到 List 的泛型(匿名数据结构)的所有属性
2514
- const { properties } = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0];
2547
+ const properties = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0].properties;
2515
2548
  const targetProperty = properties.find((p) => p.name === utils.firstLowerCase(node.name));
2516
2549
  if (!targetProperty) {
2517
2550
  continue;
@@ -2561,7 +2594,7 @@ let NaslServer = class NaslServer {
2561
2594
  if (node instanceof concepts_1.Param && (node.parentNode instanceof concepts_1.View || node.parentNode instanceof concepts_1.Process)) {
2562
2595
  const viewNode = node.parentNode;
2563
2596
  const { currentSource } = this.getCurrentSource(viewNode);
2564
- const { code } = currentSource;
2597
+ const code = currentSource.code;
2565
2598
  const viewIndex = code.indexOf(' {');
2566
2599
  const viewRefs = await this.references({
2567
2600
  file: fileNode.getEmbeddedFilePath(),
@@ -2600,7 +2633,7 @@ let NaslServer = class NaslServer {
2600
2633
  */
2601
2634
  if (node instanceof concepts_1.ViewElement) {
2602
2635
  if (currentSource) {
2603
- const { code } = currentSource;
2636
+ const code = currentSource.code;
2604
2637
  const prefix = '__elements.';
2605
2638
  const prefixIndex = code.indexOf(prefix) !== -1 ? code.indexOf(prefix) : 0;
2606
2639
  const methodsNameIndex = prefixIndex + prefix.length;
@@ -2625,7 +2658,7 @@ let NaslServer = class NaslServer {
2625
2658
  }
2626
2659
  if (node instanceof concepts_1.Process) {
2627
2660
  if (currentSource) {
2628
- const { code } = currentSource;
2661
+ const code = currentSource.code;
2629
2662
  const prefix = '__ProcessIdentification__';
2630
2663
  let positions = [];
2631
2664
  let pos = code.indexOf(prefix);
@@ -2650,7 +2683,7 @@ let NaslServer = class NaslServer {
2650
2683
  if ((node instanceof concepts_1.Param || node instanceof concepts_1.Return) && node.parentNode instanceof concepts_1.Process) {
2651
2684
  const { currentSource } = this.getCurrentSource(node.parentNode);
2652
2685
  if (currentSource) {
2653
- const { code } = currentSource;
2686
+ const code = currentSource.code;
2654
2687
  const prefix = '__ProcessIdentification__';
2655
2688
  const positions = [];
2656
2689
  let pos = code.indexOf(prefix);
@@ -2678,7 +2711,7 @@ let NaslServer = class NaslServer {
2678
2711
  }
2679
2712
  if (node instanceof concepts_1.ProcessElement) {
2680
2713
  if (currentSource) {
2681
- const { code } = currentSource;
2714
+ const code = currentSource.code;
2682
2715
  const prefix = '__ProcessIdentification__';
2683
2716
  let positions = [];
2684
2717
  let pos = code.indexOf(prefix);
@@ -2702,7 +2735,7 @@ let NaslServer = class NaslServer {
2702
2735
  if (node instanceof concepts_1.Return && node.parentNode instanceof concepts_1.ProcessElement) {
2703
2736
  const { currentSource } = this.getCurrentSource(node.parentNode);
2704
2737
  if (currentSource) {
2705
- const { code } = currentSource;
2738
+ const code = currentSource.code;
2706
2739
  const prefix = '__ProcessIdentification__';
2707
2740
  const positions = [];
2708
2741
  let pos = code.indexOf(prefix);
@@ -2766,13 +2799,16 @@ let NaslServer = class NaslServer {
2766
2799
  // }
2767
2800
  minRange.setTypeMethods = 'setTypeName';
2768
2801
  }
2802
+ if (minRange.node instanceof concepts_1.CallConnector) {
2803
+ minRange.setTypeMethods = 'setCalleeConnectionName';
2804
+ }
2769
2805
  // 如果节点是logic修改引发calllogic修改
2770
2806
  if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Logic) {
2771
2807
  minRange.setTypeMethods = 'setCalleeName';
2772
2808
  }
2773
2809
  if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.ViewElement) {
2774
2810
  minRange.setTypeMethods = 'setCalleeNamespace';
2775
- minRange.newValue = `elements.${newValue}.logics`;
2811
+ minRange.newValue = 'elements.' + newValue + '.logics';
2776
2812
  }
2777
2813
  // 如果节点是实体修改引发calllogic修改
2778
2814
  if (minRange.node instanceof concepts_1.CallLogic &&
@@ -2789,9 +2825,9 @@ let NaslServer = class NaslServer {
2789
2825
  * 3.然后把namespace中的 $替换成 ''
2790
2826
  *
2791
2827
  */
2792
- const { tsCalleeNamespace } = minRange.node;
2828
+ const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
2793
2829
  // 先看下标位置
2794
- const { lineText } = record;
2830
+ const lineText = record.lineText;
2795
2831
  const index = lineText.indexOf(tsCalleeNamespace);
2796
2832
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
2797
2833
  const start = record.start.offset - index - 1;
@@ -2826,12 +2862,12 @@ let NaslServer = class NaslServer {
2826
2862
  if (minRange.node instanceof concepts_1.Identifier) {
2827
2863
  // 匹配到的内容,当前这一行的内容;
2828
2864
  // 因为要用下面的点位信息
2829
- const { name } = minRange.node;
2865
+ const name = minRange.node.name;
2830
2866
  // 如果name不改,那就是要改命名空间
2831
2867
  if (node instanceof concepts_1.Frontend || newValue === name) {
2832
- const { namespace } = minRange.node;
2868
+ const namespace = minRange.node.namespace;
2833
2869
  // 先看下标位置
2834
- const { lineText } = record;
2870
+ const lineText = record.lineText;
2835
2871
  const index = lineText.indexOf(namespace);
2836
2872
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
2837
2873
  const start = record.start.offset - index - 1;
@@ -2863,7 +2899,7 @@ let NaslServer = class NaslServer {
2863
2899
  // 枚举key的特殊性,因为它不是原来的key+value形式的
2864
2900
  // 是加了中括号啥的,所以直接赋值新值
2865
2901
  if (node instanceof concepts_1.EnumItem) {
2866
- const newTextValue = `${node.parentNode.name}.${newValue}`;
2902
+ const newTextValue = node.parentNode.name + '.' + newValue;
2867
2903
  minRange.newValue = newTextValue;
2868
2904
  }
2869
2905
  else {
@@ -2903,7 +2939,7 @@ let NaslServer = class NaslServer {
2903
2939
  }
2904
2940
  else if (minRange.node instanceof concepts_1.BindAttribute && minRange.node.name === 'url') {
2905
2941
  // 如果是查找到 上传地址的链接引用
2906
- let newName = newValue.replace(/[A-Z]/g, (item) => `-${item.toLowerCase()}`);
2942
+ let newName = newValue.replace(/[A-Z]/g, (item) => '-' + item.toLowerCase());
2907
2943
  newName = newName[0] === '-' ? newName.slice(1) : newName;
2908
2944
  const newTextValue = node.parentNode.name === 'defaultDS' ? `/api/${newName}/import` : `/api/${node.parentNode.name}/${newName}/import`;
2909
2945
  minRange.setTypeMethods = 'setUrlValue';
@@ -2943,11 +2979,11 @@ let NaslServer = class NaslServer {
2943
2979
  * 3.然后把namespace中的 $替换成 ''
2944
2980
  *
2945
2981
  */
2946
- const { tsCalleeNamespace } = minRange.node;
2947
- const { tsName } = minRange.node;
2948
- const oldValue = `${tsCalleeNamespace}.${tsName}`;
2982
+ const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
2983
+ const tsName = minRange.node.tsName;
2984
+ const oldValue = tsCalleeNamespace + '.' + tsName;
2949
2985
  // 先看下标位置
2950
- const { lineText } = record;
2986
+ const lineText = record.lineText;
2951
2987
  const index = lineText.indexOf(oldValue);
2952
2988
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
2953
2989
  const start = record.start.offset - index - 1;
@@ -2965,11 +3001,11 @@ let NaslServer = class NaslServer {
2965
3001
  }
2966
3002
  }
2967
3003
  if (node instanceof concepts_1.Frontend && minRange.node instanceof concepts_1.Destination) {
2968
- const { tsCalleeNamespace } = minRange.node;
2969
- const { tsName } = minRange.node;
2970
- const oldValue = `${tsCalleeNamespace}.${tsName}`;
3004
+ const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
3005
+ const tsName = minRange.node.tsName;
3006
+ const oldValue = tsCalleeNamespace + '.' + tsName;
2971
3007
  // 先看下标位置
2972
- const { lineText } = record;
3008
+ const lineText = record.lineText;
2973
3009
  const index = lineText.indexOf(oldValue);
2974
3010
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
2975
3011
  const start = record.start.offset - index - 1;
@@ -2989,7 +3025,7 @@ let NaslServer = class NaslServer {
2989
3025
  // 页面逻辑直接赋值就可以, 因为是相对路径
2990
3026
  if (node instanceof concepts_1.ViewElement) {
2991
3027
  minRange.setTypeMethods = 'setCalleeNamespace';
2992
- minRange.newValue = `elements.${newValue}.logics`;
3028
+ minRange.newValue = 'elements.' + newValue + '.logics';
2993
3029
  }
2994
3030
  else {
2995
3031
  /**
@@ -3001,10 +3037,10 @@ let NaslServer = class NaslServer {
3001
3037
  * 2.在匹配到的内容中取转后的namespace的位置
3002
3038
  * 3.然后把namespace中的 $替换成 ''
3003
3039
  */
3004
- const { tsCalleeNamespace } = minRange.node;
3040
+ const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
3005
3041
  const oldValue = tsCalleeNamespace;
3006
3042
  // 先看下标位置
3007
- const { lineText } = record;
3043
+ const lineText = record.lineText;
3008
3044
  const index = lineText.indexOf(oldValue);
3009
3045
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
3010
3046
  const start = record.start.offset - index - 1;
@@ -3067,7 +3103,7 @@ let NaslServer = class NaslServer {
3067
3103
  if (node instanceof concepts_1.DataSource) {
3068
3104
  const setTypeNamespace = (typeNamespace, record) => {
3069
3105
  // 先看下标位置
3070
- const { lineText } = record;
3106
+ const lineText = record.lineText;
3071
3107
  const index = lineText.indexOf(typeNamespace);
3072
3108
  // 在把开始结束位置的-开始位置,来知道是哪里要替换
3073
3109
  const start = record.start.offset - index - 1;
@@ -3193,7 +3229,7 @@ let NaslServer = class NaslServer {
3193
3229
  if (a.node.concept === 'QueryFieldExpression') {
3194
3230
  return 1;
3195
3231
  }
3196
- if (b.node.concept === 'QueryFieldExpression') {
3232
+ else if (b.node.concept === 'QueryFieldExpression') {
3197
3233
  return -1;
3198
3234
  }
3199
3235
  return 0;
@@ -3321,7 +3357,7 @@ let NaslServer = class NaslServer {
3321
3357
  const queue = [];
3322
3358
  // 先插入自己,如果没有在往上找,
3323
3359
  // 一直到file节点的父级
3324
- while (!(parantNode instanceof concepts_1.App)) {
3360
+ while (parantNode && !(parantNode instanceof concepts_1.App)) {
3325
3361
  // 找到上一级 在map对象中构造出他的子集
3326
3362
  currentNode = parantNode;
3327
3363
  parantNode = parantNode.parentNode;
@@ -3441,7 +3477,7 @@ let NaslServer = class NaslServer {
3441
3477
  getCurrentSource(node) {
3442
3478
  if (node instanceof concepts_1.App || node instanceof concepts_1.Theme)
3443
3479
  return { fileNode: null };
3444
- let { sourceMap } = node;
3480
+ let sourceMap = node.sourceMap;
3445
3481
  let fileNode = node;
3446
3482
  // 如果没有sourceMap,就继续向上找 ,或者到module结束
3447
3483
  // 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
@@ -3479,16 +3515,30 @@ let NaslServer = class NaslServer {
3479
3515
  getFieldKeySelectCompletion(node, fieldKey) {
3480
3516
  const { currentSource, fileNode } = this.getCurrentSource(node);
3481
3517
  if (currentSource && fileNode) {
3518
+ const range = {
3519
+ line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
3520
+ offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
3521
+ };
3522
+ // foreach 在最后一行自动补全
3523
+ if (node.concept === 'ForEachStatement') {
3524
+ range.line = currentSource.range.end.line;
3525
+ range.offset = 0;
3526
+ }
3527
+ else if (node.concept === 'BindAttribute') {
3528
+ range.offset = range.offset + 7;
3529
+ }
3530
+ else if (node.concept === 'BindDirective') {
3531
+ range.offset = range.offset + 5;
3532
+ }
3482
3533
  return this._getFieldKeySelectCompletion({
3483
3534
  file: fileNode.getEmbeddedFilePath(),
3484
- range: {
3485
- line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
3486
- offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
3487
- },
3535
+ range,
3488
3536
  getFieldKey: fieldKey,
3489
3537
  });
3490
3538
  }
3491
- console.log('没找到节点', currentSource, fileNode);
3539
+ else {
3540
+ console.log('没找到节点', currentSource, fileNode);
3541
+ }
3492
3542
  }
3493
3543
  _getFieldKeySelectCompletion(args) {
3494
3544
  return this.messager.requestCommand('getFieldKeySelectCompletion', args);
@@ -3536,7 +3586,7 @@ let NaslServer = class NaslServer {
3536
3586
  });
3537
3587
  return [...fileNodes];
3538
3588
  }
3539
- /** 获取当前节点的已知类型
3589
+ /**获取当前节点的已知类型
3540
3590
  * @param node 当前要获取类型的节点
3541
3591
  * @returns 不需要去查就可以返回类型的节点
3542
3592
  */
@@ -3689,7 +3739,7 @@ let NaslServer = class NaslServer {
3689
3739
  const lastLen = codeArr?.[codeArr.length - 1]?.length;
3690
3740
  indexOf = subStr.length - lastLen;
3691
3741
  }
3692
- fileDetail.offset += indexOf;
3742
+ fileDetail.offset = fileDetail.offset + indexOf;
3693
3743
  }
3694
3744
  else if (node.concept === 'MemberExpression' ||
3695
3745
  node.concept === 'Identifier' ||
@@ -3700,7 +3750,7 @@ let NaslServer = class NaslServer {
3700
3750
  const lastLen = codeArr?.[codeArr.length - 1]?.length;
3701
3751
  // MemberExpression取最后一位当做类型
3702
3752
  const indexOf = item.code.length - lastLen;
3703
- fileDetail.offset += indexOf;
3753
+ fileDetail.offset = fileDetail.offset + indexOf;
3704
3754
  }
3705
3755
  }
3706
3756
  else if (node.concept === 'Match') {
@@ -3733,7 +3783,7 @@ let NaslServer = class NaslServer {
3733
3783
  const item = resultMap?.[file]?.[line]?.[offset];
3734
3784
  const itemType = item?.[0]?.nodeType;
3735
3785
  const nodeTypeAnnotation = (0, formatTsUtils_1.type2TypeAnnotation)(itemType);
3736
- const { node } = newQuickInfoNodes[index];
3786
+ const node = newQuickInfoNodes[index].node;
3737
3787
  types.set(node, Object.freeze(nodeTypeAnnotation));
3738
3788
  node.__nodeType = itemType ? (Object.isFrozen(itemType) ? itemType : Object.freeze(itemType)) : null;
3739
3789
  });
@@ -3769,7 +3819,7 @@ let NaslServer = class NaslServer {
3769
3819
  const typeAnnotation = value;
3770
3820
  if (!node.typeAnnotation && typeAnnotation) {
3771
3821
  if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
3772
- const { typeArguments } = typeAnnotation;
3822
+ const typeArguments = typeAnnotation.typeArguments;
3773
3823
  if (typeArguments.length && typeArguments[0].isComplexType()) {
3774
3824
  node.__TypeAnnotation = null;
3775
3825
  return;
@@ -3800,7 +3850,7 @@ let NaslServer = class NaslServer {
3800
3850
  // 全量标注并且返回json
3801
3851
  async getNaslAnnotatedJSON(app, releaseFlag) {
3802
3852
  if (this.changeStackList?.length) {
3803
- throw new Error(`当前还有${this.changeStackList.length}个文件还在执行更新操作,请稍后再试!或刷新后重试!`);
3853
+ throw new Error(`当前还有${this.changeStackList.length}个文件还在执行更新操作`);
3804
3854
  }
3805
3855
  const nodes = [];
3806
3856
  this.file2NodeMap.forEach((fileNode, filePath) => {
@@ -3985,7 +4035,7 @@ let NaslServer = class NaslServer {
3985
4035
  }
3986
4036
  }
3987
4037
  // 用户自己声明的用用户的
3988
- const callObj = App.findNodeByCompleteName(`${parent.calleeNamespace}.${parent.calleeName}`);
4038
+ const callObj = App.findNodeByCompleteName(parent.calleeNamespace + '.' + parent.calleeName);
3989
4039
  const index = parent.arguments.indexOf(node);
3990
4040
  const param = callObj?.params?.[index] || {};
3991
4041
  // 取出参数的类型
@@ -4245,7 +4295,7 @@ let NaslServer = class NaslServer {
4245
4295
  */
4246
4296
  async incidentalAction(action, fileNode, targetNode, oldpath) {
4247
4297
  if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
4248
- // 删除、更改、新增端
4298
+ //删除、更改、新增端
4249
4299
  if (fileNode instanceof concepts_1.Frontend && (fileNode.views?.length || fileNode.variables?.length)) {
4250
4300
  const fileNodeChildren = [...fileNode.views, ...fileNode.variables];
4251
4301
  for (let i = 0; i < fileNodeChildren.length; i++) {
@@ -4263,7 +4313,7 @@ let NaslServer = class NaslServer {
4263
4313
  else if (action === 'update' && oldpath) {
4264
4314
  const parentPath = oldpath.replace('.ts', '/');
4265
4315
  const foldName = fileNodeItem.concept === 'View' ? 'views' : 'variables';
4266
- const currentOldPath = `${parentPath + foldName}/${fileNodeItem.name}.ts`;
4316
+ const currentOldPath = parentPath + foldName + '/' + fileNodeItem.name + '.ts';
4267
4317
  // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
4268
4318
  await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
4269
4319
  await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
@@ -4287,7 +4337,7 @@ let NaslServer = class NaslServer {
4287
4337
  }
4288
4338
  else if (action === 'update' && oldpath) {
4289
4339
  const parentPath = oldpath.replace('.ts', '/');
4290
- const currentOldPath = `${parentPath + fileNodeItem.name}.ts`;
4340
+ const currentOldPath = parentPath + fileNodeItem.name + '.ts';
4291
4341
  // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
4292
4342
  await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
4293
4343
  await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
@@ -4332,7 +4382,7 @@ let NaslServer = class NaslServer {
4332
4382
  try {
4333
4383
  const result = entity.toEmbeddedTSFile();
4334
4384
  const parentPath = oldpath.replace('.ts', '/');
4335
- const currentOldPath = `${parentPath}/entities/${entity.name}.ts`;
4385
+ const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
4336
4386
  // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
4337
4387
  await this.handleRename(entity, entity, result, currentOldPath);
4338
4388
  }
@@ -4346,7 +4396,7 @@ let NaslServer = class NaslServer {
4346
4396
  async receiveHandleChange($event) {
4347
4397
  this.singleFileChangeIng = true;
4348
4398
  // 行为
4349
- const { action } = $event;
4399
+ const action = $event.action;
4350
4400
  const targetNode = $event.target;
4351
4401
  // Connection 相关配置的更新不需要写入文件
4352
4402
  if (targetNode?.parentNode instanceof concepts_1.Connection) {