@d-es-ign/stryker-js-instrumenter 9.6.0

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 (327) hide show
  1. package/LICENSE +201 -0
  2. package/dist/src/create-instrumenter.d.ts +16 -0
  3. package/dist/src/create-instrumenter.d.ts.map +1 -0
  4. package/dist/src/create-instrumenter.js +15 -0
  5. package/dist/src/create-instrumenter.js.map +1 -0
  6. package/dist/src/disable-type-checks.d.ts +11 -0
  7. package/dist/src/disable-type-checks.d.ts.map +1 -0
  8. package/dist/src/disable-type-checks.js +125 -0
  9. package/dist/src/disable-type-checks.js.map +1 -0
  10. package/dist/src/file.d.ts +6 -0
  11. package/dist/src/file.d.ts.map +1 -0
  12. package/dist/src/file.js +2 -0
  13. package/dist/src/file.js.map +1 -0
  14. package/dist/src/frameworks/angular-ignorer.d.ts +16 -0
  15. package/dist/src/frameworks/angular-ignorer.d.ts.map +1 -0
  16. package/dist/src/frameworks/angular-ignorer.js +85 -0
  17. package/dist/src/frameworks/angular-ignorer.js.map +1 -0
  18. package/dist/src/frameworks/index.d.ts +4 -0
  19. package/dist/src/frameworks/index.d.ts.map +1 -0
  20. package/dist/src/frameworks/index.js +7 -0
  21. package/dist/src/frameworks/index.js.map +1 -0
  22. package/dist/src/index.d.ts +9 -0
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/index.js +8 -0
  25. package/dist/src/index.js.map +1 -0
  26. package/dist/src/instrument-result.d.ts +7 -0
  27. package/dist/src/instrument-result.d.ts.map +1 -0
  28. package/dist/src/instrument-result.js +2 -0
  29. package/dist/src/instrument-result.js.map +1 -0
  30. package/dist/src/instrumenter-options.d.ts +5 -0
  31. package/dist/src/instrumenter-options.d.ts.map +1 -0
  32. package/dist/src/instrumenter-options.js +2 -0
  33. package/dist/src/instrumenter-options.js.map +1 -0
  34. package/dist/src/instrumenter-tokens.d.ts +6 -0
  35. package/dist/src/instrumenter-tokens.d.ts.map +1 -0
  36. package/dist/src/instrumenter-tokens.js +6 -0
  37. package/dist/src/instrumenter-tokens.js.map +1 -0
  38. package/dist/src/instrumenter.d.ts +24 -0
  39. package/dist/src/instrumenter.d.ts.map +1 -0
  40. package/dist/src/instrumenter.js +76 -0
  41. package/dist/src/instrumenter.js.map +1 -0
  42. package/dist/src/mutant-placers/expression-mutant-placer.d.ts +10 -0
  43. package/dist/src/mutant-placers/expression-mutant-placer.d.ts.map +1 -0
  44. package/dist/src/mutant-placers/expression-mutant-placer.js +144 -0
  45. package/dist/src/mutant-placers/expression-mutant-placer.js.map +1 -0
  46. package/dist/src/mutant-placers/index.d.ts +5 -0
  47. package/dist/src/mutant-placers/index.d.ts.map +1 -0
  48. package/dist/src/mutant-placers/index.js +11 -0
  49. package/dist/src/mutant-placers/index.js.map +1 -0
  50. package/dist/src/mutant-placers/mutant-placer.d.ts +8 -0
  51. package/dist/src/mutant-placers/mutant-placer.d.ts.map +1 -0
  52. package/dist/src/mutant-placers/mutant-placer.js +2 -0
  53. package/dist/src/mutant-placers/mutant-placer.js.map +1 -0
  54. package/dist/src/mutant-placers/statement-mutant-placer.d.ts +8 -0
  55. package/dist/src/mutant-placers/statement-mutant-placer.d.ts.map +1 -0
  56. package/dist/src/mutant-placers/statement-mutant-placer.js +24 -0
  57. package/dist/src/mutant-placers/statement-mutant-placer.js.map +1 -0
  58. package/dist/src/mutant-placers/switch-case-mutant-placer.d.ts +14 -0
  59. package/dist/src/mutant-placers/switch-case-mutant-placer.d.ts.map +1 -0
  60. package/dist/src/mutant-placers/switch-case-mutant-placer.js +29 -0
  61. package/dist/src/mutant-placers/switch-case-mutant-placer.js.map +1 -0
  62. package/dist/src/mutant-placers/throw-placement-error.d.ts +5 -0
  63. package/dist/src/mutant-placers/throw-placement-error.d.ts.map +1 -0
  64. package/dist/src/mutant-placers/throw-placement-error.js +17 -0
  65. package/dist/src/mutant-placers/throw-placement-error.js.map +1 -0
  66. package/dist/src/mutant.d.ts +27 -0
  67. package/dist/src/mutant.d.ts.map +1 -0
  68. package/dist/src/mutant.js +80 -0
  69. package/dist/src/mutant.js.map +1 -0
  70. package/dist/src/mutators/arithmetic-operator-mutator.d.ts +3 -0
  71. package/dist/src/mutators/arithmetic-operator-mutator.d.ts.map +1 -0
  72. package/dist/src/mutators/arithmetic-operator-mutator.js +34 -0
  73. package/dist/src/mutators/arithmetic-operator-mutator.js.map +1 -0
  74. package/dist/src/mutators/array-declaration-mutator.d.ts +3 -0
  75. package/dist/src/mutators/array-declaration-mutator.d.ts.map +1 -0
  76. package/dist/src/mutators/array-declaration-mutator.js +26 -0
  77. package/dist/src/mutators/array-declaration-mutator.js.map +1 -0
  78. package/dist/src/mutators/arrow-function-mutator.d.ts +3 -0
  79. package/dist/src/mutators/arrow-function-mutator.d.ts.map +1 -0
  80. package/dist/src/mutators/arrow-function-mutator.js +14 -0
  81. package/dist/src/mutators/arrow-function-mutator.js.map +1 -0
  82. package/dist/src/mutators/assignment-operator-mutator.d.ts +3 -0
  83. package/dist/src/mutators/assignment-operator-mutator.d.ts.map +1 -0
  84. package/dist/src/mutators/assignment-operator-mutator.js +42 -0
  85. package/dist/src/mutators/assignment-operator-mutator.js.map +1 -0
  86. package/dist/src/mutators/block-statement-mutator.d.ts +3 -0
  87. package/dist/src/mutators/block-statement-mutator.d.ts.map +1 -0
  88. package/dist/src/mutators/block-statement-mutator.js +63 -0
  89. package/dist/src/mutators/block-statement-mutator.js.map +1 -0
  90. package/dist/src/mutators/boolean-literal-mutator.d.ts +3 -0
  91. package/dist/src/mutators/boolean-literal-mutator.d.ts.map +1 -0
  92. package/dist/src/mutators/boolean-literal-mutator.js +17 -0
  93. package/dist/src/mutators/boolean-literal-mutator.js.map +1 -0
  94. package/dist/src/mutators/conditional-expression-mutator.d.ts +3 -0
  95. package/dist/src/mutators/conditional-expression-mutator.d.ts.map +1 -0
  96. package/dist/src/mutators/conditional-expression-mutator.js +81 -0
  97. package/dist/src/mutators/conditional-expression-mutator.js.map +1 -0
  98. package/dist/src/mutators/equality-operator-mutator.d.ts +3 -0
  99. package/dist/src/mutators/equality-operator-mutator.d.ts.map +1 -0
  100. package/dist/src/mutators/equality-operator-mutator.js +28 -0
  101. package/dist/src/mutators/equality-operator-mutator.js.map +1 -0
  102. package/dist/src/mutators/index.d.ts +4 -0
  103. package/dist/src/mutators/index.d.ts.map +1 -0
  104. package/dist/src/mutators/index.js +4 -0
  105. package/dist/src/mutators/index.js.map +1 -0
  106. package/dist/src/mutators/logical-operator-mutator.d.ts +3 -0
  107. package/dist/src/mutators/logical-operator-mutator.d.ts.map +1 -0
  108. package/dist/src/mutators/logical-operator-mutator.js +21 -0
  109. package/dist/src/mutators/logical-operator-mutator.js.map +1 -0
  110. package/dist/src/mutators/method-expression-mutator.d.ts +3 -0
  111. package/dist/src/mutators/method-expression-mutator.d.ts.map +1 -0
  112. package/dist/src/mutators/method-expression-mutator.js +65 -0
  113. package/dist/src/mutators/method-expression-mutator.js.map +1 -0
  114. package/dist/src/mutators/mutate.d.ts +3 -0
  115. package/dist/src/mutators/mutate.d.ts.map +1 -0
  116. package/dist/src/mutators/mutate.js +35 -0
  117. package/dist/src/mutators/mutate.js.map +1 -0
  118. package/dist/src/mutators/mutator-options.d.ts +5 -0
  119. package/dist/src/mutators/mutator-options.d.ts.map +1 -0
  120. package/dist/src/mutators/mutator-options.js +2 -0
  121. package/dist/src/mutators/mutator-options.js.map +1 -0
  122. package/dist/src/mutators/node-mutator.d.ts +6 -0
  123. package/dist/src/mutators/node-mutator.d.ts.map +1 -0
  124. package/dist/src/mutators/node-mutator.js +2 -0
  125. package/dist/src/mutators/node-mutator.js.map +1 -0
  126. package/dist/src/mutators/object-literal-mutator.d.ts +3 -0
  127. package/dist/src/mutators/object-literal-mutator.d.ts.map +1 -0
  128. package/dist/src/mutators/object-literal-mutator.js +11 -0
  129. package/dist/src/mutators/object-literal-mutator.js.map +1 -0
  130. package/dist/src/mutators/optional-chaining-mutator.d.ts +15 -0
  131. package/dist/src/mutators/optional-chaining-mutator.d.ts.map +1 -0
  132. package/dist/src/mutators/optional-chaining-mutator.js +28 -0
  133. package/dist/src/mutators/optional-chaining-mutator.js.map +1 -0
  134. package/dist/src/mutators/regex-mutator.d.ts +3 -0
  135. package/dist/src/mutators/regex-mutator.d.ts.map +1 -0
  136. package/dist/src/mutators/regex-mutator.js +53 -0
  137. package/dist/src/mutators/regex-mutator.js.map +1 -0
  138. package/dist/src/mutators/string-literal-mutator.d.ts +3 -0
  139. package/dist/src/mutators/string-literal-mutator.d.ts.map +1 -0
  140. package/dist/src/mutators/string-literal-mutator.js +36 -0
  141. package/dist/src/mutators/string-literal-mutator.js.map +1 -0
  142. package/dist/src/mutators/unary-operator-mutator.d.ts +3 -0
  143. package/dist/src/mutators/unary-operator-mutator.d.ts.map +1 -0
  144. package/dist/src/mutators/unary-operator-mutator.js +27 -0
  145. package/dist/src/mutators/unary-operator-mutator.js.map +1 -0
  146. package/dist/src/mutators/update-operator-mutator.d.ts +3 -0
  147. package/dist/src/mutators/update-operator-mutator.d.ts.map +1 -0
  148. package/dist/src/mutators/update-operator-mutator.js +17 -0
  149. package/dist/src/mutators/update-operator-mutator.js.map +1 -0
  150. package/dist/src/parsers/create-parser.d.ts +5 -0
  151. package/dist/src/parsers/create-parser.d.ts.map +1 -0
  152. package/dist/src/parsers/create-parser.js +58 -0
  153. package/dist/src/parsers/create-parser.js.map +1 -0
  154. package/dist/src/parsers/html-parser.d.ts +4 -0
  155. package/dist/src/parsers/html-parser.d.ts.map +1 -0
  156. package/dist/src/parsers/html-parser.js +96 -0
  157. package/dist/src/parsers/html-parser.js.map +1 -0
  158. package/dist/src/parsers/index.d.ts +5 -0
  159. package/dist/src/parsers/index.d.ts.map +1 -0
  160. package/dist/src/parsers/index.js +3 -0
  161. package/dist/src/parsers/index.js.map +1 -0
  162. package/dist/src/parsers/js-parser.d.ts +4 -0
  163. package/dist/src/parsers/js-parser.d.ts.map +1 -0
  164. package/dist/src/parsers/js-parser.js +50 -0
  165. package/dist/src/parsers/js-parser.js.map +1 -0
  166. package/dist/src/parsers/parse-error.d.ts +5 -0
  167. package/dist/src/parsers/parse-error.d.ts.map +1 -0
  168. package/dist/src/parsers/parse-error.js +6 -0
  169. package/dist/src/parsers/parse-error.js.map +1 -0
  170. package/dist/src/parsers/parser-context.d.ts +6 -0
  171. package/dist/src/parsers/parser-context.d.ts.map +1 -0
  172. package/dist/src/parsers/parser-context.js +2 -0
  173. package/dist/src/parsers/parser-context.js.map +1 -0
  174. package/dist/src/parsers/parser-options.d.ts +4 -0
  175. package/dist/src/parsers/parser-options.d.ts.map +1 -0
  176. package/dist/src/parsers/parser-options.js +2 -0
  177. package/dist/src/parsers/parser-options.js.map +1 -0
  178. package/dist/src/parsers/svelte-parser.d.ts +4 -0
  179. package/dist/src/parsers/svelte-parser.d.ts.map +1 -0
  180. package/dist/src/parsers/svelte-parser.js +169 -0
  181. package/dist/src/parsers/svelte-parser.js.map +1 -0
  182. package/dist/src/parsers/ts-parser.d.ts +9 -0
  183. package/dist/src/parsers/ts-parser.d.ts.map +1 -0
  184. package/dist/src/parsers/ts-parser.js +54 -0
  185. package/dist/src/parsers/ts-parser.js.map +1 -0
  186. package/dist/src/printers/html-printer.d.ts +4 -0
  187. package/dist/src/printers/html-printer.d.ts.map +1 -0
  188. package/dist/src/printers/html-printer.js +15 -0
  189. package/dist/src/printers/html-printer.js.map +1 -0
  190. package/dist/src/printers/index.d.ts +7 -0
  191. package/dist/src/printers/index.d.ts.map +1 -0
  192. package/dist/src/printers/index.js +23 -0
  193. package/dist/src/printers/index.js.map +1 -0
  194. package/dist/src/printers/js-printer.d.ts +4 -0
  195. package/dist/src/printers/js-printer.d.ts.map +1 -0
  196. package/dist/src/printers/js-printer.js +6 -0
  197. package/dist/src/printers/js-printer.js.map +1 -0
  198. package/dist/src/printers/svelte-printer.d.ts +4 -0
  199. package/dist/src/printers/svelte-printer.d.ts.map +1 -0
  200. package/dist/src/printers/svelte-printer.js +28 -0
  201. package/dist/src/printers/svelte-printer.js.map +1 -0
  202. package/dist/src/printers/ts-printer.d.ts +4 -0
  203. package/dist/src/printers/ts-printer.d.ts.map +1 -0
  204. package/dist/src/printers/ts-printer.js +9 -0
  205. package/dist/src/printers/ts-printer.js.map +1 -0
  206. package/dist/src/syntax/index.d.ts +86 -0
  207. package/dist/src/syntax/index.d.ts.map +1 -0
  208. package/dist/src/syntax/index.js +9 -0
  209. package/dist/src/syntax/index.js.map +1 -0
  210. package/dist/src/transformers/babel-transformer.d.ts +4 -0
  211. package/dist/src/transformers/babel-transformer.d.ts.map +1 -0
  212. package/dist/src/transformers/babel-transformer.js +142 -0
  213. package/dist/src/transformers/babel-transformer.js.map +1 -0
  214. package/dist/src/transformers/directive-bookkeeper.d.ts +19 -0
  215. package/dist/src/transformers/directive-bookkeeper.d.ts.map +1 -0
  216. package/dist/src/transformers/directive-bookkeeper.js +108 -0
  217. package/dist/src/transformers/directive-bookkeeper.js.map +1 -0
  218. package/dist/src/transformers/html-transformer.d.ts +4 -0
  219. package/dist/src/transformers/html-transformer.d.ts.map +1 -0
  220. package/dist/src/transformers/html-transformer.js +6 -0
  221. package/dist/src/transformers/html-transformer.js.map +1 -0
  222. package/dist/src/transformers/ignorer-bookkeeper.d.ts +18 -0
  223. package/dist/src/transformers/ignorer-bookkeeper.d.ts.map +1 -0
  224. package/dist/src/transformers/ignorer-bookkeeper.js +29 -0
  225. package/dist/src/transformers/ignorer-bookkeeper.js.map +1 -0
  226. package/dist/src/transformers/index.d.ts +6 -0
  227. package/dist/src/transformers/index.d.ts.map +1 -0
  228. package/dist/src/transformers/index.js +4 -0
  229. package/dist/src/transformers/index.js.map +1 -0
  230. package/dist/src/transformers/mutant-collector.d.ts +19 -0
  231. package/dist/src/transformers/mutant-collector.d.ts.map +1 -0
  232. package/dist/src/transformers/mutant-collector.js +25 -0
  233. package/dist/src/transformers/mutant-collector.js.map +1 -0
  234. package/dist/src/transformers/svelte-transformer.d.ts +4 -0
  235. package/dist/src/transformers/svelte-transformer.d.ts.map +1 -0
  236. package/dist/src/transformers/svelte-transformer.js +46 -0
  237. package/dist/src/transformers/svelte-transformer.js.map +1 -0
  238. package/dist/src/transformers/transformer-options.d.ts +6 -0
  239. package/dist/src/transformers/transformer-options.d.ts.map +1 -0
  240. package/dist/src/transformers/transformer-options.js +2 -0
  241. package/dist/src/transformers/transformer-options.js.map +1 -0
  242. package/dist/src/transformers/transformer.d.ts +22 -0
  243. package/dist/src/transformers/transformer.d.ts.map +1 -0
  244. package/dist/src/transformers/transformer.js +30 -0
  245. package/dist/src/transformers/transformer.js.map +1 -0
  246. package/dist/src/util/binary-operator.d.ts +2 -0
  247. package/dist/src/util/binary-operator.d.ts.map +1 -0
  248. package/dist/src/util/binary-operator.js +2 -0
  249. package/dist/src/util/binary-operator.js.map +1 -0
  250. package/dist/src/util/index.d.ts +4 -0
  251. package/dist/src/util/index.d.ts.map +1 -0
  252. package/dist/src/util/index.js +4 -0
  253. package/dist/src/util/index.js.map +1 -0
  254. package/dist/src/util/position-converter.d.ts +16 -0
  255. package/dist/src/util/position-converter.d.ts.map +1 -0
  256. package/dist/src/util/position-converter.js +126 -0
  257. package/dist/src/util/position-converter.js.map +1 -0
  258. package/dist/src/util/syntax-helpers.d.ts +60 -0
  259. package/dist/src/util/syntax-helpers.d.ts.map +1 -0
  260. package/dist/src/util/syntax-helpers.js +217 -0
  261. package/dist/src/util/syntax-helpers.js.map +1 -0
  262. package/package.json +64 -0
  263. package/src/create-instrumenter.ts +30 -0
  264. package/src/disable-type-checks.ts +153 -0
  265. package/src/file.ts +6 -0
  266. package/src/frameworks/angular-ignorer.ts +129 -0
  267. package/src/frameworks/index.ts +9 -0
  268. package/src/index.ts +8 -0
  269. package/src/instrument-result.ts +8 -0
  270. package/src/instrumenter-options.ts +5 -0
  271. package/src/instrumenter-tokens.ts +5 -0
  272. package/src/instrumenter.ts +100 -0
  273. package/src/mutant-placers/expression-mutant-placer.ts +210 -0
  274. package/src/mutant-placers/index.ts +12 -0
  275. package/src/mutant-placers/mutant-placer.ts +9 -0
  276. package/src/mutant-placers/statement-mutant-placer.ts +39 -0
  277. package/src/mutant-placers/switch-case-mutant-placer.ts +41 -0
  278. package/src/mutant-placers/throw-placement-error.ts +34 -0
  279. package/src/mutant.ts +101 -0
  280. package/src/mutators/arithmetic-operator-mutator.ts +51 -0
  281. package/src/mutators/array-declaration-mutator.ts +36 -0
  282. package/src/mutators/arrow-function-mutator.ts +22 -0
  283. package/src/mutators/assignment-operator-mutator.ts +59 -0
  284. package/src/mutators/block-statement-mutator.ts +89 -0
  285. package/src/mutators/boolean-literal-mutator.ts +24 -0
  286. package/src/mutators/conditional-expression-mutator.ts +92 -0
  287. package/src/mutators/equality-operator-mutator.ts +35 -0
  288. package/src/mutators/index.ts +3 -0
  289. package/src/mutators/logical-operator-mutator.ts +29 -0
  290. package/src/mutators/method-expression-mutator.ts +99 -0
  291. package/src/mutators/mutate.ts +36 -0
  292. package/src/mutators/mutator-options.ts +4 -0
  293. package/src/mutators/node-mutator.ts +6 -0
  294. package/src/mutators/object-literal-mutator.ts +15 -0
  295. package/src/mutators/optional-chaining-mutator.ts +39 -0
  296. package/src/mutators/regex-mutator.ts +69 -0
  297. package/src/mutators/string-literal-mutator.ts +49 -0
  298. package/src/mutators/unary-operator-mutator.ts +39 -0
  299. package/src/mutators/update-operator-mutator.ts +26 -0
  300. package/src/parsers/create-parser.ts +78 -0
  301. package/src/parsers/html-parser.ts +138 -0
  302. package/src/parsers/index.ts +5 -0
  303. package/src/parsers/js-parser.ts +58 -0
  304. package/src/parsers/parse-error.ts +9 -0
  305. package/src/parsers/parser-context.ts +15 -0
  306. package/src/parsers/parser-options.ts +3 -0
  307. package/src/parsers/svelte-parser.ts +255 -0
  308. package/src/parsers/ts-parser.ts +69 -0
  309. package/src/printers/html-printer.ts +20 -0
  310. package/src/printers/index.ts +33 -0
  311. package/src/printers/js-printer.ts +11 -0
  312. package/src/printers/svelte-printer.ts +34 -0
  313. package/src/printers/ts-printer.ts +14 -0
  314. package/src/syntax/index.ts +97 -0
  315. package/src/transformers/babel-transformer.ts +217 -0
  316. package/src/transformers/directive-bookkeeper.ts +173 -0
  317. package/src/transformers/html-transformer.ts +13 -0
  318. package/src/transformers/ignorer-bookkeeper.ts +41 -0
  319. package/src/transformers/index.ts +6 -0
  320. package/src/transformers/mutant-collector.ts +44 -0
  321. package/src/transformers/svelte-transformer.ts +57 -0
  322. package/src/transformers/transformer-options.ts +7 -0
  323. package/src/transformers/transformer.ts +54 -0
  324. package/src/util/binary-operator.ts +23 -0
  325. package/src/util/index.ts +3 -0
  326. package/src/util/position-converter.ts +145 -0
  327. package/src/util/syntax-helpers.ts +301 -0
