@lcap/nasl 2.19.0-beta.1 → 2.19.0-beta.2

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 (516) hide show
  1. package/out/automate/engine/index.d.ts +2 -2
  2. package/out/automate/engine/index.js +6 -7
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +2 -2
  5. package/out/automate/engine/operators.js +14 -5
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +2 -2
  8. package/out/automate/engine/uniqueName.js +5 -5
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.js +4 -1
  11. package/out/automate/engine/utils.js.map +1 -1
  12. package/out/automate/template/myProcess.d.ts +1 -1
  13. package/out/automate/template/myProcess.js +9023 -9023
  14. package/out/automate/template/myProcess.js.map +1 -1
  15. package/out/bak/translator.js +16 -24
  16. package/out/bak/translator.js.map +1 -1
  17. package/out/common/BaseNode.d.ts +12 -0
  18. package/out/common/BaseNode.js +88 -14
  19. package/out/common/BaseNode.js.map +1 -1
  20. package/out/common/EventEmitter.d.ts +1 -0
  21. package/out/common/EventEmitter.js +3 -0
  22. package/out/common/EventEmitter.js.map +1 -1
  23. package/out/common/Messager.js +1 -0
  24. package/out/common/Messager.js.map +1 -1
  25. package/out/concepts/Abort__.d.ts +25 -0
  26. package/out/concepts/Abort__.js +80 -0
  27. package/out/concepts/Abort__.js.map +1 -0
  28. package/out/concepts/Anchor__.d.ts +1 -0
  29. package/out/concepts/Anchor__.js +3 -0
  30. package/out/concepts/Anchor__.js.map +1 -1
  31. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  32. package/out/concepts/AnonymousFunction__.js +3 -0
  33. package/out/concepts/AnonymousFunction__.js.map +1 -1
  34. package/out/concepts/App__.d.ts +99 -256
  35. package/out/concepts/App__.js +232 -405
  36. package/out/concepts/App__.js.map +1 -1
  37. package/out/concepts/Argument__.d.ts +1 -0
  38. package/out/concepts/Argument__.js +3 -0
  39. package/out/concepts/Argument__.js.map +1 -1
  40. package/out/concepts/Assignee__.d.ts +1 -0
  41. package/out/concepts/Assignee__.js +3 -0
  42. package/out/concepts/Assignee__.js.map +1 -1
  43. package/out/concepts/AssignmentLine__.d.ts +1 -0
  44. package/out/concepts/AssignmentLine__.js +3 -0
  45. package/out/concepts/AssignmentLine__.js.map +1 -1
  46. package/out/concepts/Assignment__.d.ts +1 -0
  47. package/out/concepts/Assignment__.js +3 -0
  48. package/out/concepts/Assignment__.js.map +1 -1
  49. package/out/concepts/Attribute__.d.ts +10 -14
  50. package/out/concepts/Attribute__.js +15 -39
  51. package/out/concepts/Attribute__.js.map +1 -1
  52. package/out/concepts/BatchAssignment__.d.ts +1 -0
  53. package/out/concepts/BatchAssignment__.js +6 -3
  54. package/out/concepts/BatchAssignment__.js.map +1 -1
  55. package/out/concepts/BinaryExpression__.d.ts +1 -0
  56. package/out/concepts/BinaryExpression__.js +3 -0
  57. package/out/concepts/BinaryExpression__.js.map +1 -1
  58. package/out/concepts/BindAttribute__.d.ts +13 -0
  59. package/out/concepts/BindAttribute__.js +296 -38
  60. package/out/concepts/BindAttribute__.js.map +1 -1
  61. package/out/concepts/BindDirective__.d.ts +13 -0
  62. package/out/concepts/BindDirective__.js +223 -15
  63. package/out/concepts/BindDirective__.js.map +1 -1
  64. package/out/concepts/BindEvent__.d.ts +6 -0
  65. package/out/concepts/BindEvent__.js +30 -22
  66. package/out/concepts/BindEvent__.js.map +1 -1
  67. package/out/concepts/BindStyle__.d.ts +13 -0
  68. package/out/concepts/BindStyle__.js +200 -1
  69. package/out/concepts/BindStyle__.js.map +1 -1
  70. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  71. package/out/concepts/BooleanLiteral__.js +3 -0
  72. package/out/concepts/BooleanLiteral__.js.map +1 -1
  73. package/out/concepts/CallFunction__.d.ts +1 -0
  74. package/out/concepts/CallFunction__.js +3 -0
  75. package/out/concepts/CallFunction__.js.map +1 -1
  76. package/out/concepts/CallInterface__.d.ts +2 -0
  77. package/out/concepts/CallInterface__.js +51 -5
  78. package/out/concepts/CallInterface__.js.map +1 -1
  79. package/out/concepts/CallLogic__.d.ts +12 -0
  80. package/out/concepts/CallLogic__.js +141 -131
  81. package/out/concepts/CallLogic__.js.map +1 -1
  82. package/out/concepts/CallQueryComponent__.d.ts +3 -0
  83. package/out/concepts/CallQueryComponent__.js +109 -38
  84. package/out/concepts/CallQueryComponent__.js.map +1 -1
  85. package/out/concepts/Comment__.d.ts +1 -0
  86. package/out/concepts/Comment__.js +3 -0
  87. package/out/concepts/Comment__.js.map +1 -1
  88. package/out/concepts/CompletionProperty__.d.ts +2 -0
  89. package/out/concepts/CompletionProperty__.js +4 -0
  90. package/out/concepts/CompletionProperty__.js.map +1 -1
  91. package/out/concepts/ConfigGroup__.d.ts +2 -0
  92. package/out/concepts/ConfigGroup__.js +16 -0
  93. package/out/concepts/ConfigGroup__.js.map +1 -1
  94. package/out/concepts/ConfigPropertyValue__.d.ts +1 -0
  95. package/out/concepts/ConfigPropertyValue__.js +3 -0
  96. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  97. package/out/concepts/ConfigProperty__.d.ts +24 -0
  98. package/out/concepts/ConfigProperty__.js +83 -0
  99. package/out/concepts/ConfigProperty__.js.map +1 -1
  100. package/out/concepts/Configuration__.d.ts +2 -0
  101. package/out/concepts/Configuration__.js +16 -0
  102. package/out/concepts/Configuration__.js.map +1 -1
  103. package/out/concepts/Constant__.d.ts +6 -0
  104. package/out/concepts/Constant__.js +9 -0
  105. package/out/concepts/Constant__.js.map +1 -1
  106. package/out/concepts/DataElement__.d.ts +1 -0
  107. package/out/concepts/DataElement__.js +3 -0
  108. package/out/concepts/DataElement__.js.map +1 -1
  109. package/out/concepts/DataSource__.d.ts +3 -0
  110. package/out/concepts/DataSource__.js +20 -5
  111. package/out/concepts/DataSource__.js.map +1 -1
  112. package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
  113. package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
  114. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
  115. package/out/concepts/Destination__.d.ts +3 -0
  116. package/out/concepts/Destination__.js +98 -16
  117. package/out/concepts/Destination__.js.map +1 -1
  118. package/out/concepts/End__.d.ts +1 -0
  119. package/out/concepts/End__.js +4 -1
  120. package/out/concepts/End__.js.map +1 -1
  121. package/out/concepts/EntityIndex__.d.ts +1 -0
  122. package/out/concepts/EntityIndex__.js +3 -0
  123. package/out/concepts/EntityIndex__.js.map +1 -1
  124. package/out/concepts/EntityProperty__.d.ts +34 -5
  125. package/out/concepts/EntityProperty__.js +197 -56
  126. package/out/concepts/EntityProperty__.js.map +1 -1
  127. package/out/concepts/Entity__.d.ts +3 -1
  128. package/out/concepts/Entity__.js +33 -1
  129. package/out/concepts/Entity__.js.map +1 -1
  130. package/out/concepts/EnumItem__.d.ts +6 -5
  131. package/out/concepts/EnumItem__.js +9 -6
  132. package/out/concepts/EnumItem__.js.map +1 -1
  133. package/out/concepts/Enum__.d.ts +21 -19
  134. package/out/concepts/Enum__.js +31 -1
  135. package/out/concepts/Enum__.js.map +1 -1
  136. package/out/concepts/Event__.d.ts +1 -0
  137. package/out/concepts/Event__.js +3 -0
  138. package/out/concepts/Event__.js.map +1 -1
  139. package/out/concepts/ExternalDestination__.d.ts +2 -0
  140. package/out/concepts/ExternalDestination__.js +25 -4
  141. package/out/concepts/ExternalDestination__.js.map +1 -1
  142. package/out/concepts/ForEachStatement__.d.ts +1 -0
  143. package/out/concepts/ForEachStatement__.js +4 -1
  144. package/out/concepts/ForEachStatement__.js.map +1 -1
  145. package/out/concepts/FrontendLibrary__.d.ts +213 -0
  146. package/out/concepts/FrontendLibrary__.js +352 -0
  147. package/out/concepts/FrontendLibrary__.js.map +1 -0
  148. package/out/concepts/Frontend__.d.ts +373 -0
  149. package/out/concepts/Frontend__.js +685 -0
  150. package/out/concepts/Frontend__.js.map +1 -0
  151. package/out/concepts/Function__.d.ts +1 -0
  152. package/out/concepts/Function__.js +3 -0
  153. package/out/concepts/Function__.js.map +1 -1
  154. package/out/concepts/Identifier__.d.ts +1 -0
  155. package/out/concepts/Identifier__.js +26 -5
  156. package/out/concepts/Identifier__.js.map +1 -1
  157. package/out/concepts/IfStatement__.d.ts +1 -0
  158. package/out/concepts/IfStatement__.js +5 -2
  159. package/out/concepts/IfStatement__.js.map +1 -1
  160. package/out/concepts/Integration__.d.ts +53 -0
  161. package/out/concepts/Integration__.js +143 -0
  162. package/out/concepts/Integration__.js.map +1 -0
  163. package/out/concepts/InterfaceParam__.d.ts +1 -3
  164. package/out/concepts/InterfaceParam__.js +3 -56
  165. package/out/concepts/InterfaceParam__.js.map +1 -1
  166. package/out/concepts/Interface__.d.ts +14 -0
  167. package/out/concepts/Interface__.js +87 -0
  168. package/out/concepts/Interface__.js.map +1 -1
  169. package/out/concepts/JSBlock__.d.ts +1 -0
  170. package/out/concepts/JSBlock__.js +8 -1
  171. package/out/concepts/JSBlock__.js.map +1 -1
  172. package/out/concepts/JavaLogic__.d.ts +42 -0
  173. package/out/concepts/JavaLogic__.js +122 -0
  174. package/out/concepts/JavaLogic__.js.map +1 -0
  175. package/out/concepts/LogicItem__.d.ts +7 -1
  176. package/out/concepts/LogicItem__.js +11 -0
  177. package/out/concepts/LogicItem__.js.map +1 -1
  178. package/out/concepts/Logic__.d.ts +7 -0
  179. package/out/concepts/Logic__.js +74 -17
  180. package/out/concepts/Logic__.js.map +1 -1
  181. package/out/concepts/MatchCase__.d.ts +1 -0
  182. package/out/concepts/MatchCase__.js +4 -1
  183. package/out/concepts/MatchCase__.js.map +1 -1
  184. package/out/concepts/Match__.d.ts +6 -3
  185. package/out/concepts/Match__.js +116 -20
  186. package/out/concepts/Match__.js.map +1 -1
  187. package/out/concepts/MemberExpression__.d.ts +1 -0
  188. package/out/concepts/MemberExpression__.js +14 -2
  189. package/out/concepts/MemberExpression__.js.map +1 -1
  190. package/out/concepts/MicroApp__.d.ts +51 -0
  191. package/out/concepts/MicroApp__.js +113 -0
  192. package/out/concepts/MicroApp__.js.map +1 -0
  193. package/out/concepts/Module__.d.ts +96 -56
  194. package/out/concepts/Module__.js +169 -58
  195. package/out/concepts/Module__.js.map +1 -1
  196. package/out/concepts/Namespace__.d.ts +1 -0
  197. package/out/concepts/Namespace__.js +3 -0
  198. package/out/concepts/Namespace__.js.map +1 -1
  199. package/out/concepts/NewComposite__.d.ts +4 -4
  200. package/out/concepts/NewComposite__.js +139 -122
  201. package/out/concepts/NewComposite__.js.map +1 -1
  202. package/out/concepts/NewList__.d.ts +2 -0
  203. package/out/concepts/NewList__.js +49 -24
  204. package/out/concepts/NewList__.js.map +1 -1
  205. package/out/concepts/NewMap__.d.ts +2 -0
  206. package/out/concepts/NewMap__.js +53 -23
  207. package/out/concepts/NewMap__.js.map +1 -1
  208. package/out/concepts/New__.d.ts +1 -0
  209. package/out/concepts/New__.js +3 -0
  210. package/out/concepts/New__.js.map +1 -1
  211. package/out/concepts/NullLiteral__.d.ts +1 -0
  212. package/out/concepts/NullLiteral__.js +3 -0
  213. package/out/concepts/NullLiteral__.js.map +1 -1
  214. package/out/concepts/NumericLiteral__.d.ts +1 -0
  215. package/out/concepts/NumericLiteral__.js +6 -9
  216. package/out/concepts/NumericLiteral__.js.map +1 -1
  217. package/out/concepts/OqlQueryComponent__.d.ts +1 -1
  218. package/out/concepts/OqlQueryComponent__.js +43 -58
  219. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  220. package/out/concepts/Param__.d.ts +7 -3
  221. package/out/concepts/Param__.js +17 -60
  222. package/out/concepts/Param__.js.map +1 -1
  223. package/out/concepts/Point__.d.ts +1 -0
  224. package/out/concepts/Point__.js +3 -0
  225. package/out/concepts/Point__.js.map +1 -1
  226. package/out/concepts/ProcessComponent__.d.ts +1 -0
  227. package/out/concepts/ProcessComponent__.js +3 -0
  228. package/out/concepts/ProcessComponent__.js.map +1 -1
  229. package/out/concepts/ProcessElement__.d.ts +1 -0
  230. package/out/concepts/ProcessElement__.js +16 -4
  231. package/out/concepts/ProcessElement__.js.map +1 -1
  232. package/out/concepts/ProcessOutcome__.d.ts +1 -0
  233. package/out/concepts/ProcessOutcome__.js +3 -0
  234. package/out/concepts/ProcessOutcome__.js.map +1 -1
  235. package/out/concepts/ProcessOutcomes__.d.ts +1 -0
  236. package/out/concepts/ProcessOutcomes__.js +3 -0
  237. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  238. package/out/concepts/Process__.d.ts +5 -20
  239. package/out/concepts/Process__.js +4 -7
  240. package/out/concepts/Process__.js.map +1 -1
  241. package/out/concepts/QueryAggregateExpression__.d.ts +1 -0
  242. package/out/concepts/QueryAggregateExpression__.js +3 -0
  243. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  244. package/out/concepts/QueryFieldExpression__.d.ts +1 -0
  245. package/out/concepts/QueryFieldExpression__.js +7 -1
  246. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  247. package/out/concepts/QueryFromExpression__.d.ts +1 -0
  248. package/out/concepts/QueryFromExpression__.js +3 -0
  249. package/out/concepts/QueryFromExpression__.js.map +1 -1
  250. package/out/concepts/QueryGroupByExpression__.d.ts +1 -0
  251. package/out/concepts/QueryGroupByExpression__.js +3 -0
  252. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  253. package/out/concepts/QueryJoinExpression__.d.ts +1 -0
  254. package/out/concepts/QueryJoinExpression__.js +3 -0
  255. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  256. package/out/concepts/QueryLimitExpression__.d.ts +1 -0
  257. package/out/concepts/QueryLimitExpression__.js +3 -0
  258. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  259. package/out/concepts/QueryOrderByExpression__.d.ts +1 -0
  260. package/out/concepts/QueryOrderByExpression__.js +3 -0
  261. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  262. package/out/concepts/QuerySelectExpression__.d.ts +105 -16
  263. package/out/concepts/QuerySelectExpression__.js +102 -9
  264. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  265. package/out/concepts/Rect__.d.ts +1 -0
  266. package/out/concepts/Rect__.js +3 -0
  267. package/out/concepts/Rect__.js.map +1 -1
  268. package/out/concepts/Return__.d.ts +6 -3
  269. package/out/concepts/Return__.js +13 -59
  270. package/out/concepts/Return__.js.map +1 -1
  271. package/out/concepts/Role__.d.ts +1 -0
  272. package/out/concepts/Role__.js +3 -0
  273. package/out/concepts/Role__.js.map +1 -1
  274. package/out/concepts/SelectMembers__.d.ts +1 -0
  275. package/out/concepts/SelectMembers__.js +3 -0
  276. package/out/concepts/SelectMembers__.js.map +1 -1
  277. package/out/concepts/Slot__.d.ts +17 -0
  278. package/out/concepts/Slot__.js +46 -0
  279. package/out/concepts/Slot__.js.map +1 -1
  280. package/out/concepts/SqlQueryComponent__.d.ts +1 -1
  281. package/out/concepts/SqlQueryComponent__.js +3 -46
  282. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  283. package/out/concepts/Start__.d.ts +1 -0
  284. package/out/concepts/Start__.js +3 -0
  285. package/out/concepts/Start__.js.map +1 -1
  286. package/out/concepts/StringInterpolation__.d.ts +1 -0
  287. package/out/concepts/StringInterpolation__.js +6 -1
  288. package/out/concepts/StringInterpolation__.js.map +1 -1
  289. package/out/concepts/StringLiteral__.d.ts +1 -0
  290. package/out/concepts/StringLiteral__.js +9 -6
  291. package/out/concepts/StringLiteral__.js.map +1 -1
  292. package/out/concepts/StructureProperty__.d.ts +9 -3
  293. package/out/concepts/StructureProperty__.js +21 -57
  294. package/out/concepts/StructureProperty__.js.map +1 -1
  295. package/out/concepts/Structure__.d.ts +1 -0
  296. package/out/concepts/Structure__.js +3 -0
  297. package/out/concepts/Structure__.js.map +1 -1
  298. package/out/concepts/SwitchCase__.d.ts +1 -0
  299. package/out/concepts/SwitchCase__.js +5 -2
  300. package/out/concepts/SwitchCase__.js.map +1 -1
  301. package/out/concepts/SwitchStatement__.d.ts +1 -0
  302. package/out/concepts/SwitchStatement__.js +3 -0
  303. package/out/concepts/SwitchStatement__.js.map +1 -1
  304. package/out/concepts/Theme__.d.ts +1 -0
  305. package/out/concepts/Theme__.js +3 -0
  306. package/out/concepts/Theme__.js.map +1 -1
  307. package/out/concepts/Transactional__.d.ts +6 -0
  308. package/out/concepts/Transactional__.js +9 -0
  309. package/out/concepts/Transactional__.js.map +1 -1
  310. package/out/concepts/TypeAnnotation__.d.ts +9 -3
  311. package/out/concepts/TypeAnnotation__.js +96 -10
  312. package/out/concepts/TypeAnnotation__.js.map +1 -1
  313. package/out/concepts/TypeParam__.d.ts +1 -0
  314. package/out/concepts/TypeParam__.js +3 -0
  315. package/out/concepts/TypeParam__.js.map +1 -1
  316. package/out/concepts/UnaryExpression__.d.ts +1 -0
  317. package/out/concepts/UnaryExpression__.js +3 -0
  318. package/out/concepts/UnaryExpression__.js.map +1 -1
  319. package/out/concepts/Unparsed__.d.ts +1 -0
  320. package/out/concepts/Unparsed__.js +3 -0
  321. package/out/concepts/Unparsed__.js.map +1 -1
  322. package/out/concepts/UseComponent__.d.ts +1 -0
  323. package/out/concepts/UseComponent__.js +3 -0
  324. package/out/concepts/UseComponent__.js.map +1 -1
  325. package/out/concepts/ValidationRule__.d.ts +2 -0
  326. package/out/concepts/ValidationRule__.js +56 -0
  327. package/out/concepts/ValidationRule__.js.map +1 -1
  328. package/out/concepts/Variable__.d.ts +6 -3
  329. package/out/concepts/Variable__.js +14 -60
  330. package/out/concepts/Variable__.js.map +1 -1
  331. package/out/concepts/ViewBlock__.d.ts +35 -0
  332. package/out/concepts/ViewBlock__.js +85 -0
  333. package/out/concepts/ViewBlock__.js.map +1 -0
  334. package/out/concepts/ViewComponent__.d.ts +93 -0
  335. package/out/concepts/ViewComponent__.js +114 -0
  336. package/out/concepts/ViewComponent__.js.map +1 -1
  337. package/out/concepts/ViewElement__.d.ts +8 -0
  338. package/out/concepts/ViewElement__.js +66 -10
  339. package/out/concepts/ViewElement__.js.map +1 -1
  340. package/out/concepts/View__.d.ts +9 -3
  341. package/out/concepts/View__.js +64 -16
  342. package/out/concepts/View__.js.map +1 -1
  343. package/out/concepts/WhileStatement__.d.ts +1 -0
  344. package/out/concepts/WhileStatement__.js +3 -0
  345. package/out/concepts/WhileStatement__.js.map +1 -1
  346. package/out/concepts/basics/stdlib/nasl.collection.js +7 -2
  347. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
  348. package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
  349. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  350. package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
  351. package/out/concepts/basics/stdlib/nasl.core.js +34 -0
  352. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
  353. package/out/concepts/basics/stdlib/nasl.interface.js +1 -1
  354. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  355. package/out/concepts/basics/stdlib/nasl.process.js +6 -6
  356. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  357. package/out/concepts/basics/stdlib/nasl.ui.js +71 -43
  358. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  359. package/out/concepts/basics/stdlib/nasl.util.js +146 -21
  360. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  361. package/out/concepts/basics/stdlib/nasl.validation.js +13 -13
  362. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  363. package/out/concepts/basics/types/coreTypeList.js +1 -5
  364. package/out/concepts/basics/types/coreTypeList.js.map +1 -1
  365. package/out/concepts/basics/types/index.d.ts +1 -0
  366. package/out/concepts/basics/types/index.js +3 -1
  367. package/out/concepts/basics/types/index.js.map +1 -1
  368. package/out/concepts/index__.d.ts +8 -0
  369. package/out/concepts/index__.js +8 -0
  370. package/out/concepts/index__.js.map +1 -1
  371. package/out/decorators/index.js +3 -3
  372. package/out/decorators/index.js.map +1 -1
  373. package/out/enums/KEYWORDS.d.ts +1 -0
  374. package/out/enums/KEYWORDS.js +16 -1
  375. package/out/enums/KEYWORDS.js.map +1 -1
  376. package/out/generator/genBundleFiles.d.ts +6 -3
  377. package/out/generator/genBundleFiles.js +66 -48
  378. package/out/generator/genBundleFiles.js.map +1 -1
  379. package/out/generator/genMetaData.d.ts +2 -2
  380. package/out/generator/genMetaData.js +3 -3
  381. package/out/generator/genMetaData.js.map +1 -1
  382. package/out/generator/genReleaseBody.d.ts +19 -4
  383. package/out/generator/genReleaseBody.js +147 -54
  384. package/out/generator/genReleaseBody.js.map +1 -1
  385. package/out/generator/icestark.d.ts +2 -0
  386. package/out/generator/icestark.js +48 -0
  387. package/out/generator/icestark.js.map +1 -0
  388. package/out/generator/microApp.d.ts +2 -0
  389. package/out/generator/microApp.js +35 -0
  390. package/out/generator/microApp.js.map +1 -0
  391. package/out/generator/permission.d.ts +1 -0
  392. package/out/generator/permission.js +24 -29
  393. package/out/generator/permission.js.map +1 -1
  394. package/out/generator/qiankun.d.ts +2 -0
  395. package/out/generator/qiankun.js +52 -0
  396. package/out/generator/qiankun.js.map +1 -0
  397. package/out/index.d.ts +2 -1
  398. package/out/index.js +4 -1
  399. package/out/index.js.map +1 -1
  400. package/out/manager/stepRecorder.d.ts +20 -0
  401. package/out/manager/stepRecorder.js +110 -0
  402. package/out/manager/stepRecorder.js.map +1 -0
  403. package/out/sentry/index.d.ts +29 -0
  404. package/out/sentry/index.js +111 -0
  405. package/out/sentry/index.js.map +1 -0
  406. package/out/server/entity2LogicNamespace.js +3 -1
  407. package/out/server/entity2LogicNamespace.js.map +1 -1
  408. package/out/server/extendBaseNode.js +113 -2
  409. package/out/server/extendBaseNode.js.map +1 -1
  410. package/out/server/formatTsUtils.d.ts +2 -1
  411. package/out/server/formatTsUtils.js +163 -17
  412. package/out/server/formatTsUtils.js.map +1 -1
  413. package/out/server/getLogics.d.ts +2 -2
  414. package/out/server/getLogics.js +63 -17
  415. package/out/server/getLogics.js.map +1 -1
  416. package/out/server/getMemberIdentifier.d.ts +1 -0
  417. package/out/server/getMemberIdentifier.js +34 -6
  418. package/out/server/getMemberIdentifier.js.map +1 -1
  419. package/out/server/index.js +1 -0
  420. package/out/server/index.js.map +1 -1
  421. package/out/server/naslServer.d.ts +16 -4
  422. package/out/server/naslServer.js +1170 -181
  423. package/out/server/naslServer.js.map +1 -1
  424. package/out/server/translator.js +114 -38
  425. package/out/server/translator.js.map +1 -1
  426. package/out/service/creator/add.configs.js +2 -0
  427. package/out/service/creator/add.configs.js.map +1 -1
  428. package/out/service/creator/errHandles.js +5 -0
  429. package/out/service/creator/errHandles.js.map +1 -1
  430. package/out/service/creator/index.js +2 -0
  431. package/out/service/creator/index.js.map +1 -1
  432. package/out/service/storage/api.d.ts +27 -0
  433. package/out/service/storage/api.js +19 -0
  434. package/out/service/storage/api.js.map +1 -1
  435. package/out/service/storage/init.d.ts +44 -1
  436. package/out/service/storage/init.js +262 -37
  437. package/out/service/storage/init.js.map +1 -1
  438. package/out/service/storage/service.d.ts +12 -1
  439. package/out/service/storage/service.js +32 -1
  440. package/out/service/storage/service.js.map +1 -1
  441. package/out/templator/genCallComponentLogic.d.ts +1 -1
  442. package/out/templator/genCallComponentLogic.js.map +1 -1
  443. package/out/templator/genCreateBlock.js +7 -4
  444. package/out/templator/genCreateBlock.js.map +1 -1
  445. package/out/templator/genCurdEditMultipleKeyBlock.d.ts +7 -1
  446. package/out/templator/genCurdEditMultipleKeyBlock.js +122 -8
  447. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  448. package/out/templator/genCurdMultipleKeyBlock.js +6 -8
  449. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  450. package/out/templator/genEditTableBlock.js +48 -20
  451. package/out/templator/genEditTableBlock.js.map +1 -1
  452. package/out/templator/genGetBlock.js +1 -1
  453. package/out/templator/genGetBlock.js.map +1 -1
  454. package/out/templator/genGridViewBlock.js +2 -2
  455. package/out/templator/genGridViewBlock.js.map +1 -1
  456. package/out/templator/genListViewBlock.js +7 -1
  457. package/out/templator/genListViewBlock.js.map +1 -1
  458. package/out/templator/genQueryComponent.js +23 -9
  459. package/out/templator/genQueryComponent.js.map +1 -1
  460. package/out/templator/genSelectBlock.d.ts +12 -1
  461. package/out/templator/genSelectBlock.js +273 -2
  462. package/out/templator/genSelectBlock.js.map +1 -1
  463. package/out/templator/genTableBlock.js +4 -4
  464. package/out/templator/genTableBlock.js.map +1 -1
  465. package/out/templator/genUpdateBlock.js +9 -4
  466. package/out/templator/genUpdateBlock.js.map +1 -1
  467. package/out/templator/utils.d.ts +19 -33
  468. package/out/templator/utils.js +11 -8
  469. package/out/templator/utils.js.map +1 -1
  470. package/out/translator/index.js +4 -1
  471. package/out/translator/index.js.map +1 -1
  472. package/out/utils/traverse.js +8 -2
  473. package/out/utils/traverse.js.map +1 -1
  474. package/package.json +2 -2
  475. package/sandbox/stdlib/nasl.core.ts +2 -0
  476. package/sandbox/stdlib/nasl.util.ts +2 -1
  477. package/src/concepts/BatchAssignment__.ts +1 -1
  478. package/src/concepts/CallLogic__.ts +2 -64
  479. package/src/concepts/NewComposite__.ts +5 -7
  480. package/src/concepts/NewList__.ts +2 -1
  481. package/src/concepts/NewMap__.ts +2 -1
  482. package/src/concepts/OqlQueryComponent__.ts +2 -0
  483. package/src/concepts/ViewElement__.ts +1 -1
  484. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  485. package/src/generator/genBundleFiles.ts +10 -1
  486. package/src/server/naslServer.ts +12 -9
  487. package/src/server/translator.ts +33 -6
  488. package/ts-worker/lib/tsserver.js +4 -1
  489. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  490. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  491. package/src/automate/engine/dist/index.dev.js +0 -517
  492. package/src/common/dist/BaseNode.js +0 -1101
  493. package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
  494. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  495. package/src/concepts/dist/BindAttribute__.js +0 -760
  496. package/src/concepts/dist/BindEvent__.js +0 -732
  497. package/src/concepts/dist/CallFunction__.js +0 -527
  498. package/src/concepts/dist/CallLogic__.js +0 -932
  499. package/src/concepts/dist/Identifier__.js +0 -311
  500. package/src/concepts/dist/StringInterpolation__.js +0 -231
  501. package/src/concepts/dist/TypeAnnotation__.js +0 -834
  502. package/src/concepts/dist/ViewElement__.js +0 -1692
  503. package/src/concepts/dist/View__.js +0 -1601
  504. package/src/generator/dist/genBundleFiles.js +0 -261
  505. package/src/generator/dist/genMetaData.js +0 -245
  506. package/src/generator/dist/permission.js +0 -392
  507. package/src/server/dist/naslServer.js +0 -3590
  508. package/src/service/storage/dist/init.js +0 -579
  509. package/src/templator/dist/genEditTableBlock.js +0 -204
  510. package/src/templator/dist/genGridViewBlock.js +0 -265
  511. package/src/templator/dist/genListViewBlock.js +0 -84
  512. package/src/templator/dist/genTableBlock.js +0 -209
  513. package/src/templator/dist/utils.js +0 -527
  514. package/ts-worker/dist/webpack.config.dev.js +0 -106
  515. /package/src/service/{dataSource → datasource}/api.js +0 -0
  516. /package/src/service/{dataSource → datasource}/index.js +0 -0