@@ -0,0 +1,142 @@
1
+ import babel from '@babel/core';
2
+ // @ts-expect-error The babel types don't define "File" yet
3
+ import { File } from '@babel/core';
4
+ import { isImportDeclaration, isTypeNode, locationIncluded, locationOverlaps, placeHeaderIfNeeded, } from '../util/syntax-helpers.js';
5
+ import { allMutantPlacers, throwPlacementError, } from '../mutant-placers/index.js';
6
+ import { allMutators } from '../mutators/index.js';
7
+ import { DirectiveBookkeeper } from './directive-bookkeeper.js';
8
+ import { IgnorerBookkeeper } from './ignorer-bookkeeper.js';
9
+ const { traverse } = babel;
10
+ export const transformBabel = ({ root, originFileName, rawContent, offset }, mutantCollector, { options, mutateDescription, logger }, mutators = allMutators, mutantPlacers = allMutantPlacers) => {
11
+ // Wrap the AST in a `new File`, so `nodePath.buildCodeFrameError` works
12
+ // https://github.com/babel/babel/issues/11889
13
+ const file = new File({ filename: originFileName }, { code: rawContent, ast: root });
14
+ // Create a placementMap for the mutation switching bookkeeping
15
+ const placementMap = new Map();
16
+ // Create the bookkeeper responsible for the // Stryker ... directives
17
+ const directiveBookkeeper = new DirectiveBookkeeper(logger, mutators, originFileName);
18
+ // The ignorer bookkeeper is responsible for keeping track of the ignored node and the reason why it is ignored
19
+ const ignorerBookkeeper = new IgnorerBookkeeper(options.ignorers);
20
+ // Now start the actual traversing of the AST
21
+ //
22
+ // On the way down:
23
+ // * Treat the tree as immutable.
24
+ // * Identify the nodes that can be used to place mutants on in the placement map.
25
+ // * Generate the mutants on each node.
26
+ // * When a node generated mutants, do a short walk back up and register them in the placement map
27
+ // * Call the `applied` method using the placement node, that way the mutant will capture the AST with mutation all the way to the placement node
28
+ //
29
+ // On the way up:
30
+ // * If this node has mutants in the placementMap, place them in the AST.
31
+ //
32
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
33
+ traverse(file.ast, {
34
+ enter(path) {
35
+ directiveBookkeeper.processStrykerDirectives(path.node);
36
+ if (shouldSkip(path)) {
37
+ path.skip();
38
+ }
39
+ else {
40
+ ignorerBookkeeper.enterNode(path);
41
+ addToPlacementMapIfPossible(path);
42
+ if (shouldMutate(path)) {
43
+ const mutantsToPlace = collectMutants(path);
44
+ if (mutantsToPlace.length) {
45
+ registerInPlacementMap(path, mutantsToPlace);
46
+ }
47
+ }
48
+ }
49
+ },
50
+ exit(path) {
51
+ placeMutantsIfNeeded(path);
52
+ ignorerBookkeeper.leaveNode(path);
53
+ },
54
+ });
55
+ placeHeaderIfNeeded(mutantCollector, originFileName, options, root);
56
+ /**
57
+ * If mutants were collected, be sure to register them in the placement map.
58
+ */
59
+ function registerInPlacementMap(path, mutantsToPlace) {
60
+ const placementPath = path.find((ancestor) => placementMap.has(ancestor.node));
61
+ if (placementPath) {
62
+ const { appliedMutants } = placementMap.get(placementPath.node);
63
+ mutantsToPlace.forEach((mutant) => appliedMutants.set(mutant, mutant.applied(placementPath.node)));
64
+ }
65
+ else {
66
+ throw new Error(`Mutants cannot be placed. This shouldn't happen! Unplaced mutants: ${JSON.stringify(mutantsToPlace, null, 2)}`);
67
+ }
68
+ }
69
+ /**
70
+ * If this node can be used to place mutants on, add to the placement map
71
+ */
72
+ function addToPlacementMapIfPossible(path) {
73
+ const placer = mutantPlacers.find((p) => p.canPlace(path));
74
+ if (placer) {
75
+ placementMap.set(path.node, { appliedMutants: new Map(), placer });
76
+ }
77
+ }
78
+ /**
79
+ * Don't traverse import declarations, decorators and nodes that don't have overlap with the selected mutation ranges
80
+ */
81
+ function shouldSkip(path) {
82
+ return (isTypeNode(path) ||
83
+ isImportDeclaration(path) ||
84
+ path.isDecorator() ||
85
+ !mutateDescription ||
86
+ (Array.isArray(mutateDescription) &&
87
+ mutateDescription.every((range) => !locationOverlaps(range, path.node.loc))));
88
+ }
89
+ function shouldMutate(path) {
90
+ return (mutateDescription === true ||
91
+ (Array.isArray(mutateDescription) &&
92
+ mutateDescription.some((range) => locationIncluded(range, path.node.loc))));
93
+ }
94
+ /**
95
+ * Place mutants that are assigned to the current node path (on exit)
96
+ */
97
+ function placeMutantsIfNeeded(path) {
98
+ const mutantsPlacement = placementMap.get(path.node);
99
+ if (mutantsPlacement?.appliedMutants.size) {
100
+ try {
101
+ mutantsPlacement.placer.place(path, mutantsPlacement.appliedMutants);
102
+ path.skip();
103
+ }
104
+ catch (error) {
105
+ throwPlacementError(error, path, mutantsPlacement.placer, [...mutantsPlacement.appliedMutants.keys()], originFileName);
106
+ }
107
+ }
108
+ }
109
+ /**
110
+ * Collect the mutants for the current node and return the non-ignored.
111
+ */
112
+ function collectMutants(path) {
113
+ return [...mutate(path)]
114
+ .map((mutable) => mutantCollector.collect(originFileName, path.node, mutable, offset))
115
+ .filter((mutant) => !mutant.ignoreReason);
116
+ }
117
+ /**
118
+ * Generate mutants for the current node.
119
+ */
120
+ function* mutate(node) {
121
+ for (const mutator of mutators) {
122
+ for (const replacement of mutator.mutate(node)) {
123
+ yield {
124
+ replacement,
125
+ mutatorName: mutator.name,
126
+ ignoreReason: directiveBookkeeper.findIgnoreReason(node.node.loc.start.line, mutator.name) ??
127
+ findExcludedMutatorIgnoreReason(mutator.name) ??
128
+ ignorerBookkeeper.currentIgnoreMessage,
129
+ };
130
+ }
131
+ }
132
+ function findExcludedMutatorIgnoreReason(mutatorName) {
133
+ if (options.excludedMutations.includes(mutatorName)) {
134
+ return `Ignored because of excluded mutation "${mutatorName}"`;
135
+ }
136
+ else {
137
+ return undefined;
138
+ }
139
+ }
140
+ }
141
+ };
142
+ //# sourceMappingURL=babel-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-transformer.js","sourceRoot":"","sources":["../../../src/transformers/babel-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,aAAa,CAAC;AAE/D,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EAEhB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AAS3B,MAAM,CAAC,MAAM,cAAc,GAAiC,CAC1D,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,EAC5C,eAAe,EACf,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,EACtC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,gBAAgB,EAChC,EAAE;IACF,wEAAwE;IACxE,8CAA8C;IAC9C,MAAM,IAAI,GAAG,IAAI,IAAI,CACnB,EAAE,QAAQ,EAAE,cAAc,EAAE,EAC5B,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,CAChC,CAAC;IAEF,+DAA+D;IAC/D,MAAM,YAAY,GAAiB,IAAI,GAAG,EAAE,CAAC;IAE7C,sEAAsE;IACtE,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,CACjD,MAAM,EACN,QAAQ,EACR,cAAc,CAC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AI,QAAQ,EAAE,CAAC;YAC/B,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/C,MAAM;oBACJ,WAAW;oBACX,WAAW,EAAE,OAAO,CAAC,IAAI;oBACzB,YAAY,EACV,mBAAmB,CAAC,gBAAgB,CAClC,IAAI,CAAC,IAAI,CAAC,GAAI,CAAC,KAAK,CAAC,IAAI,EACzB,OAAO,CAAC,IAAI,CACb;wBACD,+BAA+B,CAAC,OAAO,CAAC,IAAI,CAAC;wBAC7C,iBAAiB,CAAC,oBAAoB;iBACzC,CAAC;YACJ,CAAC;QACH,CAAC;QAED,SAAS,+BAA+B,CACtC,WAAmB;YAEnB,IAAI,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACpD,OAAO,yCAAyC,WAAW,GAAG,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACN,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { types } from '@babel/core';
2
+ import { Logger } from '@stryker-mutator/api/logging';
3
+ import { NodeMutator } from '../mutators/node-mutator.js';
4
+ /**
5
+ * Responsible for the bookkeeping of "// Stryker" directives like "disable" and "restore".
6
+ */
7
+ export declare class DirectiveBookkeeper {
8
+ private readonly logger;
9
+ private readonly allMutators;
10
+ private readonly originFileName;
11
+ private readonly strykerCommentDirectiveRegex;
12
+ private currentIgnoreRule;
13
+ private readonly allMutatorNames;
14
+ constructor(logger: Logger, allMutators: NodeMutator[], originFileName: string);
15
+ processStrykerDirectives({ loc, leadingComments }: types.Node): void;
16
+ findIgnoreReason(line: number, mutatorName: string): string | undefined;
17
+ private warnAboutUnusedDirective;
18
+ }
19
+ //# sourceMappingURL=directive-bookkeeper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive-bookkeeper.d.ts","sourceRoot":"","sources":["../../../src/transformers/directive-bookkeeper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAmD1D;;GAEG;AACH,qBAAa,mBAAmB;IAS5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc;IATjC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAC+B;IAE5E,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAW;gBAGxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EAAE,EAC1B,cAAc,EAAE,MAAM;IAKlC,wBAAwB,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,IAAI,GAAG,IAAI;IAqEpE,gBAAgB,CACrB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS;IAKrB,OAAO,CAAC,wBAAwB;CAoBjC"}
@@ -0,0 +1,108 @@
1
+ import { notEmpty } from '@stryker-mutator/util';
2
+ const WILDCARD = 'all';
3
+ const DEFAULT_REASON = 'Ignored using a comment';
4
+ class IgnoreRule {
5
+ mutatorNames;
6
+ line;
7
+ ignoreReason;
8
+ previousRule;
9
+ constructor(mutatorNames, line, ignoreReason, previousRule) {
10
+ this.mutatorNames = mutatorNames;
11
+ this.line = line;
12
+ this.ignoreReason = ignoreReason;
13
+ this.previousRule = previousRule;
14
+ }
15
+ matches(mutatorName, line) {
16
+ const lineMatches = () => this.line === undefined || this.line === line;
17
+ const mutatorMatches = () => this.mutatorNames.includes(mutatorName) ||
18
+ this.mutatorNames.includes(WILDCARD);
19
+ return lineMatches() && mutatorMatches();
20
+ }
21
+ findIgnoreReason(mutatorName, line) {
22
+ if (this.matches(mutatorName, line)) {
23
+ return this.ignoreReason;
24
+ }
25
+ return this.previousRule.findIgnoreReason(mutatorName, line);
26
+ }
27
+ }
28
+ class RestoreRule extends IgnoreRule {
29
+ constructor(mutatorNames, line, previousRule) {
30
+ super(mutatorNames, line, undefined, previousRule);
31
+ }
32
+ }
33
+ const rootRule = {
34
+ findIgnoreReason() {
35
+ return undefined;
36
+ },
37
+ };
38
+ /**
39
+ * Responsible for the bookkeeping of "// Stryker" directives like "disable" and "restore".
40
+ */
41
+ export class DirectiveBookkeeper {
42
+ logger;
43
+ allMutators;
44
+ originFileName;
45
+ // https://regex101.com/r/nWLLLm/1
46
+ strykerCommentDirectiveRegex = /^\s?Stryker (disable|restore)(?: (next-line))? ([a-zA-Z, ]+)(?::(.+)?)?/;
47
+ currentIgnoreRule = rootRule;
48
+ allMutatorNames;
49
+ constructor(logger, allMutators, originFileName) {
50
+ this.logger = logger;
51
+ this.allMutators = allMutators;
52
+ this.originFileName = originFileName;
53
+ this.allMutatorNames = this.allMutators.map((x) => x.name.toLowerCase());
54
+ }
55
+ processStrykerDirectives({ loc, leadingComments }) {
56
+ leadingComments
57
+ ?.map((comment) => ({
58
+ comment,
59
+ matchResult: this.strykerCommentDirectiveRegex.exec(comment.value),
60
+ }))
61
+ .filter(({ matchResult }) => notEmpty(matchResult))
62
+ .forEach(({ comment, matchResult }) => {
63
+ const [, directiveType, scope, mutators, optionalReason] = matchResult;
64
+ let mutatorNames = mutators.split(',').map((mutator) => mutator.trim());
65
+ this.warnAboutUnusedDirective(mutatorNames, directiveType, scope, comment);
66
+ mutatorNames = mutatorNames.map((mutator) => mutator.toLowerCase());
67
+ const reason = (optionalReason ?? DEFAULT_REASON).trim();
68
+ switch (directiveType) {
69
+ case 'disable':
70
+ switch (scope) {
71
+ case 'next-line':
72
+ this.currentIgnoreRule = new IgnoreRule(mutatorNames, loc.start.line, reason, this.currentIgnoreRule);
73
+ break;
74
+ default:
75
+ this.currentIgnoreRule = new IgnoreRule(mutatorNames, undefined, reason, this.currentIgnoreRule);
76
+ break;
77
+ }
78
+ break;
79
+ case 'restore':
80
+ switch (scope) {
81
+ case 'next-line':
82
+ this.currentIgnoreRule = new RestoreRule(mutatorNames, loc.start.line, this.currentIgnoreRule);
83
+ break;
84
+ default:
85
+ this.currentIgnoreRule = new RestoreRule(mutatorNames, undefined, this.currentIgnoreRule);
86
+ break;
87
+ }
88
+ break;
89
+ }
90
+ });
91
+ }
92
+ findIgnoreReason(line, mutatorName) {
93
+ mutatorName = mutatorName.toLowerCase();
94
+ return this.currentIgnoreRule.findIgnoreReason(mutatorName, line);
95
+ }
96
+ warnAboutUnusedDirective(mutators, directiveType, scope, comment) {
97
+ for (const mutator of mutators) {
98
+ if (mutator === WILDCARD)
99
+ continue;
100
+ if (!this.allMutatorNames.includes(mutator.toLowerCase())) {
101
+ this.logger.warn(
102
+ // Scope can be global and therefore undefined
103
+ `Unused 'Stryker ${scope ? directiveType + ' ' + scope : directiveType}' directive. Mutator with name '${mutator}' not found. Directive found at: ${this.originFileName}:${comment.loc.start.line}:${comment.loc.start.column}.`);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ //# sourceMappingURL=directive-bookkeeper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive-bookkeeper.js","sourceRoot":"","sources":["../../../src/transformers/directive-bookkeeper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMjD,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAQjD,MAAM,UAAU;IAEL;IACA;IACA;IACA;IAJT,YACS,YAAsB,EACtB,IAAwB,EACxB,YAA0B,EAC1B,YAAkB;QAHlB,iBAAY,GAAZ,YAAY,CAAU;QACtB,SAAI,GAAJ,IAAI,CAAoB;QACxB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAM;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AAO,CAAC,GAAI,CAAC,KAAK,CAAC,IAAI,IAC1H,OAAO,CAAC,GAAI,CAAC,KAAK,CAAC,MACrB,GAAG,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { AstFormat } from '../syntax/index.js';
2
+ import { AstTransformer } from './index.js';
3
+ export declare const transformHtml: AstTransformer<AstFormat.Html>;
4
+ //# sourceMappingURL=html-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer.d.ts","sourceRoot":"","sources":["../../../src/transformers/html-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,SAAS,CAAC,IAAI,CAQxD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const transformHtml = ({ root }, mutantCollector, context) => {
2
+ root.scripts.forEach((ast) => {
3
+ context.transform(ast, mutantCollector, context);
4
+ });
5
+ };
6
+ //# sourceMappingURL=html-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer.js","sourceRoot":"","sources":["../../../src/transformers/html-transformer.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAmC,CAC3D,EAAE,IAAI,EAAE,EACR,eAAe,EACf,OAAO,EACP,EAAE;IACF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3B,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { NodePath as BabelNodePath } from '@babel/core';
2
+ import type { Ignorer } from '@stryker-mutator/api/ignore';
3
+ declare module '@stryker-mutator/api/ignore' {
4
+ interface NodePath extends BabelNodePath {
5
+ }
6
+ }
7
+ /**
8
+ * Responsible for keeping track of the active ignore message and node using the configured ignore-plugins.
9
+ */
10
+ export declare class IgnorerBookkeeper {
11
+ private readonly ignorers;
12
+ private activeIgnored?;
13
+ get currentIgnoreMessage(): string | undefined;
14
+ constructor(ignorers: Ignorer[]);
15
+ enterNode(path: BabelNodePath): void;
16
+ leaveNode(path: BabelNodePath): void;
17
+ }
18
+ //# sourceMappingURL=ignorer-bookkeeper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignorer-bookkeeper.d.ts","sourceRoot":"","sources":["../../../src/transformers/ignorer-bookkeeper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,QAAQ,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,QAAQ,6BAA6B,CAAC;IAE3C,UAAU,QAAS,SAAQ,aAAa;KAAG;CAC5C;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,aAAa,CAAC,CAAwC;IAE9D,IAAW,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAEpD;gBAEW,QAAQ,EAAE,OAAO,EAAE;IAIxB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAWpC,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;CAK5C"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Responsible for keeping track of the active ignore message and node using the configured ignore-plugins.
3
+ */
4
+ export class IgnorerBookkeeper {
5
+ ignorers;
6
+ activeIgnored;
7
+ get currentIgnoreMessage() {
8
+ return this.activeIgnored?.message;
9
+ }
10
+ constructor(ignorers) {
11
+ this.ignorers = ignorers;
12
+ }
13
+ enterNode(path) {
14
+ if (!this.activeIgnored) {
15
+ this.ignorers.forEach((ignorer) => {
16
+ const message = ignorer.shouldIgnore(path);
17
+ if (message) {
18
+ this.activeIgnored = { node: path.node, message };
19
+ }
20
+ });
21
+ }
22
+ }
23
+ leaveNode(path) {
24
+ if (this.activeIgnored?.node === path.node) {
25
+ this.activeIgnored = undefined;
26
+ }
27
+ }
28
+ }
29
+ //# sourceMappingURL=ignorer-bookkeeper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignorer-bookkeeper.js","sourceRoot":"","sources":["../../../src/transformers/ignorer-bookkeeper.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACX,QAAQ,CAAC;IAClB,aAAa,CAAyC;IAE9D,IAAW,oBAAoB;QAC7B,OAAO,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IACrC,CAAC;IAED,YAAY,QAAmB;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,SAAS,CAAC,IAAmB;QAClC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAI,CAAC,aAAa,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;gBACpD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEM,SAAS,CAAC,IAAmB;QAClC,IAAI,IAAI,CAAC,aAAa,EAAE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3C,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { MutantCollector } from './mutant-collector.js';
2
+ import { TransformerOptions } from './transformer-options.js';
3
+ export type { TransformerOptions };
4
+ export { MutantCollector };
5
+ export * from './transformer.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { MutantCollector } from './mutant-collector.js';
2
+ export { MutantCollector };
3
+ export * from './transformer.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { types } from '@babel/core';
2
+ import { Position } from '@stryker-mutator/api/core';
3
+ import { Mutant, Mutable } from '../mutant.js';
4
+ export declare class MutantCollector {
5
+ private readonly _mutants;
6
+ get mutants(): readonly Mutant[];
7
+ /**
8
+ * Adds mutants to the internal mutant list.
9
+ * @param fileName file name that houses the mutant
10
+ * @param original The node to mutate
11
+ * @param mutables the named node mutation to be added
12
+ * @param contextPath the context where these mutants are found and should be placed as close by as possible
13
+ * @param offset offset of mutant nodes
14
+ * @returns The mutant (for testability)
15
+ */
16
+ collect(fileName: string, original: types.Node, mutable: Mutable, offset?: Position): Mutant;
17
+ hasPlacedMutants(fileName: string): boolean;
18
+ }
19
+ //# sourceMappingURL=mutant-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutant-collector.d.ts","sourceRoot":"","sources":["../../../src/transformers/mutant-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,IAAW,OAAO,IAAI,SAAS,MAAM,EAAE,CAEtC;IAED;;;;;;;;OAQG;IACI,OAAO,CACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,CAAC,IAAI,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,QAAiC,GACxC,MAAM;IAYF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAKnD"}
@@ -0,0 +1,25 @@
1
+ import { Mutant } from '../mutant.js';
2
+ export class MutantCollector {
3
+ _mutants = [];
4
+ get mutants() {
5
+ return this._mutants;
6
+ }
7
+ /**
8
+ * Adds mutants to the internal mutant list.
9
+ * @param fileName file name that houses the mutant
10
+ * @param original The node to mutate
11
+ * @param mutables the named node mutation to be added
12
+ * @param contextPath the context where these mutants are found and should be placed as close by as possible
13
+ * @param offset offset of mutant nodes
14
+ * @returns The mutant (for testability)
15
+ */
16
+ collect(fileName, original, mutable, offset = { line: 0, column: 0 }) {
17
+ const mutant = new Mutant(this._mutants.length.toString(), fileName, original, mutable, offset);
18
+ this._mutants.push(mutant);
19
+ return mutant;
20
+ }
21
+ hasPlacedMutants(fileName) {
22
+ return this.mutants.some((mutant) => mutant.fileName === fileName && !mutant.ignoreReason);
23
+ }
24
+ }
25
+ //# sourceMappingURL=mutant-collector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutant-collector.js","sourceRoot":"","sources":["../../../src/transformers/mutant-collector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAW,MAAM,cAAc,CAAC;AAE/C,MAAM,OAAO,eAAe;IACT,QAAQ,GAAa,EAAE,CAAC;IAEzC,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACI,OAAO,CACZ,QAAgB,EAChB,QAAoB,EACpB,OAAgB,EAChB,SAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAEzC,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,CACP,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,gBAAgB,CAAC,QAAgB;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,CACjE,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { AstFormat } from '../syntax/index.js';
2
+ import { AstTransformer } from './transformer.js';
3
+ export declare const transformSvelte: AstTransformer<AstFormat.Svelte>;
4
+ //# sourceMappingURL=svelte-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte-transformer.d.ts","sourceRoot":"","sources":["../../../src/transformers/svelte-transformer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,SAAS,CAAC,MAAM,CA4C5D,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { notEmpty } from '@stryker-mutator/util';
2
+ import { types } from '@babel/core';
3
+ import { AstFormat } from '../syntax/index.js';
4
+ import { placeHeader } from '../util/syntax-helpers.js';
5
+ const moduleScriptStart = '<script context="module">\n';
6
+ const moduleScript = `${moduleScriptStart}\n</script>\n`;
7
+ export const transformSvelte = (svelte, mutantCollector, context) => {
8
+ const { root, originFileName } = svelte;
9
+ [root.moduleScript, ...root.additionalScripts]
10
+ .filter(notEmpty)
11
+ .forEach((script) => {
12
+ context.transform(script.ast, mutantCollector, {
13
+ ...context,
14
+ options: {
15
+ ...context.options,
16
+ noHeader: true,
17
+ },
18
+ });
19
+ });
20
+ if (mutantCollector.hasPlacedMutants(originFileName)) {
21
+ // We need to place the instrumentation header inside the `<script context="module">` script
22
+ // If there already is a module script, place it there. If not, we need to add it.
23
+ if (!root.moduleScript) {
24
+ root.moduleScript = {
25
+ ast: {
26
+ format: AstFormat.JS,
27
+ root: types.file(types.program([])),
28
+ rawContent: '',
29
+ originFileName,
30
+ },
31
+ range: {
32
+ start: moduleScriptStart.length,
33
+ end: moduleScriptStart.length,
34
+ },
35
+ isExpression: false,
36
+ };
37
+ svelte.rawContent = `${moduleScript}${svelte.rawContent}`;
38
+ svelte.root.additionalScripts.forEach((script) => {
39
+ script.range.start += moduleScript.length;
40
+ script.range.end += moduleScript.length;
41
+ });
42
+ }
43
+ placeHeader(root.moduleScript.ast.root);
44
+ }
45
+ };
46
+ //# sourceMappingURL=svelte-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte-transformer.js","sourceRoot":"","sources":["../../../src/transformers/svelte-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AACxD,MAAM,YAAY,GAAG,GAAG,iBAAiB,eAAe,CAAC;AAEzD,MAAM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C,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Ignorer } from '@stryker-mutator/api/ignore';
2
+ import { MutatorOptions } from '../mutators/index.js';
3
+ export interface TransformerOptions extends MutatorOptions {
4
+ ignorers: Ignorer[];
5
+ }
6
+ //# sourceMappingURL=transformer-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer-options.d.ts","sourceRoot":"","sources":["../../../src/transformers/transformer-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transformer-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer-options.js","sourceRoot":"","sources":["../../../src/transformers/transformer-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { MutateDescription } from '@stryker-mutator/api/core';
2
+ import { I } from '@stryker-mutator/util';
3
+ import { Logger } from '@stryker-mutator/api/logging';
4
+ import { Ast, AstByFormat, AstFormat } from '../syntax/index.js';
5
+ import { TransformerOptions } from './transformer-options.js';
6
+ import { MutantCollector } from './mutant-collector.js';
7
+ /**
8
+ * Transform the AST by generating mutants and placing them in the AST.
9
+ * Supports all AST formats supported by Stryker.
10
+ * @param ast The Abstract Syntax Tree
11
+ * @param mutantCollector the mutant collector that will be used to register and administer mutants
12
+ * @param transformerContext the options used during transforming
13
+ */
14
+ export declare function transform(ast: Ast, mutantCollector: I<MutantCollector>, transformerContext: Omit<TransformerContext, 'transform'>): void;
15
+ export type AstTransformer<T extends AstFormat> = (ast: AstByFormat[T], mutantCollector: I<MutantCollector>, context: TransformerContext) => void;
16
+ export interface TransformerContext {
17
+ transform: AstTransformer<AstFormat>;
18
+ options: TransformerOptions;
19
+ mutateDescription: MutateDescription;
20
+ logger: Logger;
21
+ }
22
+ //# sourceMappingURL=transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/transformers/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,CAAC,CAAC,eAAe,CAAC,EACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GACxD,IAAI,CAiBN;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,IAAI,CAChD,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,eAAe,EAAE,CAAC,CAAC,eAAe,CAAC,EACnC,OAAO,EAAE,kBAAkB,KACxB,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACrC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,30 @@
1
+ import { AstFormat } from '../syntax/index.js';
2
+ import { transformBabel } from './babel-transformer.js';
3
+ import { transformHtml } from './html-transformer.js';
4
+ import { transformSvelte } from './svelte-transformer.js';
5
+ /**
6
+ * Transform the AST by generating mutants and placing them in the AST.
7
+ * Supports all AST formats supported by Stryker.
8
+ * @param ast The Abstract Syntax Tree
9
+ * @param mutantCollector the mutant collector that will be used to register and administer mutants
10
+ * @param transformerContext the options used during transforming
11
+ */
12
+ export function transform(ast, mutantCollector, transformerContext) {
13
+ const context = {
14
+ ...transformerContext,
15
+ transform,
16
+ };
17
+ switch (ast.format) {
18
+ case AstFormat.Html:
19
+ transformHtml(ast, mutantCollector, context);
20
+ break;
21
+ case AstFormat.JS:
22
+ case AstFormat.TS:
23
+ case AstFormat.Tsx:
24
+ transformBabel(ast, mutantCollector, context);
25
+ break;
26
+ case AstFormat.Svelte:
27
+ transformSvelte(ast, mutantCollector, context);
28
+ }
29
+ }
30
+ //# sourceMappingURL=transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../src/transformers/transformer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,GAAQ,EACR,eAAmC,EACnC,kBAAyD;IAEzD,MAAM,OAAO,GAAuB;QAClC,GAAG,kBAAkB;QACrB,SAAS;KACV,CAAC;IACF,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,SAAS,CAAC,IAAI;YACjB,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM;QACR,KAAK,SAAS,CAAC,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC,GAAG;YAChB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM;QACR,KAAK,SAAS,CAAC,MAAM;YACnB,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type BinaryOperator = '-' | '!=' | '!==' | '*' | '**' | '/' | '&' | '%' | '^' | '+' | '<' | '<<' | '<=' | '==' | '===' | '>' | '>=' | '>>' | '>>>' | '|' | 'in' | 'instanceof';
2
+ //# sourceMappingURL=binary-operator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-operator.d.ts","sourceRoot":"","sources":["../../../src/util/binary-operator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,GAAG,GACH,IAAI,GACJ,KAAK,GACL,GAAG,GACH,IAAI,GACJ,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,GAAG,GACH,IAAI,GACJ,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=binary-operator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-operator.js","sourceRoot":"","sources":["../../../src/util/binary-operator.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from './syntax-helpers.js';
2
+ export * from './binary-operator.js';
3
+ export * from './position-converter.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './syntax-helpers.js';
2
+ export * from './binary-operator.js';
3
+ export * from './position-converter.js';
4
+ //# sourceMappingURL=index.js.map