@@ -1,3590 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArrays = (this && this.__spreadArrays) || function () {
50
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
51
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
52
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
53
- r[k] = a[j];
54
- return r;
55
- };
56
- exports.__esModule = true;
57
- exports.NaslServer = exports.getDisplayString2Type = void 0;
58
- /// #if process.env.BUILD_TARGET === 'node'
59
- var fs = require("fs-extra");
60
- var path = require("path");
61
- var worker_threads_1 = require("worker_threads");
62
- /// #endif
63
- var config_1 = require("../config");
64
- var Messager_1 = require("../common/Messager");
65
- var getMemberIdentifier_1 = require("../server/getMemberIdentifier");
66
- var concepts_1 = require("../concepts");
67
- var translator_1 = require("../translator");
68
- var storage_1 = require("../service/storage");
69
- var translator_2 = require("./translator");
70
- var common_1 = require("../common");
71
- var diagnostic_1 = require("../manager/diagnostic");
72
- var createUiTs_1 = require("./createUiTs");
73
- var coreTypeList_1 = require("../concepts/basics/types/coreTypeList");
74
- var formatTsUtils_1 = require("./formatTsUtils");
75
- var naslStdlibMap_1 = require("./naslStdlibMap");
76
- var jsoner = require("../service/storage/jsoner");
77
- var EventEmitter_1 = require("../common/EventEmitter");
78
- var EmbeddedTSFileLineMap = {
79
- Entity: 3
80
- };
81
- var EmbeddedTSFileOffsetMap = {
82
- Variable: 12
83
- };
84
- // 要Check的文件
85
- var filesToCheck = new Set();
86
- // 单个文件正在change,不允许同时两个文件一起change
87
- var singleFileChangeIng = false;
88
- var isChangeInterface = false; //判断是否导入接口
89
- var actionArr = []; //用于导入接口收集更改的节点
90
- var timer = null; //超时器用于收集导入接口相关
91
- // 联合类型切割取出类型
92
- function getDisplayString2Type(displayString) {
93
- // 取出匹配的内容
94
- var reg = /<([^()]+)>/g;
95
- // 解决extends 导致类型缺失的问题
96
- displayString = (displayString === null || displayString === void 0 ? void 0 : displayString.replace('T extends ', '')) || '';
97
- var types = reg.exec(displayString);
98
- // 取出提示的类型,组成是数组
99
- var typeList = types[1].split(' | ').map(function (item) {
100
- if (/<([^()]+)>/g.exec(item)) {
101
- return item;
102
- }
103
- else if (item.includes(' ')) {
104
- var strs = item.split(' ');
105
- var type = strs[strs.length - 1];
106
- return type;
107
- }
108
- else if (item.includes('.')) {
109
- var strs = item.split('.');
110
- var type = strs[strs.length - 1];
111
- return type;
112
- }
113
- else {
114
- return item;
115
- }
116
- });
117
- return typeList;
118
- }
119
- exports.getDisplayString2Type = getDisplayString2Type;
120
- var NaslServer = /** @class */ (function () {
121
- function NaslServer() {
122
- var _this = this;
123
- this.messager = undefined;
124
- this.worker = undefined;
125
- /**
126
- * 按道理 fileSourceMap: new Map<string, SourceMap>() 比较合理,
127
- * 但是要多维护一层 vertex 增删 -> file 增删的关系问题,
128
- * 先用挂在点上面,简单的方法实现,后期再考虑解耦
129
- */
130
- this.file2NodeMap = new Map();
131
- this.elementsLogic = {};
132
- // 错误日志收集
133
- this.diagnosticManager = undefined;
134
- this.embeddedTSEmitter = undefined;
135
- // 需要执行修改的文件
136
- this.changeStackList = [];
137
- /// #if process.env.BUILD_TARGET === 'node'
138
- if (globalThis.process) // For TS build
139
- this.worker = new worker_threads_1.Worker(path.join(__dirname, '../../ts-worker/src/index.js'));
140
- // worker = new Worker(path.join(__dirname, '../../../src/static/ts-worker.js'));
141
- /// #endif
142
- /// #if process.env.BUILD_TARGET !== 'node'
143
- if (globalThis.window) // For TS build
144
- this.worker = new worker_threads_1.Worker('/ts-worker.js');
145
- /// #endif
146
- this.diagnosticManager = new diagnostic_1.DiagnosticManager();
147
- this.messager = new Messager_1["default"]({
148
- protocol: 'ts-worker',
149
- sender: 'ide',
150
- context: this,
151
- getReceiver: function () { return _this.worker; },
152
- getSender: function () { return _this.worker; },
153
- handleMessage: function (_a) {
154
- var data = _a.data;
155
- return __awaiter(_this, void 0, void 0, function () {
156
- var records;
157
- return __generator(this, function (_b) {
158
- switch (_b.label) {
159
- case 0:
160
- if (!(data && data.event === 'publishDiagnostics')) return [3 /*break*/, 2];
161
- return [4 /*yield*/, this._resolveDiagnosticRecords(data.records)];
162
- case 1:
163
- records = _b.sent();
164
- this.diagnosticManager.pushAll(records);
165
- _b.label = 2;
166
- case 2: return [2 /*return*/];
167
- }
168
- });
169
- });
170
- }
171
- });
172
- // 监听所有改变操作
173
- this.embeddedTSEmitter = new EventEmitter_1.EventEmitter();
174
- this.embeddedTSEmitter.on('change', function ($event) {
175
- // 收集到一个行为集合
176
- var eventValue = $event.value;
177
- eventValue.forEach(function (item) { return __awaiter(_this, void 0, void 0, function () {
178
- var changeEvent, changeNode, fileNode_1, findIndex;
179
- var _this = this;
180
- return __generator(this, function (_a) {
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
- }
210
- return [2 /*return*/];
211
- });
212
- }); });
213
- // 如果有长度开始执行状态机
214
- if (_this.changeStackList.length) {
215
- _this.changeFileNext();
216
- }
217
- });
218
- }
219
- NaslServer.prototype.start = function () {
220
- return this.messager.requestCommand('start');
221
- };
222
- NaslServer.prototype.terminate = function () {
223
- this.worker.terminate();
224
- };
225
- NaslServer.prototype.createUiTs = function (allComponent) {
226
- return __awaiter(this, void 0, void 0, function () {
227
- var _a, code, elementsLogic;
228
- var _this = this;
229
- return __generator(this, function (_b) {
230
- switch (_b.label) {
231
- case 0: return [4 /*yield*/, createUiTs_1["default"](allComponent)];
232
- case 1:
233
- _a = _b.sent(), code = _a.code, elementsLogic = _a.elementsLogic;
234
- // 放入生產的uits文件
235
- return [4 /*yield*/, this.addFile({
236
- file: 'nasl.ui.definition.ts',
237
- fileContent: code
238
- })];
239
- case 2:
240
- // 放入生產的uits文件
241
- _b.sent();
242
- Object.keys(naslStdlibMap_1["default"]).forEach(function (libFileName) { return __awaiter(_this, void 0, void 0, function () {
243
- return __generator(this, function (_a) {
244
- switch (_a.label) {
245
- case 0: return [4 /*yield*/, this.addFile({
246
- file: '/' + libFileName,
247
- fileContent: naslStdlibMap_1["default"][libFileName]
248
- })];
249
- case 1:
250
- _a.sent();
251
- return [2 /*return*/];
252
- }
253
- });
254
- }); });
255
- this.elementsLogic = elementsLogic;
256
- // 全部文件加载完毕开始初始化
257
- return [4 /*yield*/, this.getDiagnosticRecordsAndPushAll()];
258
- case 3:
259
- // 全部文件加载完毕开始初始化
260
- _b.sent();
261
- return [2 /*return*/];
262
- }
263
- });
264
- });
265
- };
266
- NaslServer.prototype.contentToFile = function (module, results) {
267
- var _this = this;
268
- var _a, _b;
269
- module.structures.forEach(function (structure) {
270
- try {
271
- var result = structure.toEmbeddedTSFile();
272
- results.push(result);
273
- // sourceMap都存在目录级别内容下,在页面层级下去找
274
- structure.sourceMap = result.sourceMap;
275
- _this.file2NodeMap.set(result.filePath, structure);
276
- }
277
- catch (err) {
278
- }
279
- });
280
- (_a = module.frontendVariables) === null || _a === void 0 ? void 0 : _a.forEach(function (frontendVariable) {
281
- try {
282
- var result = frontendVariable.toEmbeddedTSFile();
283
- results.push(result);
284
- // sourceMap都存在目录级别内容下,在页面层级下去找
285
- frontendVariable.sourceMap = result.sourceMap;
286
- _this.file2NodeMap.set(result.filePath, frontendVariable);
287
- }
288
- catch (err) {
289
- console.log(err);
290
- }
291
- });
292
- (_b = module.dataSources) === null || _b === void 0 ? void 0 : _b.forEach(function (dataSource) {
293
- // 本身dataSource也要生成一个文件用于改名
294
- try {
295
- var result = dataSource.toEmbeddedTSFile();
296
- results.push(result);
297
- // sourceMap都存在目录级别内容下,在页面层级下去找
298
- dataSource.sourceMap = result.sourceMap;
299
- _this.file2NodeMap.set(result.filePath, dataSource);
300
- }
301
- catch (err) {
302
- }
303
- dataSource.entities.forEach(function (entity) {
304
- try {
305
- var result = entity.toEmbeddedTSFile();
306
- results.push(result);
307
- // sourceMap都存在目录级别内容下,在页面层级下去找
308
- entity.sourceMap = result.sourceMap;
309
- _this.file2NodeMap.set(result.filePath, entity);
310
- }
311
- catch (err) {
312
- }
313
- });
314
- });
315
- module.interfaces.forEach(function (_interface) {
316
- try {
317
- var result = _interface.toEmbeddedTSFile();
318
- results.push(result);
319
- // sourceMap都存在目录级别内容下,在页面层级下去找
320
- _interface.sourceMap = result.sourceMap;
321
- _this.file2NodeMap.set(result.filePath, _interface);
322
- }
323
- catch (err) {
324
- }
325
- });
326
- module.enums.forEach(function (_enum) {
327
- try {
328
- var result = _enum.toEmbeddedTSFile();
329
- results.push(result);
330
- // sourceMap都存在目录级别内容下,在页面层级下去找
331
- _enum.sourceMap = result.sourceMap;
332
- _this.file2NodeMap.set(result.filePath, _enum);
333
- }
334
- catch (err) {
335
- }
336
- });
337
- module.logics.forEach(function (logic) {
338
- try {
339
- if (!(logic instanceof concepts_1.Logic))
340
- return;
341
- var result = logic.toEmbeddedTSFile();
342
- results.push(result);
343
- logic.sourceMap = result.sourceMap;
344
- _this.file2NodeMap.set(result.filePath, logic);
345
- }
346
- catch (err) {
347
- }
348
- });
349
- // view的生成
350
- if (!config_1.config.closeViews) {
351
- this.view2TSFile(module.views, results);
352
- }
353
- module.processes.forEach(function (process) {
354
- try {
355
- var result = process.toEmbeddedTSFile();
356
- results.push(result);
357
- process.sourceMap = result.sourceMap;
358
- _this.file2NodeMap.set(result.filePath, process);
359
- }
360
- catch (err) {
361
- }
362
- });
363
- if (module instanceof concepts_1.App) {
364
- module.roles.forEach(function (role) {
365
- try {
366
- var result = role.toEmbeddedTSFile();
367
- results.push(result);
368
- // sourceMap都存在目录级别内容下,在页面层级下去找
369
- role.sourceMap = result.sourceMap;
370
- _this.file2NodeMap.set(result.filePath, role);
371
- }
372
- catch (err) {
373
- }
374
- });
375
- }
376
- };
377
- NaslServer.prototype.view2TSFile = function (viewsChildren, results) {
378
- var _this = this;
379
- // 如果有子页面
380
- if (viewsChildren && viewsChildren.length) {
381
- viewsChildren.forEach(function (view) {
382
- try {
383
- var result = view.toEmbeddedTSFile();
384
- results.push(result);
385
- view.sourceMap = result.sourceMap;
386
- _this.file2NodeMap.set(result.filePath, view);
387
- if (view.children.length) {
388
- _this.view2TSFile(view.children, results);
389
- }
390
- }
391
- catch (err) {
392
- }
393
- });
394
- }
395
- };
396
- NaslServer.prototype.openApp = function (app) {
397
- return __awaiter(this, void 0, void 0, function () {
398
- var results, files;
399
- var _this = this;
400
- return __generator(this, function (_a) {
401
- switch (_a.label) {
402
- case 0:
403
- results = [];
404
- try {
405
- // app的创建内容
406
- this.contentToFile(app, results);
407
- // 其他模块的创建内容
408
- app.dependencies.forEach(function (item) { return _this.contentToFile(item, results); });
409
- app.interfaceDependencies.forEach(function (item) { return _this.contentToFile(item, results); });
410
- app.componentDependencies.forEach(function (item) { return _this.contentToFile(item, results); });
411
- }
412
- catch (err) {
413
- console.log(err);
414
- }
415
- files = results.map(function (result) { return ({
416
- file: result.filePath,
417
- fileContent: result.code
418
- }); });
419
- return [4 /*yield*/, this.writeFiles(files)];
420
- case 1:
421
- _a.sent();
422
- this._debugInFileStorage(app, files);
423
- // 修改名称回调
424
- common_1.registerCommand('tsRename.change', function (value, callback) {
425
- callback(value);
426
- });
427
- // 删除回调
428
- common_1.registerCommand('tsDelete.change', function (callback) {
429
- callback();
430
- });
431
- return [2 /*return*/];
432
- }
433
- });
434
- });
435
- };
436
- NaslServer.prototype.refreshApp = function (app) {
437
- return __awaiter(this, void 0, void 0, function () {
438
- return __generator(this, function (_a) {
439
- switch (_a.label) {
440
- case 0:
441
- // 清除所有问题
442
- this.diagnosticManager.clear();
443
- return [4 /*yield*/, this.deleteDirectoryFiles({ directoryName: '/embedded' })];
444
- case 1:
445
- _a.sent();
446
- // 清楚check count的数量
447
- return [4 /*yield*/, this.messager.requestCommand('_clearTimeout')];
448
- case 2:
449
- // 清楚check count的数量
450
- _a.sent();
451
- // 重新加载app下内容
452
- return [4 /*yield*/, this.openApp(app)];
453
- case 3:
454
- // 重新加载app下内容
455
- _a.sent();
456
- // 重新check一遍所有内容
457
- return [4 /*yield*/, this.getDiagnosticRecordsAndPushAll()];
458
- case 4:
459
- // 重新check一遍所有内容
460
- _a.sent();
461
- // 重新补一遍标注
462
- return [4 /*yield*/, this.createdNaslAnnotatedJSON(app)];
463
- case 5:
464
- // 重新补一遍标注
465
- _a.sent();
466
- return [2 /*return*/];
467
- }
468
- });
469
- });
470
- };
471
- /**
472
- * 初始化之前添加文件
473
- */
474
- NaslServer.prototype.addFile = function (file) {
475
- return this.messager.requestCommand('addFile', file);
476
- };
477
- /**
478
- * 只新增文件
479
- * @param {*} files
480
- */
481
- NaslServer.prototype.writeFiles = function (files) {
482
- return this.messager.requestCommand('writeFiles', files);
483
- };
484
- /**
485
- * 新增、修改
486
- * 删除文件 文件用修改内容为空模拟,防止报错
487
- * @param {*} args
488
- */
489
- NaslServer.prototype.updateFiles = function (args) {
490
- return this.messager.requestCommand('updateFiles', args);
491
- };
492
- /**
493
- * 清除一个目录下的所有文件
494
- */
495
- NaslServer.prototype.deleteDirectoryFiles = function (args) {
496
- return this.messager.requestCommand('deleteDirectoryFiles', args);
497
- };
498
- NaslServer.prototype._debugInFileStorage = function (node, openFiles) {
499
- return __awaiter(this, void 0, void 0, function () {
500
- var app, e_1, e_2;
501
- var _this = this;
502
- return __generator(this, function (_a) {
503
- switch (_a.label) {
504
- case 0:
505
- app = node;
506
- if (node.concept !== 'App') {
507
- app = node.rootNode || node.app;
508
- }
509
- if (!globalThis.window) return [3 /*break*/, 4];
510
- _a.label = 1;
511
- case 1:
512
- _a.trys.push([1, 3, , 4]);
513
- return [4 /*yield*/, Promise.all(openFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
514
- var res;
515
- return __generator(this, function (_a) {
516
- switch (_a.label) {
517
- case 0: return [4 /*yield*/, storage_1["default"].post('/api/App/debugEmbedded?id=' + app.id, file)];
518
- case 1:
519
- res = _a.sent();
520
- return [2 /*return*/, res.data];
521
- }
522
- });
523
- }); }))];
524
- case 2:
525
- _a.sent();
526
- return [3 /*break*/, 4];
527
- case 3:
528
- e_1 = _a.sent();
529
- console.error(e_1);
530
- return [3 /*break*/, 4];
531
- case 4:
532
- if (!globalThis.process) return [3 /*break*/, 8];
533
- _a.label = 5;
534
- case 5:
535
- _a.trys.push([5, 7, , 8]);
536
- return [4 /*yield*/, Promise.all(openFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
537
- return [2 /*return*/, fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)];
538
- }); }); }))];
539
- case 6:
540
- _a.sent();
541
- return [3 /*break*/, 8];
542
- case 7:
543
- e_2 = _a.sent();
544
- console.error(e_2);
545
- return [3 /*break*/, 8];
546
- case 8: return [2 /*return*/];
547
- }
548
- });
549
- });
550
- };
551
- NaslServer.prototype.open = function () {
552
- return this.messager.requestCommand('open');
553
- };
554
- NaslServer.prototype.updateOpen = function (args) {
555
- return this.messager.requestCommand('updateOpen', args);
556
- };
557
- NaslServer.prototype.fileReferences = function (filePath) {
558
- return this.messager.requestCommand('fileReferences', filePath);
559
- };
560
- NaslServer.prototype.references = function (args) {
561
- var _a;
562
- return __awaiter(this, void 0, void 0, function () {
563
- return __generator(this, function (_b) {
564
- switch (_b.label) {
565
- case 0: return [4 /*yield*/, this.messager.requestCommand('references', args)];
566
- case 1: return [2 /*return*/, (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.response];
567
- }
568
- });
569
- });
570
- };
571
- NaslServer.prototype.getValueSelectCompletion = function (node, value, noFilterList) {
572
- var _a = this.getCurrentSource(node), currentSource = _a.currentSource, fileNode = _a.fileNode;
573
- // console.log(currentSource, fileNode);
574
- if (currentSource && fileNode) {
575
- return this._getValueSelectCompletion({
576
- file: fileNode.getEmbeddedFilePath(),
577
- range: {
578
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
579
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
580
- },
581
- value: value,
582
- noFilterList: noFilterList
583
- });
584
- }
585
- else {
586
- console.log('没找到节点', node, currentSource, fileNode);
587
- }
588
- };
589
- NaslServer.prototype._getValueSelectCompletion = function (args) {
590
- return this.messager.requestCommand('getValueSelectCompletion', args);
591
- };
592
- /**
593
- * 获取 Convert 的可选类型
594
- * @param node 传入当前已经选择的变量
595
- * @returns 可以选择的类型数组
596
- */
597
- NaslServer.prototype.getConvertTypeInfo = function (node) {
598
- var _a;
599
- return __awaiter(this, void 0, void 0, function () {
600
- var callFunction, _b, currentSource, fileNode, quickInfo, displayString, typeList, res_1, err_1;
601
- return __generator(this, function (_c) {
602
- switch (_c.label) {
603
- case 0:
604
- if (!(node && node instanceof concepts_1.BaseNode)) return [3 /*break*/, 5];
605
- callFunction = node.parentNode.parentNode;
606
- _b = this.getCurrentSource(callFunction), currentSource = _b.currentSource, fileNode = _b.fileNode;
607
- _c.label = 1;
608
- case 1:
609
- _c.trys.push([1, 3, , 4]);
610
- return [4 /*yield*/, this._getTypeQuickinfo({
611
- file: fileNode.getEmbeddedFilePath(),
612
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
613
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character) + "nasl.util.C".length
614
- })];
615
- case 2:
616
- quickInfo = _c.sent();
617
- if (quickInfo.responseRequired) {
618
- displayString = ((_a = quickInfo === null || quickInfo === void 0 ? void 0 : quickInfo.response) === null || _a === void 0 ? void 0 : _a.displayString) || '';
619
- typeList = getDisplayString2Type(displayString);
620
- res_1 = [];
621
- typeList.forEach(function (type) {
622
- var typeAnnotation = coreTypeList_1.primitiveTypeList.find(function (typeAnnotation) { return typeAnnotation.typeName === type; });
623
- if (typeAnnotation) {
624
- res_1.push(typeAnnotation);
625
- }
626
- else if (type === 'unknown' || type === 'never') {
627
- return null;
628
- }
629
- });
630
- if (!res_1.length) {
631
- return [2 /*return*/, []];
632
- }
633
- else {
634
- return [2 /*return*/, [{ title: '基础类型', children: res_1 }]];
635
- }
636
- }
637
- return [3 /*break*/, 4];
638
- case 3:
639
- err_1 = _c.sent();
640
- console.log(err_1);
641
- // 如果有异常就先放开全部可选,兜底逻辑
642
- return [2 /*return*/, []];
643
- case 4: return [3 /*break*/, 6];
644
- case 5:
645
- // 字符串 和 inter
646
- return [2 /*return*/, [{ title: '基础类型', children: [coreTypeList_1.primitiveTypeList[4]] }]];
647
- case 6: return [2 /*return*/];
648
- }
649
- });
650
- });
651
- };
652
- /**
653
- * 获取表单的dataschema类型
654
- * @param node 当前表单节点
655
- * @param allType 是不是需要全部类型 默认不要
656
- * @returns 全部类型的str 或者 最后一个.后的内容
657
- */
658
- NaslServer.prototype.getDataSchemaType = function (node, allType) {
659
- var _a;
660
- if (allType === void 0) { allType = false; }
661
- return __awaiter(this, void 0, void 0, function () {
662
- var _b, currentSource, fileNode, quickInfo, displayString, flag, types, typeStr, str, strs, type;
663
- return __generator(this, function (_c) {
664
- switch (_c.label) {
665
- case 0:
666
- if (!(node instanceof concepts_1.ViewElement))
667
- return [2 /*return*/];
668
- _b = this.getCurrentSource(node), currentSource = _b.currentSource, fileNode = _b.fileNode;
669
- return [4 /*yield*/, this._getTypeQuickinfo({
670
- file: fileNode.getEmbeddedFilePath(),
671
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
672
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character) + "new nasl.ui.".length
673
- })];
674
- case 1:
675
- quickInfo = _c.sent();
676
- if (quickInfo.responseRequired) {
677
- displayString = ((_a = quickInfo === null || quickInfo === void 0 ? void 0 : quickInfo.response) === null || _a === void 0 ? void 0 : _a.displayString) || '';
678
- flag = displayString.includes('<') && displayString.includes('>');
679
- types = /\<([^()]+)\>/g.exec(displayString);
680
- typeStr = types && types[1];
681
- if (flag) {
682
- // 自定义结构的展示
683
- if (typeStr.includes('__name: "AStructure_')) {
684
- return [2 /*return*/, typeStr.replaceAll(' ', '')
685
- .replaceAll('\n', '')
686
- .replace(/__name:"AStructure_\w{8}";/g, '')
687
- .replace(/dataSources.([^.]+).entities.([^;]+)/g, function ($1, $2, $3) { return ($3 + "(" + $2 + ")"); })];
688
- }
689
- else if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
690
- /**
691
- * {
692
- text: nasl.core.String;
693
- value: nasl.core.String;
694
- }
695
- */
696
- return [2 /*return*/, typeStr.replaceAll(' ', '')
697
- .replaceAll('\n', '')
698
- .replaceAll('nasl.core.', '')];
699
- }
700
- str = '';
701
- // 取出T的值
702
- typeStr = formatTsUtils_1.getPlatformType(typeStr);
703
- // 如果要全量的内容
704
- if (allType) {
705
- return [2 /*return*/, typeStr];
706
- }
707
- // 取出剩下的剩下的类型的最后一项
708
- if (/\<([^()]+)\>/g.exec(typeStr)) {
709
- str = typeStr;
710
- }
711
- else if (typeStr.includes('.')) {
712
- strs = typeStr.split('.');
713
- type = strs[strs.length - 1];
714
- str = type;
715
- }
716
- else {
717
- str = typeStr;
718
- }
719
- str = str === 'any' || str === 'unknown' || str === 'never' ? '' : str;
720
- return [2 /*return*/, str];
721
- }
722
- }
723
- return [2 /*return*/, ''];
724
- }
725
- });
726
- });
727
- };
728
- NaslServer.prototype.getDataSchemaStructureOrTypeAnnotation = function (node) {
729
- var _a;
730
- return __awaiter(this, void 0, void 0, function () {
731
- var _b, currentSource, fileNode, quickInfo, displayString, flag, types, typeStr, app, properties_1;
732
- return __generator(this, function (_c) {
733
- switch (_c.label) {
734
- case 0:
735
- if (!(node instanceof concepts_1.ViewElement))
736
- return [2 /*return*/];
737
- _b = this.getCurrentSource(node), currentSource = _b.currentSource, fileNode = _b.fileNode;
738
- return [4 /*yield*/, this._getTypeQuickinfo({
739
- file: fileNode.getEmbeddedFilePath(),
740
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
741
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character) + "new nasl.ui.".length
742
- })];
743
- case 1:
744
- quickInfo = _c.sent();
745
- if (quickInfo.responseRequired) {
746
- displayString = ((_a = quickInfo === null || quickInfo === void 0 ? void 0 : quickInfo.response) === null || _a === void 0 ? void 0 : _a.displayString) || '';
747
- flag = displayString.includes('<') && displayString.includes('>');
748
- if (!flag)
749
- return [2 /*return*/];
750
- types = /\<([^()]+)\>/g.exec(displayString);
751
- typeStr = types && types[1];
752
- app = node.app;
753
- if (typeStr.includes('__name: "AStructure_')) {
754
- properties_1 = [];
755
- typeStr
756
- .replace(/([^:\s]+):\s+([^;]+);/g, function ($1, name, typeKey) {
757
- if (name === '__name')
758
- return;
759
- typeKey = "app." + typeKey;
760
- var keys = typeKey.split('.');
761
- var typeName = keys.pop();
762
- var typeNamespace = keys.join('.');
763
- properties_1.push(concepts_1.StructureProperty.from({
764
- name: name,
765
- typeAnnotation: concepts_1.TypeAnnotation.from({
766
- typeKind: 'reference',
767
- typeName: typeName,
768
- typeNamespace: typeNamespace
769
- })
770
- }));
771
- return '';
772
- });
773
- return [2 /*return*/, concepts_1.TypeAnnotation.createTypeAnonymousStructure(properties_1)];
774
- }
775
- else if (typeStr.startsWith('structures'))
776
- return [2 /*return*/, app.findNodeByCompleteName("app." + typeStr)];
777
- }
778
- return [2 /*return*/];
779
- }
780
- });
781
- });
782
- };
783
- /**
784
- * ts的 quickInfo方法,查询指定位置的详情
785
- * @param args 文件信息数组
786
- * @returns 查询到的
787
- */
788
- NaslServer.prototype._getTypeQuickinfo = function (args) {
789
- return this.messager.requestCommand('quickInfo', args);
790
- };
791
- NaslServer.prototype._getQuickInfoFull = function (args) {
792
- return this.messager.requestCommand('quickInfoFull', args);
793
- };
794
- /**
795
- * 获取nasl节点的 指定位置的详情
796
- * 而且可以返回正确类型
797
- * @param args 文件信息数组
798
- * @returns 查询到的
799
- */
800
- NaslServer.prototype.getNaslNodeQuickInfoFull = function (args) {
801
- return __awaiter(this, void 0, void 0, function () {
802
- var result;
803
- return __generator(this, function (_a) {
804
- switch (_a.label) {
805
- case 0: return [4 /*yield*/, this._getQuickInfoFull(args)];
806
- case 1:
807
- result = _a.sent();
808
- return [2 /*return*/, result];
809
- }
810
- });
811
- });
812
- };
813
- NaslServer.prototype._getTypeFull = function (args) {
814
- return this.messager.requestCommand('typeFull', args);
815
- };
816
- NaslServer.prototype._getTypeBatch = function (args) {
817
- return this.messager.requestCommand('typeBatch', args);
818
- };
819
- NaslServer.prototype.getNaslNodeTypeFull = function (args) {
820
- return __awaiter(this, void 0, void 0, function () {
821
- var result;
822
- return __generator(this, function (_a) {
823
- switch (_a.label) {
824
- case 0: return [4 /*yield*/, this._getTypeFull(args)];
825
- case 1:
826
- result = _a.sent();
827
- return [2 /*return*/, result];
828
- }
829
- });
830
- });
831
- };
832
- NaslServer.prototype.getNaslNodeTypeBatch = function (args) {
833
- return __awaiter(this, void 0, void 0, function () {
834
- var result;
835
- return __generator(this, function (_a) {
836
- switch (_a.label) {
837
- case 0: return [4 /*yield*/, this._getTypeBatch(args)];
838
- case 1:
839
- result = _a.sent();
840
- return [2 /*return*/, result];
841
- }
842
- });
843
- });
844
- };
845
- /**
846
- * 获取已经选中的内容的 下一级的内容
847
- * @param node 已经选中的内容
848
- * @param noFilterList 不过滤的key 的数据
849
- * @returns 可以选择的数据数组
850
- */
851
- NaslServer.prototype.getSelectNextCompletion = function (node, noFilterList) {
852
- var _a = this.getCurrentSource(node), currentSource = _a.currentSource, fileNode = _a.fileNode;
853
- // console.log(currentSource, fileNode);
854
- if (currentSource && fileNode) {
855
- return this._getSelectNextCompletion({
856
- file: fileNode.getEmbeddedFilePath(),
857
- range: {
858
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
859
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
860
- },
861
- noFilterList: noFilterList
862
- });
863
- }
864
- else {
865
- console.log('没找到节点', currentSource, fileNode);
866
- }
867
- };
868
- NaslServer.prototype._getSelectNextCompletion = function (args) {
869
- return this.messager.requestCommand('getSelectNextCompletion', args);
870
- };
871
- /**
872
- * 获取诊断信息
873
- * @param fileNames 多个文件名
874
- * @returns 诊断结果
875
- */
876
- NaslServer.prototype.getDiagnosticRecords = function (fileNames) {
877
- return __awaiter(this, void 0, Promise, function () {
878
- var records, diagnosticRecords;
879
- return __generator(this, function (_a) {
880
- switch (_a.label) {
881
- case 0: return [4 /*yield*/, this.messager.requestCommand('getDiagnosticRecords', fileNames)];
882
- case 1:
883
- records = (_a.sent());
884
- return [4 /*yield*/, this._resolveDiagnosticRecords(records)];
885
- case 2:
886
- diagnosticRecords = _a.sent();
887
- return [2 /*return*/, diagnosticRecords];
888
- }
889
- });
890
- });
891
- };
892
- NaslServer.prototype.getDiagnosticRecordsAndPushAll = function (fileNames) {
893
- return __awaiter(this, void 0, void 0, function () {
894
- var records;
895
- return __generator(this, function (_a) {
896
- switch (_a.label) {
897
- case 0: return [4 /*yield*/, this.getDiagnosticRecords(fileNames)];
898
- case 1:
899
- records = _a.sent();
900
- return [2 /*return*/];
901
- }
902
- });
903
- });
904
- };
905
- /**
906
- * 处理诊断结果
907
- * @param records 结果
908
- * @returns 过滤或者转换后的诊断结果
909
- */
910
- NaslServer.prototype._resolveDiagnosticRecords = function (records) {
911
- return __awaiter(this, void 0, void 0, function () {
912
- var _this = this;
913
- return __generator(this, function (_a) {
914
- switch (_a.label) {
915
- case 0:
916
- if (!records.length) return [3 /*break*/, 2];
917
- return [4 /*yield*/, this.IncrementalAnnotationJSON(records)];
918
- case 1:
919
- _a.sent();
920
- _a.label = 2;
921
- case 2:
922
- records.forEach(function (record) {
923
- var _a, _b;
924
- var node = record.node;
925
- if (!node)
926
- return;
927
- // 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
928
- var oldRecord = _this.diagnosticManager.getRecord(record.id);
929
- oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.semanticDiagnostics.forEach(function (item) {
930
- if (item.node) {
931
- item.node.tsErrorDetail = undefined;
932
- // 如果logic中有报错就把标识置为true
933
- if (item.node.logic) {
934
- item.node.logic.haveError = false;
935
- }
936
- }
937
- });
938
- // 清空一些状态
939
- oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.suggestionDiagnostics.forEach(function (item) {
940
- if (item.node) {
941
- item.node.tsErrorDetail = undefined;
942
- if (item.node && item.node instanceof concepts_1.Logic) {
943
- item.node.isSmpty = false;
944
- }
945
- }
946
- });
947
- // 语义诊断
948
- if (isChangeInterface) {
949
- _this.existStructureFix(record.semanticDiagnostics, node, _this);
950
- }
951
- // 单独处理 oql 语义错误提示
952
- if (record.node instanceof concepts_1.Logic) {
953
- record === null || record === void 0 ? void 0 : record.syntaxDiagnostics.forEach(function (item) {
954
- var minRange = _this._findMinRange(item, record.node);
955
- if (minRange.node instanceof concepts_1.OqlQueryComponent) {
956
- if (item.text === 'Invalid character.') {
957
- record.semanticDiagnostics.push(item);
958
- }
959
- }
960
- });
961
- }
962
- record.semanticDiagnostics = record.semanticDiagnostics
963
- .map(function (diag) { return _this._resolveDiagnostic(diag, node, record); })
964
- .filter(function (diag) { return !!diag; });
965
- (_a = record.semanticDiagnostics).push.apply(_a, _this._attachDiagnostics(node));
966
- // 建议诊断
967
- // 实体下的建议不用展示,因为都是平台自己写的逻辑
968
- // if (node instanceof Entity) {
969
- // record.suggestionDiagnostics = [];
970
- // }
971
- // if (node instanceof View) {
972
- // // event在view中不展示建议使用,提示关闭掉
973
- // record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`'event'`));
974
- // }
975
- // if (node instanceof Logic) {
976
- // // logic在for循环中,不展示any提示
977
- // record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
978
- // }
979
- record.suggestionDiagnostics = record.suggestionDiagnostics
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); })
982
- .map(function (diag) { return _this._resolveDiagnostic(diag, node, record); })
983
- .filter(function (diag) { return !!diag; });
984
- (_b = record.suggestionDiagnostics).push.apply(_b, _this._attachSuggestionDiagnostics(node));
985
- });
986
- return [2 /*return*/, records];
987
- }
988
- });
989
- });
990
- };
991
- /**
992
- * 额外的建议诊断
993
- * @param fileNode 文件级别的节点
994
- * @returns 诊断结果
995
- */
996
- NaslServer.prototype._attachSuggestionDiagnostics = function (fileNode) {
997
- var diagnostics = [];
998
- if (fileNode instanceof concepts_1.Logic || fileNode instanceof concepts_1.View) {
999
- // 判断逻辑是否已经删除
1000
- if (fileNode instanceof concepts_1.Logic && fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
1001
- return diagnostics;
1002
- // 判断页面是否已经删除
1003
- var removed = false;
1004
- var curNode = fileNode;
1005
- // 递归检查,防止从顶层页面开始删除影响子页面内容检查
1006
- while (curNode instanceof concepts_1.View && !removed) {
1007
- if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
1008
- || curNode.parentNode instanceof concepts_1.App && !curNode.parentNode.views.includes(curNode)) {
1009
- removed = true;
1010
- }
1011
- curNode = curNode.parentNode;
1012
- }
1013
- if (removed)
1014
- return diagnostics;
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();
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; });
1053
- }
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;
1079
- }
1080
- });
1081
- }
1082
- });
1083
- var enumerableKeys = Object.keys(map_1);
1084
- if (enumerableKeys.length === enumerableItems.length) {
1085
- isDisabled = true;
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
- };
1100
- }
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
1109
- };
1110
- }
1111
- return typeAnnotation;
1112
- }
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
- }
1137
- }
1138
- }
1139
- }
1140
- });
1141
- }
1142
- return diagnostics;
1143
- };
1144
- /**
1145
- * 额外的诊断
1146
- * @param fileNode 文件级别的节点
1147
- * @returns 诊断结果
1148
- */
1149
- NaslServer.prototype._attachDiagnostics = function (fileNode) {
1150
- var _this = this;
1151
- var _a;
1152
- var diagnostics = [];
1153
- if (fileNode instanceof concepts_1.View) {
1154
- // 判断页面是否已经删除
1155
- var removed = false;
1156
- var curNode = fileNode;
1157
- // 递归检查,防止从顶层页面开始删除影响子页面内容检查
1158
- while (curNode instanceof concepts_1.View && !removed) {
1159
- if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
1160
- || curNode.parentNode instanceof concepts_1.App && !curNode.parentNode.views.includes(curNode)) {
1161
- removed = true;
1162
- }
1163
- curNode = curNode.parentNode;
1164
- }
1165
- if (removed)
1166
- return diagnostics;
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()) {
1183
- diagnostic = {
1184
- node: bindAttr,
1185
- severity: 'error',
1186
- message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。'
1187
- };
1188
- }
1189
- }
1190
- if (diagnostic) {
1191
- bindAttr.tsErrorDetail = diagnostic;
1192
- diagnostics.push(diagnostic);
1193
- }
1194
- }
1195
- });
1196
- }
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 + " = "))
1219
- return;
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);
1231
- }
1232
- msg_1 = '系统无法推断类型。';
1233
- }
1234
- }
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);
1256
- }
1257
- }
1258
- else {
1259
- _this.checkNodeError(node, diagnostics);
1260
- }
1261
- });
1262
- }
1263
- if (fileNode instanceof concepts_1.DataSource) {
1264
- var dataSourceGroup = (_a = fileNode.rootNode.configuration) === null || _a === void 0 ? void 0 : _a.getGroup('dataSource');
1265
- if (dataSourceGroup) {
1266
- var property_1 = dataSourceGroup.getProperty(fileNode.name);
1267
- if (property_1 && property_1.values) {
1268
- property_1.values.forEach(function (propertyValue) {
1269
- if (!propertyValue.value && fileNode.name !== 'defaultDS') {
1270
- var diagnostic = {
1271
- node: fileNode,
1272
- severity: 'error',
1273
- message: "\u6570\u636E\u6E90\u914D\u7F6E\uFF1A\u6570\u636E\u6E90" + property_1.name + (propertyValue.env === 'dev' ? '开发环境' : '生产环境') + "\u672A\u914D\u7F6E\u6570\u636E\u4FE1\u606F",
1274
- // 保留原来的内容方便查询一些问题
1275
- originalDiagnostic: {
1276
- fileName: '',
1277
- start: null,
1278
- end: null,
1279
- category: 'error',
1280
- text: "Data Source is not config"
1281
- }
1282
- };
1283
- diagnostics.push(diagnostic);
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
- }
1323
- });
1324
- }
1325
- }
1326
- }
1327
- if (fileNode instanceof concepts_1.Logic) {
1328
- // 判断逻辑是否已经删除
1329
- if (fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
1330
- return diagnostics;
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 = {
1366
- node: node,
1367
- severity: 'error',
1368
- message: nodeTypeName + " " + node.name + " " + msg
1369
- };
1370
- node.tsErrorDetail = diagnostic;
1371
- diagnostics.push(diagnostic);
1372
- }
1373
- else {
1374
- node.tsErrorDetail = undefined;
1375
- }
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
- });
1384
- }
1385
- return diagnostics;
1386
- };
1387
- NaslServer.prototype.checkNodeError = function (node, diagnostics) {
1388
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1389
- if (!node)
1390
- return;
1391
- // 如果节点是match的看看节点里是不是有重复的
1392
- if (node instanceof concepts_1.Match) {
1393
- var typeMap_1 = {};
1394
- if ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.__TypeAnnotation) {
1395
- var _k = node.expression.__TypeAnnotation, typeName = _k.typeName, typeNamespace = _k.typeNamespace;
1396
- if (typeName === 'Union' || typeName === 'Boolean' || (typeNamespace === null || typeNamespace === void 0 ? void 0 : typeNamespace.endsWith('enums'))) {
1397
- node.cases.forEach(function (item) {
1398
- if (Array.isArray(item.patterns)) {
1399
- item.patterns.forEach(function (pattern) {
1400
- var _a, _b;
1401
- if (pattern instanceof concepts_1.TypeAnnotation) {
1402
- if (typeMap_1[pattern.sortedTypeKey]) {
1403
- typeMap_1[pattern.sortedTypeKey].push(pattern);
1404
- }
1405
- else {
1406
- typeMap_1[pattern.sortedTypeKey] = [pattern];
1407
- }
1408
- }
1409
- else if (pattern instanceof concepts_1.MemberExpression) {
1410
- if (pattern.completeName && ((_b = (_a = pattern.object) === null || _a === void 0 ? void 0 : _a.namespace) === null || _b === void 0 ? void 0 : _b.endsWith('enums'))) {
1411
- var onlyKey = pattern.completeName;
1412
- if (typeMap_1[onlyKey]) {
1413
- typeMap_1[onlyKey].push(pattern);
1414
- }
1415
- else {
1416
- typeMap_1[onlyKey] = [pattern];
1417
- }
1418
- }
1419
- }
1420
- else if (pattern instanceof concepts_1.BooleanLiteral) {
1421
- var onlyKey = pattern.concept + pattern.value;
1422
- if (typeMap_1[onlyKey]) {
1423
- typeMap_1[onlyKey].push(pattern);
1424
- }
1425
- else {
1426
- typeMap_1[onlyKey] = [pattern];
1427
- }
1428
- }
1429
- });
1430
- }
1431
- });
1432
- }
1433
- }
1434
- Object.keys(typeMap_1).forEach(function (item) {
1435
- if (typeMap_1[item].length > 1) {
1436
- typeMap_1[item].forEach(function (nodeItem) {
1437
- var diagnostic = {
1438
- node: nodeItem,
1439
- severity: 'error',
1440
- message: '匹配:重复添加类型',
1441
- titleTip: '重复添加此项'
1442
- };
1443
- nodeItem.tsErrorDetail = diagnostic;
1444
- diagnostics.push(diagnostic);
1445
- });
1446
- }
1447
- });
1448
- }
1449
- // 如果节点是match的patterns 里的
1450
- if ((node === null || node === void 0 ? void 0 : node.parentKey) === 'patterns' && node.parentNode instanceof concepts_1.MatchCase) {
1451
- var matchNode = node.getAncestor('Match');
1452
- var matchExpressionType = (_c = (_b = matchNode) === null || _b === void 0 ? void 0 : _b.expression) === null || _c === void 0 ? void 0 : _c.__TypeAnnotation;
1453
- // 判断union类型是不是重复
1454
- // 先使用ts原始的报错,这个先注释掉
1455
- if (node instanceof concepts_1.TypeAnnotation && (matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeKind) === 'union') {
1456
- var haveType = matchExpressionType === null || matchExpressionType === void 0 ? void 0 : matchExpressionType.typeArguments.find(function (item) { return item.sortedTypeKey === node.sortedTypeKey; });
1457
- if (!haveType) {
1458
- var diagnostic = {
1459
- node: node,
1460
- severity: 'error',
1461
- message: '匹配:选择类型不存在',
1462
- titleTip: '该类型已被删除'
1463
- };
1464
- node.tsErrorDetail = diagnostic;
1465
- diagnostics.push(diagnostic);
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);
1489
- }
1490
- if (node.tsErrorDetail) {
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)) {
1493
- node.tsErrorDetail.titleTip = '该枚举值已被删除';
1494
- }
1495
- else if (!node.tsErrorDetail.titleTip) {
1496
- node.tsErrorDetail.titleTip = '该值已被删除';
1497
- }
1498
- }
1499
- }
1500
- // 如果forEach 中的each的内容是union类型就要提示报错
1501
- if ((node === null || node === void 0 ? void 0 : node.parentKey) === 'each' && ((_e = node === null || node === void 0 ? void 0 : node.__TypeAnnotation) === null || _e === void 0 ? void 0 : _e.typeKind) === 'union') {
1502
- var diagnostic = {
1503
- node: node,
1504
- severity: 'error',
1505
- message: 'ForEach:参数类型不一致!传入类型:联合类型。接受类型:List类型。'
1506
- };
1507
- node.tsErrorDetail = diagnostic;
1508
- diagnostics.push(diagnostic);
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
- }
1529
- };
1530
- /* 接口导入查找 */
1531
- NaslServer.prototype.existStructureFix = function (semanticDiagnostics, node, that) {
1532
- var _this = this;
1533
- var module;
1534
- semanticDiagnostics.map(function (diag) {
1535
- var _a, _b, _c, _d;
1536
- var minRange = _this._findMinRange(diag, node);
1537
- if ((_a = diag.text) === null || _a === void 0 ? void 0 : _a.includes('has no exported member named')) {
1538
- if (minRange.node instanceof concepts_1.Logic) {
1539
- return null;
1540
- }
1541
- var typeAnnotation = minRange.node instanceof concepts_1.TypeAnnotation ? minRange.node.upperNode.typeAnnotation : minRange.node.typeAnnotation;
1542
- var regNamespace = /<(\S*)>/;
1543
- var typeKey = (typeAnnotation.typeKey.match(regNamespace) && typeAnnotation.typeKey.match(regNamespace)[1]) || typeAnnotation.typeKey;
1544
- var typeKeyArr = typeKey.split('.');
1545
- if (typeKeyArr[0] === 'apis') {
1546
- var structureName_1 = typeKeyArr[3];
1547
- var moduleName_1 = typeKeyArr[1];
1548
- var app = typeAnnotation.upperNode.app;
1549
- if (!app) {
1550
- return null;
1551
- }
1552
- module = (_b = app.interfaceDependencies) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.name === moduleName_1; });
1553
- var existStructure = (_c = module === null || module === void 0 ? void 0 : module.structures) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.name.toUpperCase() === structureName_1.toUpperCase(); });
1554
- if (!existStructure) {
1555
- var realName_1 = structureName_1.replace(/\d*$/, function (m) { return String(''); });
1556
- existStructure = (_d = module === null || module === void 0 ? void 0 : module.structures) === null || _d === void 0 ? void 0 : _d.find(function (item) { return item.name.toUpperCase() === realName_1.toUpperCase(); });
1557
- }
1558
- if (existStructure) {
1559
- var editTypeAnnotation = JSON.parse(JSON.stringify(typeAnnotation).replace(new RegExp(structureName_1, 'g'), existStructure.name));
1560
- actionArr.push({ target: typeAnnotation.parentNode, typeannotation: editTypeAnnotation });
1561
- }
1562
- }
1563
- return null;
1564
- }
1565
- else {
1566
- return diag;
1567
- }
1568
- });
1569
- if (actionArr.length) {
1570
- if (timer)
1571
- return;
1572
- timer = window.setTimeout(function () {
1573
- var app = actionArr[0].target.app;
1574
- app.emit('collect:start', {
1575
- actionMsg: '设置导入接口数据类型错误'
1576
- });
1577
- module.isAdd && module.setIsAdd(false);
1578
- actionArr.forEach(function (item) {
1579
- item.target.setDataType(concepts_1.TypeAnnotation.from(item.typeannotation));
1580
- });
1581
- app.emit('collect:end');
1582
- actionArr = [];
1583
- isChangeInterface = false;
1584
- clearTimeout(timer);
1585
- timer = null;
1586
- }, 2000);
1587
- }
1588
- };
1589
- /**
1590
- * 单个问题的诊断处理
1591
- * @param diagnostic 诊断问题
1592
- * @param fileNode 页面节点
1593
- * @returns 处理后的结果
1594
- */
1595
- NaslServer.prototype._resolveDiagnostic = function (diagnostic, fileNode, record) {
1596
- // 拓展模块中的翻译先过滤掉,因为有错用户也不能修改
1597
- if (fileNode.module)
1598
- return;
1599
- var minRange = this._findMinRange(diagnostic, fileNode);
1600
- var tsErrorDetail = {
1601
- severity: diagnostic.category === 'error' ? 'error' : 'warning',
1602
- message: translator_2.translateDiagnosticMessage(diagnostic.text),
1603
- // 保留原来的内容方便查询一些问题
1604
- originalDiagnostic: diagnostic
1605
- };
1606
- var result;
1607
- if (minRange) {
1608
- // 节点的error要置为true
1609
- result = translator_2.naslNodeTranslateMessage(minRange, tsErrorDetail);
1610
- }
1611
- else {
1612
- // 没找到节点, 先把问题暴露出来
1613
- result = tsErrorDetail;
1614
- }
1615
- if (result)
1616
- result.id = record.filePath + (result ? JSON.stringify({ start: result.originalDiagnostic.start, end: result.originalDiagnostic.end }) : '');
1617
- return result;
1618
- };
1619
- /**
1620
- * 通过节点诊断反过来查找节点
1621
- * @param diagnostic 诊断信息
1622
- * @param fileNode 文件级别节点
1623
- * @returns 找到的节点
1624
- */
1625
- NaslServer.prototype._findMinRange = function (diagnostic, fileNode) {
1626
- var minRange;
1627
- var sourceMap = fileNode.sourceMap;
1628
- for (var _i = 0, _a = sourceMap.entries(); _i < _a.length; _i++) {
1629
- var _b = _a[_i], node = _b[0], item = _b[1];
1630
- /**
1631
- * 当前内容的开始行 <= 诊断开始的行 &&
1632
- * 当前内容的结束行 >= 诊断结束的行
1633
- */
1634
- if (translator_1.lsp2tspNumber(item.range.start.line) <= diagnostic.start.line && translator_1.lsp2tspNumber(item.range.end.line) >= diagnostic.end.line) {
1635
- // 如果找到某一行
1636
- if (translator_1.lsp2tspNumber(item.range.start.line) === diagnostic.start.line && translator_1.lsp2tspNumber(item.range.end.line) === diagnostic.end.line) {
1637
- // 在行的范围但是又不在列的范围,不用给默认值,给了反而不对,
1638
- // 需要在列的范围内
1639
- if (translator_1.lsp2tspNumber(item.range.start.character) <= diagnostic.start.offset && translator_1.lsp2tspNumber(item.range.end.character) >= diagnostic.end.offset) {
1640
- // 比列更靠近 ,满足条件且长度更短
1641
- // 如果先走到下面有一个默认值了就像在if for里面有个表达式
1642
- // if for的内容也是包括当前的所以会重新赋值
1643
- if (!minRange || item.code.length < minRange.item.code.length) {
1644
- minRange = { item: item, node: node };
1645
- }
1646
- }
1647
- }
1648
- else {
1649
- // 没有节点 或者 行差比较小比已有的小就可以
1650
- // 一般出现在一大块上,多半是if for 等等没有参数
1651
- if (!minRange || item.range.end.line - item.range.start.line < minRange.item.range.end.line - minRange.item.range.start.line) {
1652
- minRange = { node: node, item: item };
1653
- }
1654
- }
1655
- }
1656
- }
1657
- if (!minRange) {
1658
- if (fileNode instanceof concepts_1.View) {
1659
- return { node: fileNode, item: sourceMap.get(fileNode) };
1660
- }
1661
- console.log(minRange, '需要特殊看下,为什么没找到内容-------------');
1662
- }
1663
- return minRange;
1664
- };
1665
- /**
1666
- * 查看当前节点是不是有引用
1667
- * @param node 节点
1668
- * @returns 查找到的数组
1669
- */
1670
- NaslServer.prototype._isHaveRef = function (node) {
1671
- return __awaiter(this, void 0, void 0, function () {
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;
1673
- var _this = this;
1674
- return __generator(this, function (_b) {
1675
- switch (_b.label) {
1676
- case 0:
1677
- _a = this.getCurrentSource(node), currentSource = _a.currentSource, fileNode = _a.fileNode;
1678
- refsList = [];
1679
- if (!currentSource) return [3 /*break*/, 2];
1680
- return [4 /*yield*/, this.references({
1681
- file: fileNode.getEmbeddedFilePath(),
1682
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
1683
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
1684
- })];
1685
- case 1:
1686
- newRefs = _b.sent();
1687
- refsList = __spreadArrays(newRefs.refs);
1688
- return [3 /*break*/, 4];
1689
- case 2:
1690
- if (!(node instanceof concepts_1.Module)) return [3 /*break*/, 4];
1691
- lists = node.logics || node.structures || node.enums;
1692
- moduleName_2 = fileNode.getEmbeddedFilePath();
1693
- if (!lists.length) return [3 /*break*/, 4];
1694
- item = lists[0];
1695
- fileNode_2 = this.getCurrentSource(item).fileNode;
1696
- if (!fileNode_2) return [3 /*break*/, 4];
1697
- return [4 /*yield*/, this.references({
1698
- file: fileNode_2.getEmbeddedFilePath(),
1699
- line: 1,
1700
- offset: 22
1701
- })];
1702
- case 3:
1703
- newRefs = _b.sent();
1704
- refsList = newRefs.refs.filter(function (item) { return !item.file.startsWith(moduleName_2); });
1705
- // 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
1706
- refsList.unshift(newRefs.refs[0]);
1707
- _b.label = 4;
1708
- case 4:
1709
- // 如果是DataSource就需要在单独,查一边来修改名字
1710
- if (node instanceof concepts_1.DataSource) {
1711
- // 过滤一把不需要改的信息
1712
- refsList = refsList.filter(function (item) {
1713
- var dataSourceFile = fileNode.getEmbeddedFilePath();
1714
- var entityFilePrefix = dataSourceFile.replace('.ts', '');
1715
- /**
1716
- * 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
1717
- * 所以全部过滤掉了,
1718
- * 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了11个函数之外的引用
1719
- * 所以底部内容是11个函数,所以这里就 用entity的行数 减去11个函数的行数,然后其余的在进行处理
1720
- * 进行过滤
1721
- */
1722
- // 不要数据源下面的实体里的引用 ,保留原始的节点内容
1723
- var flag = false;
1724
- if (item.file.includes(entityFilePrefix)) {
1725
- var entity = _this.file2NodeMap.get(item.file);
1726
- var currentSource_3 = _this.getCurrentSource(entity).currentSource;
1727
- // 42 11个函数的总行数
1728
- if (item.end.line < currentSource_3.range.end.line - 42 && item.start.line > 1) {
1729
- flag = true;
1730
- }
1731
- }
1732
- // 属于实体而且需要修改和查到 || 不是实体前缀的 || 他本身
1733
- return flag || !item.file.includes(entityFilePrefix) || dataSourceFile === item.file;
1734
- });
1735
- }
1736
- // 如果是entity就需要在单独,查一边来修改名字
1737
- if (node instanceof concepts_1.Entity) {
1738
- // 过滤一把不需要改的信息
1739
- refsList = refsList.filter(function (item) { return fileNode.getEmbeddedFilePath() !== item.file || item.isDefinition === true; });
1740
- // 不再当前文件里
1741
- // 或者在当前列表但是位置小于entity的结束位置
1742
- }
1743
- if (node instanceof concepts_1.Return) {
1744
- // 过滤一下最后出去的值
1745
- refsList = refsList.filter(function (item) { return !item.lineText.includes('return '); });
1746
- }
1747
- if (!(node instanceof concepts_1.Param && node.parentNode instanceof concepts_1.Logic && node.parentKey !== 'virtualParams')) return [3 /*break*/, 6];
1748
- logicNode = node.parentNode;
1749
- currentSource_1 = this.getCurrentSource(logicNode).currentSource;
1750
- return [4 /*yield*/, this.references({
1751
- file: fileNode.getEmbeddedFilePath(),
1752
- line: translator_1.lsp2tspNumber(currentSource_1.range.start.line),
1753
- offset: translator_1.lsp2tspNumber(currentSource_1.range.start.character)
1754
- })];
1755
- case 5:
1756
- parentRefs = _b.sent();
1757
- refsList = __spreadArrays(refsList, parentRefs.refs);
1758
- _b.label = 6;
1759
- case 6:
1760
- if (!(node instanceof concepts_1.Param && (node.parentNode instanceof concepts_1.View || node.parentNode instanceof concepts_1.Process))) return [3 /*break*/, 8];
1761
- viewNode = node.parentNode;
1762
- currentSource_2 = this.getCurrentSource(viewNode).currentSource;
1763
- code = currentSource_2.code;
1764
- viewIndex = code.indexOf(' {');
1765
- return [4 /*yield*/, this.references({
1766
- file: fileNode.getEmbeddedFilePath(),
1767
- line: translator_1.lsp2tspNumber(currentSource_2.range.start.line),
1768
- offset: translator_1.lsp2tspNumber(currentSource_2.range.start.character + viewIndex)
1769
- })];
1770
- case 7:
1771
- viewRefs = _b.sent();
1772
- filterViewRefs = [];
1773
- if (node.parentNode instanceof concepts_1.View) {
1774
- filterViewRefs = viewRefs.refs.filter(function (item) { return item.lineText.includes('.$destination('); });
1775
- }
1776
- else {
1777
- // 如果是参数修改, 就需要把Process的引用查找出来
1778
- filterViewRefs = viewRefs.refs.filter(function (item) { return item.lineText.includes('.launch('); });
1779
- }
1780
- refsList = __spreadArrays(refsList, filterViewRefs);
1781
- _b.label = 8;
1782
- case 8:
1783
- if (!(node instanceof concepts_1.ViewElement)) return [3 /*break*/, 10];
1784
- if (!currentSource) return [3 /*break*/, 10];
1785
- code = currentSource.code;
1786
- prefix = '__elements.';
1787
- prefixIndex = code.indexOf(prefix) !== -1 ? code.indexOf(prefix) : 0;
1788
- methodsNameIndex = prefixIndex + prefix.length;
1789
- return [4 /*yield*/, this.references({
1790
- file: fileNode.getEmbeddedFilePath(),
1791
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
1792
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character + methodsNameIndex)
1793
- })];
1794
- case 9:
1795
- methods = _b.sent();
1796
- methodRefs_1 = [];
1797
- methods.refs.forEach(function (item) {
1798
- // 定义里的格式,在删除的时候留下来占位
1799
- // 重命名的时候会过滤
1800
- // 这里只过滤 __elements.button = new nasl.ui.Button<any>这种格式
1801
- // 处理声明组件名可能重复的问题, 查找引用不提示
1802
- var find = methodRefs_1.find(function (findItem) { return item.lineText === findItem.lineText && item.lineText.includes(': nasl.ui.'); });
1803
- if (!find) {
1804
- methodRefs_1.push(item);
1805
- }
1806
- });
1807
- refsList = __spreadArrays(methodRefs_1);
1808
- _b.label = 10;
1809
- case 10:
1810
- // console.log(refsList, 'refsList');
1811
- return [2 /*return*/, refsList];
1812
- }
1813
- });
1814
- });
1815
- };
1816
- /**
1817
- * 查找引用,并且做一些 修改前的准备工作,
1818
- * 有引用有的话,就返回集合
1819
- * @param node 当前重命名的节点
1820
- * @param newValue 传递过来的新值,给MemberExpression用的比较特殊
1821
- * 而且,这个新值不一定会用到,MemberExpression在批量更新的时候,可以取到新的value, 这里需要位置信息防止 a.a.a.a 中的一个a发生修改
1822
- * @returns 找到的引用
1823
- */
1824
- NaslServer.prototype._renamePrepare = function (node, refsList, newValue) {
1825
- var _this = this;
1826
- var oldName = node === null || node === void 0 ? void 0 : node.name;
1827
- var result = refsList
1828
- .map(function (record) {
1829
- var fileNode = _this.file2NodeMap.get(record.file);
1830
- if (!fileNode)
1831
- return null;
1832
- var minRange = _this._findMinRange(record, fileNode);
1833
- if (minRange) {
1834
- // 节点上ts临时变量标识,如果有这个就不rename
1835
- if (minRange.node.noTsReName) {
1836
- return null;
1837
- }
1838
- // 如果节点是TypeAnnotation类型,
1839
- // 很复杂,可能是多级嵌套结构
1840
- // 不一定只修改typeName
1841
- if (minRange.node instanceof concepts_1.TypeAnnotation) {
1842
- // console.log(record);
1843
- // 如果是fake的逻辑,内部的重命名都不需要修改
1844
- // if ((minRange.node?.parentNode as any).logic && (minRange.node?.parentNode as any).logic?.fake) {
1845
- // return null;
1846
- // }
1847
- minRange.setTypeMethods = 'setTypeName';
1848
- }
1849
- // 如果节点是logic修改引发calllogic修改
1850
- if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Logic) {
1851
- minRange.setTypeMethods = 'setCalleeName';
1852
- }
1853
- if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.ViewElement) {
1854
- minRange.setTypeMethods = 'setCalleeNamespace';
1855
- minRange.newValue = 'elements.' + newValue + '.logics';
1856
- }
1857
- // 如果节点是实体修改引发calllogic修改
1858
- if (minRange.node instanceof concepts_1.CallLogic && (node instanceof concepts_1.Entity || node instanceof concepts_1.View || node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
1859
- // 匹配到的内容,当前这一行的内容;
1860
- // 因为要用下面的点位信息
1861
- /**
1862
- * 如果namespce是 'app.views.Student.views.404.views.505.views.update'
1863
- * 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
1864
- * 但是505 要改名为 666 ,要存的是666
1865
- * 'app.views.Student.views.404.views.666.views.update'
1866
- * 1.取到转后的
1867
- * 2.在匹配到的内容中取转后的namespace的位置
1868
- * 3.然后把namespace中的 $替换成 ''
1869
- *
1870
- */
1871
- var tsCalleeNamespace = minRange.node.tsCalleeNamespace;
1872
- // 先看下标位置
1873
- var lineText = record.lineText;
1874
- var index = lineText.indexOf(tsCalleeNamespace);
1875
- // 在把开始结束位置的-开始位置,来知道是哪里要替换
1876
- var start = record.start.offset - index - 1;
1877
- var end = record.end.offset - index - 1;
1878
- // 新的完整的value
1879
- var newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
1880
- newTsNameSpace = newTsNameSpace.replace(/.\$/g, '.');
1881
- minRange.setTypeMethods = 'setCalleeNamespace';
1882
- minRange.newValue = newTsNameSpace;
1883
- }
1884
- // 如果参数修改影响了 callLogic
1885
- if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
1886
- return null;
1887
- // 逻辑第几个位置发生修改,对应的calllogic对应位置的内容要进行修改
1888
- // minRange.setTypeMethods = 'setArgumentName';
1889
- // const nodeArguments = minRange.node.arguments;
1890
- // minRange.newValue = [...nodeArguments];
1891
- // const LogicNode = node.parentNode;
1892
- // const paramIndex = (LogicNode as Logic).params.findIndex((param) => param === node);
1893
- // console.log(node, nodeArguments);
1894
- // if (paramIndex !== -1) {
1895
- // minRange.setTypeMethods = 'setArgumentName';
1896
- // minRange.newValue = {
1897
- // argument: nodeArguments[paramIndex],
1898
- // newKeyword: newValue,
1899
- // };
1900
- // } else {
1901
- // return null;
1902
- // }
1903
- }
1904
- // 如果节点是Identifier表达式
1905
- if (minRange.node instanceof concepts_1.Identifier) {
1906
- // 匹配到的内容,当前这一行的内容;
1907
- // 因为要用下面的点位信息
1908
- var name = minRange.node.name;
1909
- // 如果name不改,那就是要改命名空间
1910
- if (newValue === name) {
1911
- var namespace = minRange.node.namespace;
1912
- // 先看下标位置
1913
- var lineText = record.lineText;
1914
- var index = lineText.indexOf(namespace);
1915
- // 在把开始结束位置的-开始位置,来知道是哪里要替换
1916
- var start = record.start.offset - index - 1;
1917
- var end = record.end.offset - index - 1;
1918
- // 新的完整的value
1919
- var newTextValue = namespace.substring(0, start) + newValue + namespace.substring(end, namespace.length);
1920
- minRange.setTypeMethods = 'setNamespace';
1921
- minRange.newValue = newTextValue;
1922
- }
1923
- }
1924
- if (node instanceof concepts_1.Enum) {
1925
- // 如果是枚举修改,枚举的值刚好在Identifier 中选了 就修改值
1926
- if (minRange.node instanceof concepts_1.Identifier) {
1927
- minRange.newValue = newValue;
1928
- minRange.setTypeMethods = 'setName';
1929
- }
1930
- else if (minRange.node instanceof concepts_1.EntityProperty) {
1931
- // 如果枚举自己改名引用到了实体字段,而不是实体字段下的类型,就说明是默认值,默认值可以不处理
1932
- return null;
1933
- }
1934
- }
1935
- // 如果修改逻辑,改到了Identifier表达式,只能说明是在属性里有使用了
1936
- if (minRange.node instanceof concepts_1.Identifier && node instanceof concepts_1.Logic) {
1937
- minRange.newValue = newValue;
1938
- minRange.setTypeMethods = 'setName';
1939
- }
1940
- // 如果节点是MemberExpression表达式
1941
- if (minRange.node instanceof concepts_1.MemberExpression) {
1942
- // 枚举key的特殊性,因为它不是原来的key+value形式的
1943
- // 是加了中括号啥的,所以直接赋值新值
1944
- if (node instanceof concepts_1.EnumItem) {
1945
- var newTextValue = node.parentNode.name + '.' + newValue;
1946
- minRange.newValue = newTextValue;
1947
- }
1948
- else {
1949
- // 匹配到的内容,当前这一行的内容;
1950
- // 因为要用下面的点位信息
1951
- var a = record.lineText;
1952
- // 之前的内容
1953
- var oldValue = minRange.node.getValue();
1954
- var index = a.indexOf(oldValue);
1955
- var start = record.start.offset - index - 1;
1956
- var end = record.end.offset - index - 1;
1957
- var newTextValue = oldValue.substring(0, start) + newValue + oldValue.substring(end, oldValue.length);
1958
- // MemberExpression可能改的是多层中的某一个
1959
- // 倒序, 对比看是哪里发生了修改
1960
- // 比较特殊就把新匹配到的值返回内部自己看要改那个地方的值
1961
- minRange.newValue = newTextValue;
1962
- }
1963
- }
1964
- if (node instanceof concepts_1.Entity) {
1965
- // 如果是修改实体,引发节点依赖实体发生改变的
1966
- if (minRange.node instanceof concepts_1.EntityProperty) {
1967
- minRange.setTypeMethods = 'setRelationEntity';
1968
- }
1969
- else if (minRange.node instanceof concepts_1.QueryFieldExpression || minRange.node instanceof concepts_1.QueryGroupByExpression) {
1970
- minRange.setTypeMethods = 'setEntityAsName';
1971
- }
1972
- else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
1973
- minRange.setTypeMethods = 'setEntityName';
1974
- }
1975
- else if (minRange.node instanceof concepts_1.BindAttribute && minRange.node.name === 'url') {
1976
- // 如果是查找到 上传地址的链接引用
1977
- var newName = newValue.replace(/[A-Z]/g, function (item) { return '-' + item.toLowerCase(); });
1978
- newName = newName[0] === '-' ? newName.slice(1) : newName;
1979
- var newTextValue = node.parentNode.name === 'defaultDS' ? "/api/" + newName + "/import" : "/api/" + node.parentNode.name + "/" + newName + "/import";
1980
- minRange.setTypeMethods = 'setUrlValue';
1981
- minRange.newValue = newTextValue;
1982
- }
1983
- }
1984
- // 如果是修改实体属性,要同步实体属性
1985
- if (minRange.node instanceof concepts_1.EntityProperty && node instanceof concepts_1.EntityProperty && record.lineText.includes('@nasl.annotation.EntityRelation')) {
1986
- minRange.setTypeMethods = 'setRelationProperty';
1987
- }
1988
- // 如果要修改索引的
1989
- if (minRange.node instanceof concepts_1.EntityIndex) {
1990
- var newPropertyNameList = __spreadArrays(minRange.node.propertyNames);
1991
- var findIndex = newPropertyNameList.findIndex(function (item) { return item === oldName; });
1992
- if (findIndex !== -1) {
1993
- // 修改数组的值
1994
- newPropertyNameList.splice(findIndex, 1, newValue);
1995
- minRange.setTypeMethods = 'setPropertyNameList';
1996
- minRange.newValue = newPropertyNameList;
1997
- }
1998
- }
1999
- // 如果是跳转逻辑的修改
2000
- // 跳转逻辑本身页面 都需要带 View前缀
2001
- if (node instanceof concepts_1.View && minRange.node instanceof concepts_1.Destination) {
2002
- /**
2003
- * 如果namespce是 'app.views.Student.views.404.views.505.views.update'
2004
- * 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
2005
- * 但是505 要改名为 666 ,要存的是666
2006
- * 'app.views.Student.views.404.views.666.views.update'
2007
- * 1.取到转后的
2008
- * 2.在匹配到的内容中取转后的namespace的位置
2009
- * 3.然后把namespace中的 $替换成 ''
2010
- *
2011
- */
2012
- var tsCalleeNamespace = minRange.node.tsCalleeNamespace;
2013
- var tsName = minRange.node.tsName;
2014
- var oldValue = tsCalleeNamespace + '.' + tsName;
2015
- // 先看下标位置
2016
- var lineText = record.lineText;
2017
- var index = lineText.indexOf(oldValue);
2018
- // 在把开始结束位置的-开始位置,来知道是哪里要替换
2019
- var start = record.start.offset - index - 1;
2020
- var end = record.end.offset - index - 1;
2021
- if (start > tsCalleeNamespace.length) {
2022
- minRange.setTypeMethods = 'setViewName';
2023
- minRange.newValue = newValue;
2024
- }
2025
- else {
2026
- // 新的完整的value
2027
- var newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
2028
- minRange.setTypeMethods = 'setViewNamespace';
2029
- newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
2030
- minRange.newValue = newTsNameSpace;
2031
- }
2032
- }
2033
- // 如果是事件修改
2034
- // 如果是view也需要加前缀
2035
- // logic 和 views名称修改 可能会触发bindEvent修改
2036
- if (minRange.node instanceof concepts_1.BindEvent) {
2037
- // 页面逻辑直接赋值就可以, 因为是相对路径
2038
- if (node instanceof concepts_1.ViewElement) {
2039
- minRange.setTypeMethods = 'setCalleeNamespace';
2040
- minRange.newValue = 'elements.' + newValue + '.logics';
2041
- }
2042
- else {
2043
- /**
2044
- * 如果namespce是 'app.views.Student.views.404.views.505.views.update'
2045
- * 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
2046
- * 但是505 要改名为 666 ,要存的是666
2047
- * 'app.views.Student.views.404.views.666.views.update'
2048
- * 1.取到转后的
2049
- * 2.在匹配到的内容中取转后的namespace的位置
2050
- * 3.然后把namespace中的 $替换成 ''
2051
- */
2052
- var tsCalleeNamespace = minRange.node.tsCalleeNamespace;
2053
- var oldValue = tsCalleeNamespace;
2054
- // 先看下标位置
2055
- var lineText = record.lineText;
2056
- var index = lineText.indexOf(oldValue);
2057
- // 在把开始结束位置的-开始位置,来知道是哪里要替换
2058
- var start = record.start.offset - index - 1;
2059
- var end = record.end.offset - index - 1;
2060
- // 新的完整的value
2061
- if (start > tsCalleeNamespace.length) {
2062
- minRange.setTypeMethods = 'setCalleeName';
2063
- minRange.newValue = newValue;
2064
- }
2065
- else {
2066
- // 新的完整的value
2067
- var newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
2068
- minRange.setTypeMethods = 'setCalleeNamespace';
2069
- newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
2070
- minRange.newValue = newTsNameSpace;
2071
- }
2072
- }
2073
- }
2074
- if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
2075
- // 因为view是key value 绑定所以需要重新赋值
2076
- if (node.parentNode instanceof concepts_1.View) {
2077
- var nodeArguments = minRange.node.arguments;
2078
- var findArgument = nodeArguments.find(function (item) { return node.name === item.keyword; });
2079
- if (findArgument) {
2080
- minRange.setTypeMethods = 'setArgumentsKeyWord';
2081
- minRange.newValue = {
2082
- findArgument: findArgument,
2083
- newKeyword: newValue
2084
- };
2085
- }
2086
- }
2087
- else {
2088
- // 如果是修改param查找到Destination就不操作
2089
- return null;
2090
- }
2091
- }
2092
- if (minRange.node instanceof concepts_1.Interface && node instanceof concepts_1.Logic) {
2093
- minRange.setTypeMethods = 'setOriginLogicName';
2094
- }
2095
- // 如果是role改名,就需要查到变更后的数组
2096
- if ((minRange.node instanceof concepts_1.View || minRange.node instanceof concepts_1.ViewElement) && node instanceof concepts_1.Role) {
2097
- // oldName旧的节点存的值
2098
- // newValue用户输入值
2099
- // node.bindRoles 存的
2100
- minRange.setTypeMethods = 'setBindRoles';
2101
- var str = minRange.node.bindRoles.toString().replace(oldName, newValue);
2102
- var newBindRoles = str.split(',');
2103
- minRange.newValue = newBindRoles;
2104
- }
2105
- // 修改枚举值找到了EntityProperty就说明给了默认值
2106
- if (node instanceof concepts_1.EnumItem) {
2107
- if (minRange.node instanceof concepts_1.EntityProperty || minRange.node instanceof concepts_1.StructureProperty) {
2108
- minRange.setTypeMethods = 'setDefaultValue';
2109
- }
2110
- if (minRange.node instanceof concepts_1.Param || minRange.node instanceof concepts_1.Variable || minRange.node instanceof concepts_1.Return) {
2111
- minRange.setTypeMethods = 'setDefaultValue';
2112
- }
2113
- }
2114
- // 如果修改的是dataSource属性
2115
- if (node instanceof concepts_1.DataSource) {
2116
- var setTypeNamespace = function (typeNamespace, record) {
2117
- // 先看下标位置
2118
- var lineText = record.lineText;
2119
- var index = lineText.indexOf(typeNamespace);
2120
- // 在把开始结束位置的-开始位置,来知道是哪里要替换
2121
- var start = record.start.offset - index - 1;
2122
- var end = record.end.offset - index - 1;
2123
- // 新的完整的value
2124
- var newTextValue = typeNamespace.substring(0, start) + newValue + typeNamespace.substring(end, typeNamespace.length);
2125
- minRange.newValue = newTextValue;
2126
- return newTextValue;
2127
- };
2128
- if (minRange.node instanceof concepts_1.TypeAnnotation) {
2129
- minRange.setTypeMethods = 'setTypeNamespace';
2130
- var newValue_1 = setTypeNamespace(minRange.node.typeNamespace, record);
2131
- minRange.newValue = newValue_1;
2132
- }
2133
- else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
2134
- minRange.setTypeMethods = 'setEntityNamespace';
2135
- var newValue_2 = setTypeNamespace(minRange.node.entityNamespace, record);
2136
- minRange.newValue = newValue_2;
2137
- }
2138
- else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
2139
- return null;
2140
- }
2141
- else if (minRange.node instanceof concepts_1.CallLogic) {
2142
- minRange.setTypeMethods = 'setCalleeNamespace';
2143
- var newValue_3 = setTypeNamespace(minRange.node.calleeNamespace, record);
2144
- minRange.newValue = newValue_3;
2145
- }
2146
- else if (minRange.node instanceof concepts_1.EntityProperty) {
2147
- minRange.setTypeMethods = 'setRelationNamespace';
2148
- var newValue_4 = setTypeNamespace(minRange.node.relationNamespace, record);
2149
- minRange.newValue = newValue_4;
2150
- }
2151
- else if (minRange.node instanceof concepts_1.SqlQueryComponent || minRange.node instanceof concepts_1.OqlQueryComponent) {
2152
- minRange.setTypeMethods = 'renameDataSource';
2153
- }
2154
- }
2155
- if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.EntityProperty) {
2156
- minRange.setTypeMethods = 'setPropertyName';
2157
- }
2158
- if (minRange.node instanceof concepts_1.QueryGroupByExpression && node instanceof concepts_1.EntityProperty) {
2159
- minRange.setTypeMethods = 'setPropertyName';
2160
- }
2161
- // 如果跳转链接或者页面变量同一个param和TypeAnnotation 有两个过滤掉一个
2162
- if ((minRange.node instanceof concepts_1.Param || minRange.node instanceof concepts_1.Variable || minRange.node instanceof concepts_1.Return)
2163
- && (node instanceof concepts_1.Entity || node instanceof concepts_1.Enum || node instanceof concepts_1.Structure)) {
2164
- return null;
2165
- }
2166
- if (minRange.node instanceof concepts_1.Destination && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
2167
- return null;
2168
- }
2169
- if (minRange.node instanceof concepts_1.Assignee && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
2170
- return null;
2171
- }
2172
- // 枚举修改枚举名,比较特殊
2173
- if (minRange.node instanceof concepts_1.EnumItem && node instanceof concepts_1.Enum) {
2174
- // 什么都不做,用来跳过修改
2175
- return null;
2176
- }
2177
- // params修改 查找bindevent不需要修改
2178
- if (minRange.node instanceof concepts_1.BindEvent && node instanceof concepts_1.Param) {
2179
- return null;
2180
- }
2181
- /**
2182
- * 理论上 logic setName只能自己触发,别的地方查到引用都不用重命名
2183
- * 流程改名不触发Logic改名
2184
- * 如果是修改param查找到logic就不操作
2185
- * 除非想在内部修改别的内容所以暂时屏蔽掉
2186
- */
2187
- if (minRange.node instanceof concepts_1.Logic && node !== minRange.node) {
2188
- return null;
2189
- }
2190
- if (node instanceof concepts_1.Param && minRange.node instanceof concepts_1.Interface) {
2191
- return null;
2192
- }
2193
- // 如果是被影响的是页面
2194
- if (minRange.node instanceof concepts_1.View) {
2195
- if (node instanceof concepts_1.View) {
2196
- // 如果是子页面修改
2197
- // 父页面引起子页面改名,就可以不改了,自动同步
2198
- if (minRange.node !== node) {
2199
- return null;
2200
- }
2201
- }
2202
- else if (!(node instanceof concepts_1.Role)) {
2203
- /**
2204
- * 无论是逻辑还是实体中的key,修改都不应该触发
2205
- * 理论上除了组件自己改名可以触发
2206
- * 下面这里 不属于Role是因为上面代码里有, 不符合 规范 的role改名存在所以先保留
2207
- */
2208
- return null;
2209
- }
2210
- }
2211
- // 如果是被影响的是页面元素
2212
- if (minRange.node instanceof concepts_1.ViewElement) {
2213
- if (node instanceof concepts_1.ViewElement) {
2214
- if (minRange.node !== node) {
2215
- return null;
2216
- }
2217
- }
2218
- else if (!(node instanceof concepts_1.Role)) {
2219
- /**
2220
- * 无论是逻辑还是实体中的key,修改都不应该触发
2221
- * 理论上除了组件自己改名可以触发
2222
- * 下面这里 不属于Role是因为上面代码里有, 不符合 规范 的role改名存在所以先保留
2223
- */
2224
- return null;
2225
- }
2226
- }
2227
- }
2228
- else {
2229
- console.log('没找到节点需要排查', record, fileNode.sourceMap);
2230
- }
2231
- return minRange;
2232
- })
2233
- // 过滤掉不需要操作的
2234
- .filter(function (item) { return !!item; });
2235
- return result;
2236
- };
2237
- // 增加参数的副作用,用于更新logic和view
2238
- NaslServer.prototype._addParamsEffect = function (refsList, node) {
2239
- var _this = this;
2240
- var parantNode = node === null || node === void 0 ? void 0 : node.parentNode;
2241
- refsList.forEach(function (record) {
2242
- var fileNode = _this.file2NodeMap.get(record.file);
2243
- if (!fileNode)
2244
- return null;
2245
- var minRange = _this._findMinRange(record, fileNode);
2246
- if (minRange) {
2247
- // 如果找到节点是callLogic就去更新
2248
- if ((minRange.node instanceof concepts_1.CallLogic || minRange.node instanceof concepts_1.Destination) && node instanceof concepts_1.Param) {
2249
- minRange.node.addCalleeArg(parantNode);
2250
- }
2251
- }
2252
- });
2253
- };
2254
- NaslServer.prototype._addParamsPrepare = function (node, refsList, needAdd) {
2255
- if (needAdd) {
2256
- var App_1 = node === null || node === void 0 ? void 0 : node.rootNode;
2257
- var parantNode = node === null || node === void 0 ? void 0 : node.parentNode;
2258
- // 收集修改
2259
- App_1.emit('collect:start', {
2260
- actionMsg: '增加逻辑参数'
2261
- });
2262
- var index = node.getIndexOfParent();
2263
- node.create({
2264
- index: index,
2265
- parentNode: parantNode,
2266
- parentKey: node.parentKey
2267
- });
2268
- this._addParamsEffect(refsList, node);
2269
- // 结束修改 ,批量操作
2270
- App_1.emit('collect:end');
2271
- return node;
2272
- }
2273
- this._addParamsEffect(refsList, node);
2274
- return node;
2275
- };
2276
- // 查找引用
2277
- NaslServer.prototype.findReferences = function (node) {
2278
- return __awaiter(this, void 0, void 0, function () {
2279
- var refsList, result, resMap, nodeMap;
2280
- var _this = this;
2281
- return __generator(this, function (_a) {
2282
- switch (_a.label) {
2283
- case 0: return [4 /*yield*/, this._isHaveRef(node)];
2284
- case 1:
2285
- refsList = _a.sent();
2286
- // 如果查找引用查到自己里面的引用不展示
2287
- refsList = refsList.filter(function (item) {
2288
- // 自己引用自己的过滤掉
2289
- // 删除的时候过滤一把组件删除提示
2290
- // 展示组件自己屏蔽掉
2291
- return !item.isDefinition && !item.lineText.includes(' = new nasl.ui.');
2292
- });
2293
- result = new Map();
2294
- resMap = new Map();
2295
- nodeMap = new Map();
2296
- try {
2297
- refsList.forEach(function (record) {
2298
- var fileNode = _this.file2NodeMap.get(record.file);
2299
- if (!fileNode)
2300
- return;
2301
- var minRange = _this._findMinRange(record, fileNode);
2302
- // 过滤一把不需要改的信息
2303
- if (minRange) {
2304
- // 拼装树
2305
- _this._getTreeMap(minRange, fileNode, resMap, nodeMap);
2306
- }
2307
- });
2308
- if (resMap.size > 0) {
2309
- result = this.handleTreeMap(resMap);
2310
- }
2311
- }
2312
- catch (err) {
2313
- console.log(err);
2314
- }
2315
- return [2 /*return*/, result];
2316
- }
2317
- });
2318
- });
2319
- };
2320
- // 获取节点的上层渲染
2321
- NaslServer.prototype._getTreeMap = function (minRange, fileNode, resMap, nodeMap) {
2322
- var minRangeNode = minRange.node;
2323
- var currentNode = minRangeNode;
2324
- var parantNode = currentNode;
2325
- // 顺序队列
2326
- var queue = [];
2327
- // 先插入自己,如果没有在往上找,
2328
- // 一直到file节点的父级
2329
- while (!(parantNode instanceof concepts_1.App)) {
2330
- // 找到上一级 在map对象中构造出他的子集
2331
- currentNode = parantNode;
2332
- parantNode = parantNode.parentNode;
2333
- // 如果第一次就塞入子集和父节点,以后就只用父节点了
2334
- // 因为部分节点没有name,先过滤掉
2335
- // if (currentNode.name) {
2336
- // }
2337
- // 排除一些不放入集合的节点
2338
- var isNeedPush = true;
2339
- // 如果不是ViewElement 或者 Assignment , 或者如果是的话, 排除l-root
2340
- if (currentNode instanceof concepts_1.ViewElement && currentNode.tag === 'l-root')
2341
- isNeedPush = false;
2342
- else if (currentNode instanceof concepts_1.Argument)
2343
- isNeedPush = false;
2344
- else if (currentNode instanceof concepts_1.Assignment)
2345
- isNeedPush = false;
2346
- else if (currentNode instanceof concepts_1.TypeAnnotation)
2347
- isNeedPush = false;
2348
- else if (currentNode instanceof concepts_1.CallQueryComponent)
2349
- isNeedPush = false;
2350
- else if (currentNode instanceof concepts_1.QueryFromExpression)
2351
- isNeedPush = false;
2352
- else if (currentNode instanceof concepts_1.TypeAnnotation)
2353
- isNeedPush = false;
2354
- // 需要放到数组中
2355
- if (isNeedPush) {
2356
- // 名称
2357
- // 赋值图标
2358
- var icon = '';
2359
- if (currentNode instanceof concepts_1.ViewElement)
2360
- icon = 'element';
2361
- else if (currentNode instanceof concepts_1.BindAttribute)
2362
- icon = 'attr';
2363
- else if (currentNode instanceof concepts_1.Destination)
2364
- icon = 'logicNode';
2365
- else if (currentNode instanceof concepts_1.CallLogic) {
2366
- icon = 'interface';
2367
- }
2368
- // 相同节点使用一个引用
2369
- if (nodeMap.get(currentNode)) {
2370
- queue.unshift(nodeMap.get(currentNode));
2371
- }
2372
- else {
2373
- var quoteNode = { node: currentNode, expanded: true, icon: icon };
2374
- nodeMap.set(currentNode, quoteNode);
2375
- queue.unshift(quoteNode);
2376
- }
2377
- }
2378
- }
2379
- // 一个logic 或者 view可能会有多个顺序队列
2380
- if (resMap.get(currentNode)) {
2381
- // 是否展示两个内容全等,但是两个queue的node可能不一样,但是只需要展示一个
2382
- resMap.get(currentNode).push(queue);
2383
- }
2384
- else {
2385
- resMap.set(currentNode, [queue]);
2386
- }
2387
- };
2388
- NaslServer.prototype.handleTreeMap = function (resMap) {
2389
- var _this = this;
2390
- var treeNodeMap = new Map();
2391
- resMap.forEach(function (value, fileNode) {
2392
- // 循环处理tree的queue
2393
- var treeObj = _this.handleTreeQueue(value);
2394
- treeNodeMap.set(fileNode, treeObj);
2395
- });
2396
- return treeNodeMap;
2397
- };
2398
- /**
2399
- * 处理tree的队列,把相同节点进行合并
2400
- * 这里把当前二维数组进行一个整合
2401
- * @param arr 当前页面下的queue的二维数组,一个数组下有多条链路
2402
- * @returns 最后要使用到的节点和对应的子集
2403
- */
2404
- NaslServer.prototype.handleTreeQueue = function (queueLists) {
2405
- var map = new Map();
2406
- var root = null;
2407
- if (!queueLists.length)
2408
- return;
2409
- for (var _i = 0, queueLists_1 = queueLists; _i < queueLists_1.length; _i++) {
2410
- var queueList = queueLists_1[_i];
2411
- var preNode = null;
2412
- var _loop_1 = function (queueItem) {
2413
- if (!map.get(queueItem)) {
2414
- map.set(queueItem, []);
2415
- }
2416
- if (preNode) {
2417
- var find = map.get(preNode).find(function (item) { return item === queueItem; });
2418
- if (!find) {
2419
- map.get(preNode).push(queueItem);
2420
- }
2421
- }
2422
- else {
2423
- root = queueItem;
2424
- }
2425
- preNode = queueItem;
2426
- };
2427
- for (var _a = 0, queueList_1 = queueList; _a < queueList_1.length; _a++) {
2428
- var queueItem = queueList_1[_a];
2429
- _loop_1(queueItem);
2430
- }
2431
- }
2432
- var children = this._recursionCreateResult(root, map);
2433
- return children;
2434
- };
2435
- /**
2436
- * 递归调用输出结果
2437
- * @param root 一个根节点
2438
- * @param map 当前所有节点的map对象
2439
- * @returns 当前节点,最后输出所有节点
2440
- */
2441
- NaslServer.prototype._recursionCreateResult = function (root, map) {
2442
- var _this = this;
2443
- var children = (map.get(root) || []).map(function (item) { return _this._recursionCreateResult(item, map); });
2444
- if (children && children.length) {
2445
- root.children = children;
2446
- }
2447
- return root;
2448
- };
2449
- /**
2450
- * 获取
2451
- * 当前this上下文 的Source 和 父级文件级别的节点
2452
- */
2453
- NaslServer.prototype.getCurrentSource = function (node) {
2454
- if (node instanceof concepts_1.App || node instanceof concepts_1.Theme)
2455
- return { fileNode: null };
2456
- var sourceMap = node.sourceMap;
2457
- var fileNode = node;
2458
- // 如果没有sourceMap,就继续向上找 ,或者到module结束
2459
- // 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
2460
- // 如果当前节点是view就不要向上查找了
2461
- while (!sourceMap
2462
- && fileNode
2463
- && !(fileNode.parentNode instanceof concepts_1.App)
2464
- && !(fileNode.parentNode instanceof concepts_1.Module)
2465
- && !(fileNode.parentNode instanceof concepts_1.DataSource)
2466
- && !(fileNode instanceof concepts_1.View)) {
2467
- fileNode = fileNode.parentNode;
2468
- sourceMap = fileNode === null || fileNode === void 0 ? void 0 : fileNode.sourceMap;
2469
- }
2470
- var currentSource = sourceMap && sourceMap.get(node);
2471
- if (currentSource) {
2472
- // 这里处理一些加了注解或者需要定制位置的节点的取值
2473
- this.handlingCurrentSourceException(currentSource, node);
2474
- return { currentSource: currentSource, fileNode: fileNode };
2475
- }
2476
- return { fileNode: fileNode };
2477
- };
2478
- NaslServer.prototype.handlingCurrentSourceException = function (currentSource, node) {
2479
- // 如果有前面的一些注解,元素在最后一行输出的值就给最后一行
2480
- if (node instanceof concepts_1.EntityProperty) {
2481
- if (currentSource.range.start.line !== currentSource.range.end.line) {
2482
- currentSource.range.start = __assign(__assign({}, currentSource.range.start), { line: currentSource.range.end.line });
2483
- }
2484
- }
2485
- };
2486
- // 获取element方法的可选值
2487
- NaslServer.prototype.getFieldKeySelectCompletion = function (node, fieldKey) {
2488
- var _a = this.getCurrentSource(node), currentSource = _a.currentSource, fileNode = _a.fileNode;
2489
- if (currentSource && fileNode) {
2490
- return this._getFieldKeySelectCompletion({
2491
- file: fileNode.getEmbeddedFilePath(),
2492
- range: {
2493
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
2494
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
2495
- },
2496
- getFieldKey: fieldKey
2497
- });
2498
- }
2499
- else {
2500
- console.log('没找到节点', currentSource, fileNode);
2501
- }
2502
- };
2503
- NaslServer.prototype._getFieldKeySelectCompletion = function (args) {
2504
- return this.messager.requestCommand('getFieldKeySelectCompletion', args);
2505
- };
2506
- /**
2507
- * 获取模块下多个CallInterface 被依赖的页面节点
2508
- * 查找callInterface 被依赖的页面级别的节点,要让他们重新生成一次代码,因为多个Interface重新导入,需要查找到引用的额内容
2509
- * 对应引用地方,需要重新生成,因为是生成方控制是不是必填的,
2510
- * @param oldInterfaceModule 发生修改的module,查他下面的Interface被引用的地方
2511
- * @returns 查找到的有引用这个内容的页面级别节点
2512
- */
2513
- NaslServer.prototype.findModulesCallInterfaceFileRef = function (oldInterfaceModule) {
2514
- return __awaiter(this, void 0, void 0, function () {
2515
- var oldInterfaces, fileNodes, i, item, refsList;
2516
- var _this = this;
2517
- return __generator(this, function (_a) {
2518
- switch (_a.label) {
2519
- case 0:
2520
- oldInterfaces = oldInterfaceModule.interfaces;
2521
- fileNodes = new Set();
2522
- i = 0;
2523
- _a.label = 1;
2524
- case 1:
2525
- if (!(i < oldInterfaces.length)) return [3 /*break*/, 4];
2526
- item = oldInterfaces[i];
2527
- return [4 /*yield*/, this._isHaveRef(item)];
2528
- case 2:
2529
- refsList = _a.sent();
2530
- refsList.forEach(function (record) {
2531
- if (record.isDefinition)
2532
- return;
2533
- var fileNode = _this.file2NodeMap.get(record.file);
2534
- if (fileNode) {
2535
- fileNodes.add(fileNode);
2536
- }
2537
- });
2538
- _a.label = 3;
2539
- case 3:
2540
- i++;
2541
- return [3 /*break*/, 1];
2542
- case 4: return [2 /*return*/, __spreadArrays(fileNodes)];
2543
- }
2544
- });
2545
- });
2546
- };
2547
- /**
2548
- * 查找calllogic 被依赖的页面级别的节点,要让他们重新生成一次代码,因为logic,参数必填非必填发生修改,
2549
- * 对应引用地方,需要重新生成,因为是生成方控制是不是必填的,
2550
- * @param logic 发生修改的logic
2551
- * @returns 查找到的有引用这个内容的页面级别节点
2552
- */
2553
- NaslServer.prototype.findCallLogicFileRef = function (logic) {
2554
- return __awaiter(this, void 0, void 0, function () {
2555
- var fileNodes, refsList;
2556
- var _this = this;
2557
- return __generator(this, function (_a) {
2558
- switch (_a.label) {
2559
- case 0:
2560
- fileNodes = new Set();
2561
- return [4 /*yield*/, this._isHaveRef(logic)];
2562
- case 1:
2563
- refsList = _a.sent();
2564
- refsList.forEach(function (record) {
2565
- if (record.isDefinition)
2566
- return;
2567
- var fileNode = _this.file2NodeMap.get(record.file);
2568
- if (fileNode) {
2569
- fileNodes.add(fileNode);
2570
- }
2571
- });
2572
- return [2 /*return*/, __spreadArrays(fileNodes)];
2573
- }
2574
- });
2575
- });
2576
- };
2577
- /**获取当前节点的已知类型
2578
- * @param node 当前要获取类型的节点
2579
- * @returns 不需要去查就可以返回类型的节点
2580
- */
2581
- NaslServer.prototype.getCurrentNodeKnownTypeAnnotation = function (node) {
2582
- var _a;
2583
- if (node.concept === 'StringLiteral' || node.concept === 'StringInterpolation' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
2584
- var type = 'String';
2585
- switch (node.concept) {
2586
- case 'NullLiteral':
2587
- type = 'Null';
2588
- break;
2589
- case 'BooleanLiteral':
2590
- type = 'Boolean';
2591
- break;
2592
- }
2593
- return concepts_1.TypeAnnotation.createPrimitive(type);
2594
- }
2595
- // 这些原有类型的 比较的 返回值肯定就是布尔值,就不去调用ls
2596
- if (node instanceof concepts_1.BinaryExpression && (['==', '!=', '>', '<', '>=', '<='].includes(node.operator))) {
2597
- return concepts_1.TypeAnnotation.createPrimitive('Boolean');
2598
- }
2599
- // Convert和new都是自身携带类型的,就不进行修改
2600
- if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && (['Convert', 'New', 'FromString'].includes(node.calleeName))) {
2601
- if (node.typeArguments.length) {
2602
- return node.typeArguments[0];
2603
- }
2604
- }
2605
- // Convert和new都是自身携带类型的,就不进行修改
2606
- if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && (node.calleeName === 'jsonDeserialize')) {
2607
- if (node.typeArguments.length) {
2608
- return node.typeArguments[0];
2609
- }
2610
- }
2611
- // 特殊处理param有类型错误的
2612
- if (node instanceof concepts_1.Param) {
2613
- // index在nasl foreach上有脏数据
2614
- if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
2615
- return concepts_1.TypeAnnotation.createPrimitive('Integer');
2616
- }
2617
- }
2618
- if (node instanceof concepts_1.CallQueryComponent || node instanceof concepts_1.SqlQueryComponent || node instanceof concepts_1.OqlQueryComponent) {
2619
- return node.typeAnnotation;
2620
- }
2621
- // 老数据可能typeKind 的primitive缺失
2622
- if (node instanceof concepts_1.NumericLiteral && node.typeAnnotation) {
2623
- return concepts_1.TypeAnnotation.from(__assign(__assign({}, (_a = node.typeAnnotation) === null || _a === void 0 ? void 0 : _a.toJSON()), { typeKind: 'primitive' }));
2624
- }
2625
- };
2626
- /**
2627
- * 获取传入节点的TypeAnnotation
2628
- * @param nodes {filePath: string, node: BaseNode, item: SourceMapItem}
2629
- * @returns Map<BaseNode, TypeAnnotation | { typeAnnotation: TypeAnnotation, option: any }>
2630
- * 普通的TypeAnnotation,额外的可能携带 option
2631
- * 这里会处理callloigc callinterface 和 callfuntion 的 argment的参数一起携带回去,
2632
- * 也就是说如果 只传入了这个也会一起返回argment的节点,所以返回map最好去get结果
2633
- */
2634
- NaslServer.prototype.getQuickInfoNodesTypeMap = function (nodes, lotFlag) {
2635
- return __awaiter(this, void 0, void 0, function () {
2636
- var args, getFromOthers, types, newQuickInfoNodes, resultMap;
2637
- var _this = this;
2638
- return __generator(this, function (_a) {
2639
- switch (_a.label) {
2640
- case 0:
2641
- args = [];
2642
- getFromOthers = new Map();
2643
- types = new Map();
2644
- newQuickInfoNodes = [];
2645
- nodes.forEach(function (itemDetail) {
2646
- var _a, _b, _c;
2647
- var node = itemDetail.node, filePath = itemDetail.filePath, item = itemDetail.item;
2648
- // 先按照顺序占位
2649
- types.set(node, null);
2650
- // 获取已知节点类型的类型
2651
- var nodeTypeAnnotation = _this.getCurrentNodeKnownTypeAnnotation(node);
2652
- if (nodeTypeAnnotation) {
2653
- types.set(node, nodeTypeAnnotation);
2654
- return;
2655
- }
2656
- // 要通过自己或者依赖关系拿的,二次遍历
2657
- if ([
2658
- 'Argument',
2659
- 'Assignment',
2660
- 'MatchCase',
2661
- ].includes(node.concept)) {
2662
- getFromOthers.set(node, null);
2663
- }
2664
- if ([
2665
- 'Return',
2666
- 'Variable',
2667
- ].includes(node.concept) && node.typeAnnotation) {
2668
- types.set(node, node.typeAnnotation);
2669
- return;
2670
- }
2671
- if (![
2672
- 'Identifier',
2673
- 'UnaryExpression',
2674
- 'BinaryExpression',
2675
- 'CallLogic',
2676
- 'CallFunction',
2677
- 'CallInterface',
2678
- 'MemberExpression',
2679
- 'Return',
2680
- 'Variable',
2681
- 'Match',
2682
- 'NewComposite',
2683
- 'NewList',
2684
- 'NewMap',
2685
- ].includes(node.concept))
2686
- return;
2687
- // 要去ls那边获取的
2688
- newQuickInfoNodes.push(itemDetail);
2689
- var fileDetail = {
2690
- file: filePath,
2691
- line: translator_1.lsp2tspNumber(item.range.start.line),
2692
- offset: translator_1.lsp2tspNumber(item.range.start.character)
2693
- };
2694
- if (node.concept === 'BinaryExpression'
2695
- || node.concept === 'CallLogic'
2696
- || node.concept === 'CallFunction'
2697
- || node.concept === 'CallInterface') {
2698
- // 如果没有括号 ,括号就在外面,就 -1
2699
- // 有括号就找到括号的位置 然后 -1
2700
- var indexOf = 0;
2701
- if (!item.code.includes('(')) {
2702
- indexOf = -1;
2703
- }
2704
- else {
2705
- // 如果有泛型先往前找一找
2706
- if (item.code.includes('<')) {
2707
- indexOf = Math.min(item.code.indexOf('<'), item.code.indexOf('('));
2708
- }
2709
- else {
2710
- indexOf = item.code.indexOf('(');
2711
- }
2712
- var subStr = item.code.substring(0, indexOf);
2713
- var codeArr = subStr === null || subStr === void 0 ? void 0 : subStr.split('.');
2714
- var lastLen = (_a = codeArr === null || codeArr === void 0 ? void 0 : codeArr[codeArr.length - 1]) === null || _a === void 0 ? void 0 : _a.length;
2715
- indexOf = subStr.length - lastLen;
2716
- }
2717
- fileDetail.offset = fileDetail.offset + indexOf;
2718
- }
2719
- else if (node.concept === 'MemberExpression' || node.concept === 'Identifier') {
2720
- if (item.code.includes('.')) {
2721
- var codeArr = (_b = item.code) === null || _b === void 0 ? void 0 : _b.split('.');
2722
- var lastLen = (_c = codeArr === null || codeArr === void 0 ? void 0 : codeArr[codeArr.length - 1]) === null || _c === void 0 ? void 0 : _c.length;
2723
- // MemberExpression取最后一位当做类型
2724
- var indexOf = item.code.length - lastLen;
2725
- fileDetail.offset = fileDetail.offset + indexOf;
2726
- }
2727
- }
2728
- else if (node.concept === 'Match') {
2729
- // 去查return 后面的返回值,变成函数调用
2730
- fileDetail.line = item.range.end.line - 1;
2731
- var indexOf = item.code.indexOf('return __MatchExpressionFuntion');
2732
- var newCode = item.code.substring(0, indexOf);
2733
- newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
2734
- fileDetail.offset = newCode.length + 'return '.length;
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
- }
2743
- args.push(fileDetail);
2744
- });
2745
- console.time('请求');
2746
- return [4 /*yield*/, this.getNaslNodeTypeFull(args)];
2747
- case 1:
2748
- resultMap = (_a.sent()).response;
2749
- console.timeEnd('请求');
2750
- // console.log(resultMap);
2751
- // const result = (await this.getNaslNodeQuickInfoFull(args)).response;
2752
- // console.log(result);
2753
- args.forEach(function (arg, index) {
2754
- var _a, _b, _c, _d, _e;
2755
- var file = arg.file, line = arg.line, offset = arg.offset;
2756
- var item = (_c = (_b = (_a = resultMap) === null || _a === void 0 ? void 0 : _a[file]) === null || _b === void 0 ? void 0 : _b[line]) === null || _c === void 0 ? void 0 : _c[offset];
2757
- //const displayString1 = resule1[index]?.displayString;
2758
- // console.log('位置:', file, line, offset);
2759
- // console.log('原始:', displayString);
2760
- // console.log('方案2:', item?.[0]?.nodeType);
2761
- var nodeTypeAnnotation = formatTsUtils_1.type2TypeAnnotation((_d = item === null || item === void 0 ? void 0 : item[0]) === null || _d === void 0 ? void 0 : _d.nodeType);
2762
- // console.log(newQuickInfoNodes[index].node, nodeTypeAnnotation, nodeTypeAnnotation?.typeKey);
2763
- types.set(newQuickInfoNodes[index].node, nodeTypeAnnotation);
2764
- newQuickInfoNodes[index].node.__nodeType = Object.freeze((_e = item === null || item === void 0 ? void 0 : item[0]) === null || _e === void 0 ? void 0 : _e.nodeType);
2765
- // console.log('方案1:', displayString1);
2766
- });
2767
- getFromOthers.forEach(function (type, node) {
2768
- var _a;
2769
- if (node instanceof concepts_1.Assignment) {
2770
- if (!types.get(node.left)) {
2771
- types.set(node.left, types.get(node.right));
2772
- }
2773
- }
2774
- else if (node instanceof concepts_1.Argument) {
2775
- // 如果Argument,但是没可以用的类型,就用原来logic的参数类型
2776
- var argType = _this.getArgumentTypeAnnotation(node, newQuickInfoNodes, types);
2777
- types.set(node, argType);
2778
- }
2779
- else if (node instanceof concepts_1.MatchCase) {
2780
- // matchCase的类型
2781
- // 直接从最后一项的返回值取,有就有没有就没有
2782
- if ((_a = node.body) === null || _a === void 0 ? void 0 : _a.length) {
2783
- var last = node.body[node.body.length - 1];
2784
- if (last.__TypeAnnotation) {
2785
- types.set(node, last.__TypeAnnotation);
2786
- }
2787
- }
2788
- }
2789
- });
2790
- // 重置类型状态, 并且赋值
2791
- types.forEach(function (value, node) {
2792
- try {
2793
- // 因为node可能是经过处理的TypeAnnotation
2794
- node.__isCorrectTypeAnnotation = true;
2795
- if (value) {
2796
- if (value instanceof concepts_1.TypeAnnotation) {
2797
- node.__TypeAnnotation = Object.freeze(value);
2798
- }
2799
- else if (value.typeAnnotation) {
2800
- node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
2801
- }
2802
- }
2803
- else {
2804
- // 清空原来已经赋值上去的类型,可能原来有现在没有了
2805
- node.__TypeAnnotation = null;
2806
- }
2807
- }
2808
- catch (err) {
2809
- if (globalThis.window) {
2810
- console.log(err);
2811
- }
2812
- }
2813
- });
2814
- // newQuickInfoNodes.forEach((itemDetail, index) => {
2815
- // const { node, filePath } = itemDetail;
2816
- // if (!result[index] || node.concept === 'Argument')
2817
- // return;
2818
- // // console.log(result[index].displayString, node);
2819
- // /**
2820
- // * 这个前缀是给会自动省略命名空间的内容设置的,下个版本干掉,应急的方法
2821
- // */
2822
- // let parentPrefix;
2823
- // if (filePath && (filePath.split('/').length > 3)) {
2824
- // const arr = filePath.split('/');
2825
- // if (arr[3] === 'dependencies' || arr[3] === 'interfaceDependencies' || arr[3] === 'componentDependencies') {
2826
- // const map = {
2827
- // dependencies: 'extensions',
2828
- // interfaceDependencies: 'apis',
2829
- // componentDependencies: 'components',
2830
- // };
2831
- // parentPrefix = `${map[arr[3]]}.${arr[4]}.`;
2832
- // }
2833
- // }
2834
- // const nodeTypeAnnotation = displayString2TypeAnnotation(result[index].displayString, parentPrefix);
2835
- // // console.log(result[index].displayString, items[index], '************', typeAnnotation);
2836
- // // console.log(node, index, items[index].code, result[index].displayString, '+++++++++++++++++++++++++++', typeAnnotation && typeAnnotation.typeKey)
2837
- // try {
2838
- // types.set(node, nodeTypeAnnotation);
2839
- // /**
2840
- // * 没有类型标注的情况
2841
- // * 1.void 没有返回值
2842
- // * 2.Argment
2843
- // */
2844
- // // if (!typeAnnotation) {
2845
- // // console.log(items[index].code, jsonNode, result[index]);
2846
- // // console.log(result[index].displayString)
2847
- // // }
2848
- // } catch (e) {
2849
- // console.log(node, node.getNodePath(false));
2850
- // }
2851
- // });
2852
- // // Argument的标注,因为这个位置上可能放任何东西所以直接在其内部去取
2853
- // newQuickInfoNodes.forEach((itemDetail, index) => {
2854
- // const { node } = itemDetail;
2855
- // if (node instanceof Argument) {
2856
- // // 如果Argument,但是没可以用的类型,就用原来logic的参数类型
2857
- // const argType = this.getArgumentTypeAnnotation(node, newQuickInfoNodes, result, (types as any));
2858
- // types.set(node, argType);
2859
- // }
2860
- // });
2861
- return [2 /*return*/, types];
2862
- }
2863
- });
2864
- });
2865
- };
2866
- // 全量标注并且返回json
2867
- NaslServer.prototype.getNaslAnnotatedJSON = function (app, releaseFlag) {
2868
- return __awaiter(this, void 0, void 0, function () {
2869
- var nodes, typesMap, json;
2870
- return __generator(this, function (_a) {
2871
- switch (_a.label) {
2872
- case 0:
2873
- console.time('全量标注');
2874
- nodes = [];
2875
- this.file2NodeMap.forEach(function (fileNode, filePath) {
2876
- // 先不排除view,传递给后端的时候,去除views下的标注
2877
- if (!['Structure', 'DataSource', 'Entity', 'Enum', 'Role'].includes(fileNode.concept)) {
2878
- fileNode.sourceMap.forEach(function (item, node) {
2879
- nodes.push({
2880
- filePath: filePath,
2881
- node: node,
2882
- item: item
2883
- });
2884
- });
2885
- }
2886
- });
2887
- return [4 /*yield*/, this.getQuickInfoNodesTypeMap(nodes, true)];
2888
- case 1:
2889
- typesMap = _a.sent();
2890
- // console.log(typesMap, 'typesMap')
2891
- console.timeEnd('全量标注');
2892
- json = app.toJSON();
2893
- if (releaseFlag) {
2894
- // 全量标注后对json进行一些修改,为了服务端翻译处理
2895
- this.annotationToJson(typesMap, json);
2896
- }
2897
- return [2 /*return*/, json];
2898
- }
2899
- });
2900
- });
2901
- };
2902
- // 加载全量nasl节点标注
2903
- NaslServer.prototype.createdNaslAnnotatedJSON = function (app) {
2904
- return __awaiter(this, void 0, void 0, function () {
2905
- var nodes;
2906
- return __generator(this, function (_a) {
2907
- switch (_a.label) {
2908
- case 0:
2909
- nodes = [];
2910
- this.file2NodeMap.forEach(function (fileNode, filePath) {
2911
- // 先不排除view,传递给后端的时候,去除views下的标注
2912
- if (!['Structure', 'DataSource', 'Entity', 'Enum', 'Role'].includes(fileNode.concept)) {
2913
- fileNode.sourceMap.forEach(function (item, node) {
2914
- nodes.push({
2915
- filePath: filePath,
2916
- node: node,
2917
- item: item
2918
- });
2919
- });
2920
- }
2921
- });
2922
- return [4 /*yield*/, this.getQuickInfoNodesTypeMap(nodes, true)];
2923
- case 1:
2924
- _a.sent();
2925
- return [2 /*return*/];
2926
- }
2927
- });
2928
- });
2929
- };
2930
- // 增量标注
2931
- NaslServer.prototype.IncrementalAnnotationJSON = function (records) {
2932
- return __awaiter(this, void 0, void 0, function () {
2933
- var nodes;
2934
- var _this = this;
2935
- return __generator(this, function (_a) {
2936
- switch (_a.label) {
2937
- case 0:
2938
- console.time('增量标注');
2939
- nodes = [];
2940
- records.forEach(function (record) {
2941
- var fileNode = _this.file2NodeMap.get(record.filePath);
2942
- if (!fileNode)
2943
- return;
2944
- record.id = fileNode.id;
2945
- record.node = fileNode;
2946
- if (!['Structure', 'DataSource', 'Entity', 'Enum', 'Role'].includes(fileNode.concept)) {
2947
- fileNode.sourceMap.forEach(function (item, nodeItem) {
2948
- nodes.push({
2949
- filePath: record.filePath,
2950
- node: nodeItem,
2951
- item: item
2952
- });
2953
- });
2954
- }
2955
- });
2956
- return [4 /*yield*/, this.getQuickInfoNodesTypeMap(nodes)];
2957
- case 1:
2958
- _a.sent();
2959
- console.timeEnd('增量标注');
2960
- return [2 /*return*/];
2961
- }
2962
- });
2963
- });
2964
- };
2965
- NaslServer.prototype.annotationToJson = function (typesMap, json) {
2966
- typesMap.forEach(function (value, node) {
2967
- var _a, _b, _c, _d;
2968
- // 如果节点本身有类型就不去在塞一遍了
2969
- // 有值而且没有类型再去设置
2970
- // 但是Identifier 和 MemberExpression 都用标注出来的因为本身是变量,有类型也需要覆盖一下
2971
- if (value && (!node.typeAnnotation || node instanceof concepts_1.Identifier || node instanceof concepts_1.MemberExpression)) {
2972
- var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
2973
- if (jsonNode) {
2974
- if (node instanceof concepts_1.Argument) {
2975
- jsonNode.defaultValue = value.option.defaultValue;
2976
- jsonNode.typeAnnotation = (_b = (_a = value) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.toJSON();
2977
- }
2978
- else {
2979
- jsonNode.typeAnnotation = (_c = value) === null || _c === void 0 ? void 0 : _c.toJSON();
2980
- }
2981
- }
2982
- }
2983
- // 旧版本数据查询需要确认是匿名数据结构的 ListTotal 类型
2984
- if (node instanceof concepts_1.CallQueryComponent && node.ideVersion !== '2.11') {
2985
- var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
2986
- jsonNode.typeAnnotation = {
2987
- concept: 'TypeAnnotation',
2988
- typeKind: 'anonymousStructure',
2989
- typeNamespace: null,
2990
- typeName: null,
2991
- typeArguments: [],
2992
- inferred: false,
2993
- ruleMap: null,
2994
- properties: [{
2995
- concept: 'StructureProperty',
2996
- name: 'list',
2997
- label: null,
2998
- description: null,
2999
- typeAnnotation: {
3000
- concept: 'TypeAnnotation',
3001
- typeKind: 'generic',
3002
- typeNamespace: 'nasl.collection',
3003
- typeName: 'List',
3004
- typeArguments: [jsonNode.typeAnnotation],
3005
- inferred: null
3006
- },
3007
- required: null,
3008
- defaultValue: null
3009
- }, {
3010
- concept: 'StructureProperty',
3011
- name: 'total',
3012
- label: null,
3013
- description: null,
3014
- typeAnnotation: {
3015
- concept: 'TypeAnnotation',
3016
- typeKind: 'primitive',
3017
- typeNamespace: 'nasl.core',
3018
- typeName: 'Integer',
3019
- typeArguments: null,
3020
- inferred: null
3021
- },
3022
- required: null,
3023
- defaultValue: null
3024
- }]
3025
- };
3026
- }
3027
- // 特殊处理param有类型错误的
3028
- if (node instanceof concepts_1.Param) {
3029
- // index在nasl foreach上有脏数据
3030
- if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
3031
- var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
3032
- jsonNode.typeAnnotation = concepts_1.TypeAnnotation.createPrimitive('Integer').toJSON();
3033
- }
3034
- }
3035
- if (node instanceof concepts_1.Match) {
3036
- var matchExpression_1 = node.expression;
3037
- if (((_d = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.__TypeAnnotation) === null || _d === void 0 ? void 0 : _d.typeKind) === 'union' && (matchExpression_1 instanceof concepts_1.Identifier || matchExpression_1 instanceof concepts_1.MemberExpression)) {
3038
- var _e = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.getCurrentSource(), currentSource_4 = _e.currentSource, fileNode = _e.fileNode;
3039
- fileNode.sourceMap.forEach(function (item, itemNode) {
3040
- if (itemNode.concept === matchExpression_1.concept && item.code === currentSource_4.code) {
3041
- var jsonNode = jsoner.queryNodeByPath(json, itemNode.getNodePath(false));
3042
- jsonNode.typeAnnotation = matchExpression_1.__TypeAnnotation;
3043
- }
3044
- });
3045
- }
3046
- }
3047
- // 特殊处理param有类型错误的
3048
- if (node instanceof concepts_1.Param && value) {
3049
- // index在nasl foreach上有脏数据
3050
- if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
3051
- var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
3052
- jsonNode.typeAnnotation = value.toJSON();
3053
- }
3054
- }
3055
- });
3056
- };
3057
- /**
3058
- * 获取getArgument的参数位的类型
3059
- * 如果内部表达式的,就用表达式的,如果没有就试试用默认值的
3060
- * 获取logic的默认值和原来Arg的类型和默认值对应
3061
- */
3062
- NaslServer.prototype.getArgumentTypeAnnotation = function (node, QuickInfoNodes, types) {
3063
- var _a, _b, _c;
3064
- // 直接复用内部expression的type类型
3065
- if (node.parentNode instanceof concepts_1.CallLogic && node.parentNode.calleeNamespace.includes('entities') && node.parentNode.calleeNamespace.includes('logics') && node.parentNode.calleeName === 'delete') {
3066
- var nodeType = (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.__nodeType;
3067
- if (nodeType && Array.isArray(nodeType.fnParams)) {
3068
- var index_1 = node.parentNode.arguments.indexOf(node);
3069
- var type = (_b = nodeType.fnParams[index_1]) === null || _b === void 0 ? void 0 : _b.typeInfo;
3070
- var nodeTypeAnnotation = formatTsUtils_1.type2TypeAnnotation(type);
3071
- if (nodeTypeAnnotation) {
3072
- return {
3073
- typeAnnotation: nodeTypeAnnotation,
3074
- option: {}
3075
- };
3076
- }
3077
- }
3078
- }
3079
- // 获取返回值结果里找到父级的callLogic || CallInterface的类型填充进去Argument
3080
- var App = node.app;
3081
- var parent = (node.parentNode);
3082
- // 如果nasl包下的 ,很多声明都含有T啥的先用自己内部的
3083
- if (!parent.calleeNamespace || parent.calleeNamespace.startsWith('nasl')) {
3084
- if (types.get(node.expression)) {
3085
- return {
3086
- typeAnnotation: types.get(node.expression),
3087
- option: {}
3088
- };
3089
- }
3090
- }
3091
- // 用户自己声明的用用户的
3092
- var callObj = App.findNodeByCompleteName(parent.calleeNamespace + '.' + parent.calleeName);
3093
- var index = parent.arguments.indexOf(node);
3094
- var param = ((_c = callObj === null || callObj === void 0 ? void 0 : callObj.params) === null || _c === void 0 ? void 0 : _c[index]) || {};
3095
- // 取出参数的类型
3096
- // 设置类型
3097
- return {
3098
- typeAnnotation: param.typeAnnotation,
3099
- // 设置默认值
3100
- option: { defaultValue: param.defaultValue }
3101
- };
3102
- };
3103
- NaslServer.prototype.getCurrentTypeAnnotation = function (node, outTime) {
3104
- if (outTime === void 0) { outTime = 600; }
3105
- return __awaiter(this, void 0, void 0, function () {
3106
- return __generator(this, function (_a) {
3107
- if (node.__TypeAnnotation) {
3108
- return [2 /*return*/, node.__TypeAnnotation];
3109
- }
3110
- return [2 /*return*/, new Promise(function (resolve, reject) {
3111
- var myTimer = setTimeout(function () {
3112
- console.warn(node, '没有获取到类型');
3113
- clearTimeout(myTimer);
3114
- clearInterval(mySetInterval);
3115
- if (node.__isCorrectTypeAnnotation) {
3116
- resolve(node.__TypeAnnotation);
3117
- }
3118
- else {
3119
- resolve(null);
3120
- }
3121
- }, outTime);
3122
- var mySetInterval = setInterval(function () {
3123
- if (node.__isCorrectTypeAnnotation) {
3124
- resolve(node.__TypeAnnotation);
3125
- clearInterval(mySetInterval);
3126
- clearTimeout(myTimer);
3127
- }
3128
- }, 50);
3129
- })];
3130
- });
3131
- });
3132
- };
3133
- // 获取节点标注,去动态查
3134
- NaslServer.prototype.getBaseNodesTypeMap = function (nodes) {
3135
- return __awaiter(this, void 0, void 0, function () {
3136
- var args, typesMap;
3137
- return __generator(this, function (_a) {
3138
- switch (_a.label) {
3139
- case 0:
3140
- args = nodes.map(function (item) {
3141
- var _a = item.getCurrentSource(), currentSource = _a.currentSource, fileNode = _a.fileNode;
3142
- return {
3143
- filePath: fileNode.getEmbeddedFilePath(),
3144
- node: item,
3145
- item: currentSource
3146
- };
3147
- });
3148
- return [4 /*yield*/, this.getQuickInfoNodesTypeMap(args)];
3149
- case 1:
3150
- typesMap = _a.sent();
3151
- return [2 /*return*/, typesMap];
3152
- }
3153
- });
3154
- });
3155
- };
3156
- NaslServer.prototype._getTypeStrFull = function (args) {
3157
- return this.messager.requestCommand('typeStrFull', args);
3158
- };
3159
- NaslServer.prototype.getNaslNodeTypeStrFull = function (args) {
3160
- return __awaiter(this, void 0, void 0, function () {
3161
- var result;
3162
- return __generator(this, function (_a) {
3163
- switch (_a.label) {
3164
- case 0: return [4 /*yield*/, this._getTypeStrFull(args)];
3165
- case 1:
3166
- result = _a.sent();
3167
- return [2 /*return*/, result];
3168
- }
3169
- });
3170
- });
3171
- };
3172
- /**
3173
- * 处理删除节点
3174
- * @param fileNode 当前删除节点的文件级别节点
3175
- * @param targetNode 当前操作的节点
3176
- * @param result toTs生成的内容
3177
- */
3178
- NaslServer.prototype.handleDelete = function (fileNode, targetNode, result) {
3179
- var _a, _b;
3180
- return __awaiter(this, void 0, void 0, function () {
3181
- var filePath, outputFiles, newRefs;
3182
- return __generator(this, function (_c) {
3183
- switch (_c.label) {
3184
- case 0:
3185
- filePath = fileNode.getEmbeddedFilePath();
3186
- outputFiles = [];
3187
- return [4 /*yield*/, this.references({
3188
- file: result.filePath,
3189
- line: (_a = EmbeddedTSFileLineMap[fileNode.concept]) !== null && _a !== void 0 ? _a : 2,
3190
- offset: (_b = EmbeddedTSFileOffsetMap[fileNode.concept]) !== null && _b !== void 0 ? _b : 6
3191
- })];
3192
- case 1:
3193
- newRefs = _c.sent();
3194
- // 如果是要删除的内容,就是当前的file节点,要关闭当前文件,就把内容置为空
3195
- if (fileNode === targetNode) {
3196
- outputFiles = [{ file: filePath, fileContent: '' }];
3197
- }
3198
- else {
3199
- // 如果是要删除logic一个小内容,要覆盖全部内容
3200
- // 其余要删除的都是把原来的file节点的内容全部覆盖一把
3201
- outputFiles = [{ file: result.filePath, fileContent: result.code }];
3202
- }
3203
- // 更新文件之后
3204
- return [4 /*yield*/, this.updateFiles({ outputFiles: outputFiles })];
3205
- case 2:
3206
- // 更新文件之后
3207
- _c.sent();
3208
- newRefs.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3209
- return [2 /*return*/];
3210
- }
3211
- });
3212
- });
3213
- };
3214
- /**
3215
- * 除去rename场景下的更新
3216
- * @param fileNode 文件级别的节点
3217
- * @param targetNode 触发修改的节点
3218
- * @param result 生成代码的code 和位置信息
3219
- */
3220
- NaslServer.prototype.handleChange = function (fileNode, targetNode, result, action) {
3221
- var _a, _b;
3222
- return __awaiter(this, void 0, void 0, function () {
3223
- var outputFiles, newRefs, confirmParms;
3224
- return __generator(this, function (_c) {
3225
- switch (_c.label) {
3226
- case 0:
3227
- this.file2NodeMap.set(result.filePath, fileNode);
3228
- outputFiles = [{ file: result.filePath, fileContent: result.code }];
3229
- // 创建和更新都用update,内部会做判断
3230
- return [4 /*yield*/, this.updateFiles({ outputFiles: outputFiles })];
3231
- case 1:
3232
- // 创建和更新都用update,内部会做判断
3233
- _c.sent();
3234
- return [4 /*yield*/, this.references({
3235
- file: result.filePath,
3236
- line: (_a = EmbeddedTSFileLineMap[fileNode.concept]) !== null && _a !== void 0 ? _a : 2,
3237
- offset: (_b = EmbeddedTSFileOffsetMap[fileNode.concept]) !== null && _b !== void 0 ? _b : 6
3238
- })];
3239
- case 2:
3240
- newRefs = _c.sent();
3241
- newRefs.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3242
- // 唤起建立连接弹框
3243
- // 文件级别的建立连接采取提醒
3244
- if (action === 'create' && targetNode.__init) {
3245
- // 清除临时状态, 完成本次创建
3246
- delete targetNode.__init;
3247
- if (fileNode === targetNode && filesToCheck.size > 1) {
3248
- confirmParms = {
3249
- actionType: 'createEstablishConnection',
3250
- node: fileNode,
3251
- icon: 'success'
3252
- };
3253
- common_1.invokeCommand('tsConfirm.open', confirmParms, function () { });
3254
- }
3255
- }
3256
- return [2 /*return*/];
3257
- }
3258
- });
3259
- });
3260
- };
3261
- /**
3262
- * 重命名的更新
3263
- * @param fileNode 文件级别的节点
3264
- * @param targetNode 触发修改的节点
3265
- * @param result 生成代码的code 和位置信息
3266
- * @param isRename 是不是修改名字
3267
- * @param oldFilePath 如果是改名,文件级别的才会有这个参数,用于文件新增替换
3268
- */
3269
- NaslServer.prototype.handleRename = function (fileNode, targetNode, result, oldFilePath) {
3270
- var _a, _b, _c, _d, _e, _f;
3271
- return __awaiter(this, void 0, void 0, function () {
3272
- var outputFiles, oldRefs, newRefs, newRefFileList_1, newRefs2, _g, currentSource, fileNode_3, oldRefs, newRefs2;
3273
- return __generator(this, function (_h) {
3274
- switch (_h.label) {
3275
- case 0:
3276
- outputFiles = [{ file: result.filePath, fileContent: result.code }];
3277
- if (!(fileNode === targetNode)) return [3 /*break*/, 4];
3278
- this.file2NodeMap["delete"](oldFilePath);
3279
- this.file2NodeMap.set(result.filePath, fileNode);
3280
- // 修改名字新的添加进去,旧的置为空
3281
- outputFiles.unshift({ file: oldFilePath, fileContent: '' });
3282
- return [4 /*yield*/, this.references({
3283
- file: oldFilePath,
3284
- line: (_a = EmbeddedTSFileLineMap[fileNode.concept]) !== null && _a !== void 0 ? _a : 2,
3285
- offset: (_b = EmbeddedTSFileOffsetMap[fileNode.concept]) !== null && _b !== void 0 ? _b : 6
3286
- })];
3287
- case 1:
3288
- oldRefs = _h.sent();
3289
- oldRefs.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3290
- filesToCheck["delete"](oldFilePath);
3291
- // 更新文件之后
3292
- return [4 /*yield*/, this.updateFiles({ outputFiles: outputFiles })];
3293
- case 2:
3294
- // 更新文件之后
3295
- _h.sent();
3296
- return [4 /*yield*/, this.references({
3297
- file: result.filePath,
3298
- line: (_c = EmbeddedTSFileLineMap[fileNode.concept]) !== null && _c !== void 0 ? _c : 2,
3299
- offset: (_d = EmbeddedTSFileOffsetMap[fileNode.concept]) !== null && _d !== void 0 ? _d : 6
3300
- })];
3301
- case 3:
3302
- newRefs = _h.sent();
3303
- newRefFileList_1 = new Set();
3304
- newRefs.refs.forEach(function (ref) {
3305
- filesToCheck.add(ref.file);
3306
- newRefFileList_1.add(ref.file);
3307
- });
3308
- return [3 /*break*/, 11];
3309
- case 4:
3310
- if (!(targetNode instanceof concepts_1.ViewElement)) return [3 /*break*/, 7];
3311
- /**
3312
- * 因为页面组件比较特殊
3313
- * 修改之后只用查页面本身就好了
3314
- */
3315
- // 更新文件之后
3316
- return [4 /*yield*/, this.updateFiles({ outputFiles: outputFiles })];
3317
- case 5:
3318
- /**
3319
- * 因为页面组件比较特殊
3320
- * 修改之后只用查页面本身就好了
3321
- */
3322
- // 更新文件之后
3323
- _h.sent();
3324
- return [4 /*yield*/, this.references({
3325
- file: fileNode.getEmbeddedFilePath(),
3326
- line: (_e = EmbeddedTSFileLineMap[fileNode.concept]) !== null && _e !== void 0 ? _e : 2,
3327
- offset: (_f = EmbeddedTSFileOffsetMap[fileNode.concept]) !== null && _f !== void 0 ? _f : 6
3328
- })];
3329
- case 6:
3330
- newRefs2 = _h.sent();
3331
- newRefs2.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3332
- return [3 /*break*/, 11];
3333
- case 7:
3334
- _g = this.getCurrentSource(targetNode), currentSource = _g.currentSource, fileNode_3 = _g.fileNode;
3335
- if (!currentSource) return [3 /*break*/, 11];
3336
- return [4 /*yield*/, this.references({
3337
- file: fileNode_3.getEmbeddedFilePath(),
3338
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
3339
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
3340
- })];
3341
- case 8:
3342
- oldRefs = _h.sent();
3343
- oldRefs.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3344
- // 更新文件之后
3345
- return [4 /*yield*/, this.updateFiles({ outputFiles: outputFiles })];
3346
- case 9:
3347
- // 更新文件之后
3348
- _h.sent();
3349
- return [4 /*yield*/, this.references({
3350
- file: fileNode_3.getEmbeddedFilePath(),
3351
- line: translator_1.lsp2tspNumber(currentSource.range.start.line),
3352
- offset: translator_1.lsp2tspNumber(currentSource.range.start.character)
3353
- })];
3354
- case 10:
3355
- newRefs2 = _h.sent();
3356
- newRefs2.refs.forEach(function (ref) { return filesToCheck.add(ref.file); });
3357
- _h.label = 11;
3358
- case 11: return [2 /*return*/];
3359
- }
3360
- });
3361
- });
3362
- };
3363
- /**
3364
- * 处理一些节点操作,子节点需要更新并且check的场景
3365
- * 因为删除,新增父页面,或者重命名会一起
3366
- * 删除或者新增view而且他有子集 就要执行同样的操作
3367
- * @param action 当前操作类型
3368
- * @param fileNode 文件节点
3369
- * @param targetNode 操作节点 这里要两个相等才会走家去面对哦逻辑
3370
- * @param oldpath 触发内容的oldpath
3371
- */
3372
- NaslServer.prototype.incidentalAction = function (action, fileNode, targetNode, oldpath) {
3373
- var _a;
3374
- return __awaiter(this, void 0, void 0, function () {
3375
- var fileNodeChildren, i, fileNodeItem, result, parentPath, currentOldPath, module_1, results, i, result, node;
3376
- var _this = this;
3377
- return __generator(this, function (_b) {
3378
- switch (_b.label) {
3379
- case 0:
3380
- if (!((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode)) return [3 /*break*/, 19];
3381
- if (!(fileNode instanceof concepts_1.View && ((_a = fileNode.children) === null || _a === void 0 ? void 0 : _a.length))) return [3 /*break*/, 11];
3382
- fileNodeChildren = fileNode.children;
3383
- i = 0;
3384
- _b.label = 1;
3385
- case 1:
3386
- if (!(i < fileNodeChildren.length)) return [3 /*break*/, 11];
3387
- fileNodeItem = fileNodeChildren[i];
3388
- result = fileNodeItem.toEmbeddedTSFile();
3389
- fileNodeItem.sourceMap = result.sourceMap;
3390
- if (!(action === 'create')) return [3 /*break*/, 4];
3391
- return [4 /*yield*/, this.handleChange(fileNodeItem, fileNodeItem, result, action)];
3392
- case 2:
3393
- _b.sent();
3394
- return [4 /*yield*/, this.incidentalAction(action, fileNodeItem, fileNodeItem)];
3395
- case 3:
3396
- _b.sent();
3397
- return [3 /*break*/, 10];
3398
- case 4:
3399
- if (!(action === 'delete')) return [3 /*break*/, 7];
3400
- return [4 /*yield*/, this.handleDelete(fileNodeItem, fileNodeItem, result)];
3401
- case 5:
3402
- _b.sent();
3403
- return [4 /*yield*/, this.incidentalAction(action, fileNodeItem, fileNodeItem)];
3404
- case 6:
3405
- _b.sent();
3406
- return [3 /*break*/, 10];
3407
- case 7:
3408
- if (!(action === 'update' && oldpath)) return [3 /*break*/, 10];
3409
- parentPath = oldpath.replace('.ts', '/');
3410
- currentOldPath = parentPath + fileNodeItem.name + '.ts';
3411
- // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
3412
- return [4 /*yield*/, this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath)];
3413
- case 8:
3414
- // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
3415
- _b.sent();
3416
- return [4 /*yield*/, this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath)];
3417
- case 9:
3418
- _b.sent();
3419
- _b.label = 10;
3420
- case 10:
3421
- i++;
3422
- return [3 /*break*/, 1];
3423
- case 11:
3424
- if (!(fileNode instanceof concepts_1.Module)) return [3 /*break*/, 18];
3425
- if (fileNode.type === 'interface' && fileNode.isAdd && action === 'create') {
3426
- isChangeInterface = true;
3427
- }
3428
- module_1 = targetNode;
3429
- results = [];
3430
- this.contentToFile(module_1, results);
3431
- i = 0;
3432
- _b.label = 12;
3433
- case 12:
3434
- if (!(i < results.length)) return [3 /*break*/, 17];
3435
- result = results[i];
3436
- node = this.file2NodeMap.get(result.filePath);
3437
- if (!(action === 'create')) return [3 /*break*/, 14];
3438
- return [4 /*yield*/, this.handleChange(node, node, result, action)];
3439
- case 13:
3440
- _b.sent();
3441
- return [3 /*break*/, 16];
3442
- case 14: return [4 /*yield*/, this.handleDelete(node, node, result)];
3443
- case 15:
3444
- _b.sent();
3445
- _b.label = 16;
3446
- case 16:
3447
- i++;
3448
- return [3 /*break*/, 12];
3449
- case 17:
3450
- // 删除模块通知更新列表
3451
- if (action === 'delete') {
3452
- try {
3453
- // 如果已经
3454
- common_1.invokeCommand('module.delete', true);
3455
- }
3456
- catch (err) {
3457
- console.log('module.delete', '组件销毁了,不用唤起了');
3458
- }
3459
- }
3460
- _b.label = 18;
3461
- case 18:
3462
- /**
3463
- * DataSource只会重命名时候,需要把子集全部重新生成一下
3464
- */
3465
- if (fileNode instanceof concepts_1.DataSource) {
3466
- fileNode.entities.forEach(function (entity) { return __awaiter(_this, void 0, void 0, function () {
3467
- var result, parentPath, currentOldPath, err_2;
3468
- return __generator(this, function (_a) {
3469
- switch (_a.label) {
3470
- case 0:
3471
- _a.trys.push([0, 2, , 3]);
3472
- result = entity.toEmbeddedTSFile();
3473
- parentPath = oldpath.replace('.ts', '/');
3474
- currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
3475
- // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
3476
- return [4 /*yield*/, this.handleRename(entity, entity, result, currentOldPath)];
3477
- case 1:
3478
- // 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
3479
- _a.sent();
3480
- return [3 /*break*/, 3];
3481
- case 2:
3482
- err_2 = _a.sent();
3483
- console.log(err_2);
3484
- return [3 /*break*/, 3];
3485
- case 3: return [2 /*return*/];
3486
- }
3487
- });
3488
- }); });
3489
- }
3490
- _b.label = 19;
3491
- case 19: return [2 /*return*/];
3492
- }
3493
- });
3494
- });
3495
- };
3496
- NaslServer.prototype.receiveHandleChange = function ($event) {
3497
- return __awaiter(this, void 0, void 0, function () {
3498
- var action, targetNode, fileNode, result, oldpath;
3499
- return __generator(this, function (_a) {
3500
- switch (_a.label) {
3501
- case 0:
3502
- singleFileChangeIng = true;
3503
- action = $event.action;
3504
- targetNode = $event.target;
3505
- fileNode = this.getCurrentSource(targetNode).fileNode;
3506
- if (!(!fileNode || fileNode instanceof concepts_1.Module || fileNode instanceof concepts_1.Configuration)) return [3 /*break*/, 3];
3507
- if (!(fileNode instanceof concepts_1.Module)) return [3 /*break*/, 2];
3508
- return [4 /*yield*/, this.incidentalAction(action, fileNode, targetNode)];
3509
- case 1:
3510
- _a.sent();
3511
- _a.label = 2;
3512
- case 2: return [2 /*return*/];
3513
- case 3:
3514
- result = fileNode.toEmbeddedTSFile();
3515
- // 当前操作的节点
3516
- // 如果当前没有生成tsFile
3517
- if (!result) {
3518
- return [2 /*return*/];
3519
- }
3520
- // 修改触发修改文件
3521
- this._debugInFileStorage(targetNode, [
3522
- {
3523
- file: result.filePath,
3524
- fileContent: result.code
3525
- },
3526
- ]);
3527
- fileNode.sourceMap = result.sourceMap;
3528
- if (!(action === 'update' || action === 'create')) return [3 /*break*/, 9];
3529
- if (!(($event === null || $event === void 0 ? void 0 : $event.field) !== 'name')) return [3 /*break*/, 6];
3530
- return [4 /*yield*/, this.handleChange(fileNode, targetNode, result, action)];
3531
- case 4:
3532
- _a.sent();
3533
- return [4 /*yield*/, this.incidentalAction(action, fileNode, targetNode)];
3534
- case 5:
3535
- _a.sent();
3536
- return [3 /*break*/, 9];
3537
- case 6:
3538
- oldpath = fileNode.getEmbeddedFilePath($event.oldObject.name);
3539
- return [4 /*yield*/, this.handleRename(fileNode, targetNode, result, oldpath)];
3540
- case 7:
3541
- _a.sent();
3542
- return [4 /*yield*/, this.incidentalAction(action, fileNode, targetNode, oldpath)];
3543
- case 8:
3544
- _a.sent();
3545
- _a.label = 9;
3546
- case 9:
3547
- if (!(action === 'delete')) return [3 /*break*/, 12];
3548
- return [4 /*yield*/, this.incidentalAction(action, fileNode, targetNode)];
3549
- case 10:
3550
- _a.sent();
3551
- return [4 /*yield*/, this.handleDelete(fileNode, targetNode, result)];
3552
- case 11:
3553
- _a.sent();
3554
- _a.label = 12;
3555
- case 12: return [2 /*return*/, true];
3556
- }
3557
- });
3558
- });
3559
- };
3560
- NaslServer.prototype.changeFileNext = function () {
3561
- var _this = this;
3562
- if (!singleFileChangeIng) {
3563
- var item = this.changeStackList.shift();
3564
- this.receiveHandleChange(item)["catch"](function (err) {
3565
- console.log(err, 'receiveHandleChangeErr');
3566
- })["finally"](function () { return __awaiter(_this, void 0, void 0, function () {
3567
- return __generator(this, function (_a) {
3568
- switch (_a.label) {
3569
- case 0:
3570
- // 每一个文件与change接触就把状态置为false,让下一个进入
3571
- singleFileChangeIng = false;
3572
- if (!this.changeStackList.length) return [3 /*break*/, 1];
3573
- this.changeFileNext();
3574
- return [3 /*break*/, 3];
3575
- case 1:
3576
- console.log(Array.from(filesToCheck));
3577
- return [4 /*yield*/, this.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck))];
3578
- case 2:
3579
- _a.sent();
3580
- filesToCheck.clear();
3581
- _a.label = 3;
3582
- case 3: return [2 /*return*/];
3583
- }
3584
- });
3585
- }); });
3586
- }
3587
- };
3588
- return NaslServer;
3589
- }());
3590
- exports.NaslServer = NaslServer;