loadwise 0.0.0-stage → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (804) hide show
  1. package/LICENSE +201 -0
  2. package/PERFORMANCE.md +110 -0
  3. package/README.md +1429 -2
  4. package/bin/github-action.js +58 -0
  5. package/bin/loadwise.js +98 -0
  6. package/editor/README.md +47 -0
  7. package/editor/accessibility-examples.cjs +90 -0
  8. package/editor/apply-fix.cjs +187 -0
  9. package/editor/control-flow-comparison.cjs +133 -0
  10. package/editor/finding-comparison.cjs +77 -0
  11. package/editor/maintainability-examples.cjs +229 -0
  12. package/editor/perf-site-comparison.cjs +85 -0
  13. package/editor/performance-examples.cjs +438 -0
  14. package/editor/reliability-examples.cjs +77 -0
  15. package/editor/security-examples.cjs +59 -0
  16. package/editor/source-example.cjs +66 -0
  17. package/editor/standalone-performance-examples.cjs +487 -0
  18. package/examples/indexed.ts +19 -0
  19. package/examples/labels.py +6 -0
  20. package/examples/mongo-plan.json +8 -0
  21. package/examples/postgres-plan.json +10 -0
  22. package/examples/query-policy.json +24 -0
  23. package/examples/redis-keys.otlp.json +22 -0
  24. package/examples/repeated-db.otlp.json +73 -0
  25. package/examples/slow.ts +10 -0
  26. package/examples/tsconfig.json +4 -0
  27. package/lib/accessibility/analyze.js +26 -0
  28. package/lib/accessibility/angular-inline.js +43 -0
  29. package/lib/accessibility/aria-tables.js +231 -0
  30. package/lib/accessibility/cli.js +11 -0
  31. package/lib/accessibility/frontend-detect.js +98 -0
  32. package/lib/accessibility/jsx-elements.js +110 -0
  33. package/lib/accessibility/markup-files.js +41 -0
  34. package/lib/accessibility/markup.js +24 -0
  35. package/lib/accessibility/rule-ids.js +36 -0
  36. package/lib/accessibility/rules.js +293 -0
  37. package/lib/accessibility/site-fixes/buttons.js +35 -0
  38. package/lib/accessibility/template-attributes.js +137 -0
  39. package/lib/accessibility/template-elements.js +434 -0
  40. package/lib/accessibility/template-file.js +183 -0
  41. package/lib/accessibility/usage.js +12 -0
  42. package/lib/maintainability/advisory-context.js +182 -0
  43. package/lib/maintainability/analyze-source.js +93 -0
  44. package/lib/maintainability/ancestor-aliases.js +35 -0
  45. package/lib/maintainability/apply-fix.js +85 -0
  46. package/lib/maintainability/architecture-nest.js +103 -0
  47. package/lib/maintainability/architecture.js +482 -0
  48. package/lib/maintainability/branch-advice.js +135 -0
  49. package/lib/maintainability/changed-lines.js +135 -0
  50. package/lib/maintainability/changed-output.js +21 -0
  51. package/lib/maintainability/checklist-context.js +74 -0
  52. package/lib/maintainability/child-buffer.js +20 -0
  53. package/lib/maintainability/cli.js +410 -0
  54. package/lib/maintainability/config-entry-points.js +86 -0
  55. package/lib/maintainability/data-access.js +153 -0
  56. package/lib/maintainability/deprecated-apis.js +170 -0
  57. package/lib/maintainability/docker-entry-points.js +98 -0
  58. package/lib/maintainability/duplicates.js +326 -0
  59. package/lib/maintainability/entry-points.js +603 -0
  60. package/lib/maintainability/examples.js +122 -0
  61. package/lib/maintainability/finding-ids.js +46 -0
  62. package/lib/maintainability/fix-cli.js +235 -0
  63. package/lib/maintainability/fix-text.js +11 -0
  64. package/lib/maintainability/functions.js +315 -0
  65. package/lib/maintainability/graph.js +186 -0
  66. package/lib/maintainability/html-entry-points.js +75 -0
  67. package/lib/maintainability/inputs.js +231 -0
  68. package/lib/maintainability/layout.js +56 -0
  69. package/lib/maintainability/limits.js +3 -0
  70. package/lib/maintainability/mocha-entry-points.js +88 -0
  71. package/lib/maintainability/modifiers.js +6 -0
  72. package/lib/maintainability/module-usage-dynamic.js +175 -0
  73. package/lib/maintainability/module-usage.js +574 -0
  74. package/lib/maintainability/notify-editor.js +1 -0
  75. package/lib/maintainability/operator-references.js +84 -0
  76. package/lib/maintainability/polyglot-duplicates.js +121 -0
  77. package/lib/maintainability/polyglot.js +173 -0
  78. package/lib/maintainability/project.js +116 -0
  79. package/lib/maintainability/review-directive.js +91 -0
  80. package/lib/maintainability/rule-ids.js +67 -0
  81. package/lib/maintainability/runtime-directories.js +22 -0
  82. package/lib/maintainability/scan-changed.js +67 -0
  83. package/lib/maintainability/scan-worker.js +38 -0
  84. package/lib/maintainability/scan.js +238 -0
  85. package/lib/maintainability/site-fix.js +221 -0
  86. package/lib/maintainability/site-fixes/boolean-returns.js +79 -0
  87. package/lib/maintainability/site-fixes/branches.js +418 -0
  88. package/lib/maintainability/site-fixes/control-flow.js +67 -0
  89. package/lib/maintainability/site-fixes/cycles.js +101 -0
  90. package/lib/maintainability/site-fixes/deprecated-apis.js +67 -0
  91. package/lib/maintainability/site-fixes/duplicate-arrows.js +343 -0
  92. package/lib/maintainability/site-fixes/duplicate-bindings.js +149 -0
  93. package/lib/maintainability/site-fixes/duplicate-edits.js +396 -0
  94. package/lib/maintainability/site-fixes/duplicate-methods.js +407 -0
  95. package/lib/maintainability/site-fixes/duplicates.js +125 -0
  96. package/lib/maintainability/site-fixes/exports.js +25 -0
  97. package/lib/maintainability/site-fixes/extract-block-ast.js +130 -0
  98. package/lib/maintainability/site-fixes/extract-block-edits.js +156 -0
  99. package/lib/maintainability/site-fixes/extract-block-flow.js +265 -0
  100. package/lib/maintainability/site-fixes/extract-block-measure.js +131 -0
  101. package/lib/maintainability/site-fixes/extract-block-naming.js +164 -0
  102. package/lib/maintainability/site-fixes/extract-block-narrowing.js +141 -0
  103. package/lib/maintainability/site-fixes/extract-block.js +38 -0
  104. package/lib/maintainability/site-fixes/helpers.js +308 -0
  105. package/lib/maintainability/site-fixes/if-rewrites.js +468 -0
  106. package/lib/maintainability/site-fixes/isolated-program.js +85 -0
  107. package/lib/maintainability/site-fixes/large-module.js +175 -0
  108. package/lib/maintainability/site-fixes/parameters.js +460 -0
  109. package/lib/maintainability/site-fixes/stray-console.js +21 -0
  110. package/lib/maintainability/site-fixes/unused-bindings.js +158 -0
  111. package/lib/maintainability/size-limits.js +94 -0
  112. package/lib/maintainability/snapshot-context.js +63 -0
  113. package/lib/maintainability/source-exclusions.js +68 -0
  114. package/lib/maintainability/source-facts.js +39 -0
  115. package/lib/maintainability/stray-console.js +352 -0
  116. package/lib/maintainability/traversal-context.js +76 -0
  117. package/lib/maintainability/types/changed-lines.js +1 -0
  118. package/lib/maintainability/types/created-module.js +1 -0
  119. package/lib/maintainability/types/duplicate-sites.js +1 -0
  120. package/lib/maintainability/types/duplicates.js +1 -0
  121. package/lib/maintainability/types/entry-points.js +1 -0
  122. package/lib/maintainability/types/extract-block.js +1 -0
  123. package/lib/maintainability/types/extraction-drafts.js +1 -0
  124. package/lib/maintainability/types/finding-comparison.js +1 -0
  125. package/lib/maintainability/types/fix-files.js +1 -0
  126. package/lib/maintainability/types/module-graph.js +1 -0
  127. package/lib/maintainability/types/module-resolver.js +1 -0
  128. package/lib/maintainability/types/module-usage.js +1 -0
  129. package/lib/maintainability/types/policy.js +1 -0
  130. package/lib/maintainability/types/polyglot-scan.js +1 -0
  131. package/lib/maintainability/types/scan-report.js +1 -0
  132. package/lib/maintainability/types/scan-worker.js +1 -0
  133. package/lib/maintainability/types/site-fix-edits.js +1 -0
  134. package/lib/maintainability/types/site-fix-loader.js +1 -0
  135. package/lib/maintainability/types/site-fix-nodes.js +1 -0
  136. package/lib/maintainability/types/source-analysis.js +1 -0
  137. package/lib/maintainability/types/source-facts.js +1 -0
  138. package/lib/maintainability/types/typescript-jsdoc-internals.js +1 -0
  139. package/lib/maintainability/types/typescript-site-fix-internals.js +1 -0
  140. package/lib/maintainability/unused-bindings.js +182 -0
  141. package/lib/maintainability/unused-modules.js +258 -0
  142. package/lib/maintainability/verified-private-types.js +142 -0
  143. package/lib/maintainability/walk.js +17 -0
  144. package/lib/maintainability/workflow-entry-points.js +83 -0
  145. package/lib/performance/analyze.js +251 -0
  146. package/lib/performance/async-errors.js +190 -0
  147. package/lib/performance/await-before-early-exit.js +176 -0
  148. package/lib/performance/awaits.js +70 -0
  149. package/lib/performance/backend-mastery.js +444 -0
  150. package/lib/performance/cache-reads.js +170 -0
  151. package/lib/performance/call-syntax.js +27 -0
  152. package/lib/performance/cartesian-includes.js +364 -0
  153. package/lib/performance/changed-lines.js +141 -0
  154. package/lib/performance/cli-arguments.js +61 -0
  155. package/lib/performance/cli-output.js +175 -0
  156. package/lib/performance/cli-policy.js +79 -0
  157. package/lib/performance/cli-scan.js +419 -0
  158. package/lib/performance/cli-types.js +1 -0
  159. package/lib/performance/cli.js +120 -0
  160. package/lib/performance/collection-bindings.js +283 -0
  161. package/lib/performance/collection-bounds.js +247 -0
  162. package/lib/performance/collection-copy.js +169 -0
  163. package/lib/performance/collection-lookups.js +432 -0
  164. package/lib/performance/collection-reduce.js +340 -0
  165. package/lib/performance/collections.js +25 -0
  166. package/lib/performance/compiler.js +52 -0
  167. package/lib/performance/contracts/cli.js +230 -0
  168. package/lib/performance/contracts/dto.js +244 -0
  169. package/lib/performance/contracts/git-files.js +37 -0
  170. package/lib/performance/contracts/graphql.js +360 -0
  171. package/lib/performance/contracts/openapi.js +363 -0
  172. package/lib/performance/db/checks.js +398 -0
  173. package/lib/performance/db/cli-format.js +9 -0
  174. package/lib/performance/db/cli-mysql.js +82 -0
  175. package/lib/performance/db/cli.js +469 -0
  176. package/lib/performance/db/drivers.js +241 -0
  177. package/lib/performance/db/gateway.js +194 -0
  178. package/lib/performance/db/hypopg.js +52 -0
  179. package/lib/performance/db/measure.js +141 -0
  180. package/lib/performance/db/mongo.js +272 -0
  181. package/lib/performance/db/mysql-catalog.js +64 -0
  182. package/lib/performance/db/pg-catalog.js +114 -0
  183. package/lib/performance/db/plan-estimates.js +188 -0
  184. package/lib/performance/db/redact.js +126 -0
  185. package/lib/performance/db/snapshot.js +82 -0
  186. package/lib/performance/dependent-writes.js +228 -0
  187. package/lib/performance/discarded-error-result.js +46 -0
  188. package/lib/performance/drizzle-write-preflight.js +195 -0
  189. package/lib/performance/drizzle.js +288 -0
  190. package/lib/performance/editor-report.js +191 -0
  191. package/lib/performance/editor-setup.js +189 -0
  192. package/lib/performance/editor-signal.js +57 -0
  193. package/lib/performance/editor-watch-supervisor.js +104 -0
  194. package/lib/performance/editor-watch.js +193 -0
  195. package/lib/performance/emit-options.js +29 -0
  196. package/lib/performance/filter-existence.js +149 -0
  197. package/lib/performance/find-then-create.js +281 -0
  198. package/lib/performance/finding-ids.js +48 -0
  199. package/lib/performance/finding-text.js +117 -0
  200. package/lib/performance/fix-cli.js +200 -0
  201. package/lib/performance/floating-promises.js +248 -0
  202. package/lib/performance/frontend-dom-perf.js +310 -0
  203. package/lib/performance/frontend-helpers.js +93 -0
  204. package/lib/performance/frontend-perf.js +472 -0
  205. package/lib/performance/function-kinds.js +9 -0
  206. package/lib/performance/guard-queries.js +356 -0
  207. package/lib/performance/http-timeouts.js +492 -0
  208. package/lib/performance/impact.js +53 -0
  209. package/lib/performance/index-rules-foreign-keys.js +81 -0
  210. package/lib/performance/index-rules-order.js +152 -0
  211. package/lib/performance/index-rules-pattern.js +137 -0
  212. package/lib/performance/index-rules-table.js +288 -0
  213. package/lib/performance/index-rules.js +107 -0
  214. package/lib/performance/json-clone.js +28 -0
  215. package/lib/performance/json-parse-context.js +99 -0
  216. package/lib/performance/last-insert-id.js +120 -0
  217. package/lib/performance/list-counts.js +321 -0
  218. package/lib/performance/list-overfetch.js +216 -0
  219. package/lib/performance/literal-awaits.js +190 -0
  220. package/lib/performance/memory-growth.js +516 -0
  221. package/lib/performance/migrations/cli.js +203 -0
  222. package/lib/performance/migrations/discover.js +354 -0
  223. package/lib/performance/migrations/enforce.js +177 -0
  224. package/lib/performance/migrations/extract-code-builders.js +291 -0
  225. package/lib/performance/migrations/extract-code-discovery.js +179 -0
  226. package/lib/performance/migrations/extract-code-sql.js +196 -0
  227. package/lib/performance/migrations/extract-code-types.js +1 -0
  228. package/lib/performance/migrations/extract-code.js +123 -0
  229. package/lib/performance/migrations/extract-sql.js +452 -0
  230. package/lib/performance/migrations/operations.js +156 -0
  231. package/lib/performance/migrations/postgres-registry.js +135 -0
  232. package/lib/performance/migrations/rules-mysql.js +105 -0
  233. package/lib/performance/migrations/rules-postgres-add-column.js +145 -0
  234. package/lib/performance/migrations/rules-postgres-shared.js +22 -0
  235. package/lib/performance/migrations/rules-postgres.js +464 -0
  236. package/lib/performance/missing-packages.js +116 -0
  237. package/lib/performance/models/index.js +284 -0
  238. package/lib/performance/mongoose-patterns.js +245 -0
  239. package/lib/performance/native-checker.js +312 -0
  240. package/lib/performance/native-runtime.js +24 -0
  241. package/lib/performance/native-syntax.js +132 -0
  242. package/lib/performance/native-workspaces.js +31 -0
  243. package/lib/performance/native.js +342 -0
  244. package/lib/performance/node-fs-context.js +390 -0
  245. package/lib/performance/node-fs.js +452 -0
  246. package/lib/performance/notification-loops.js +176 -0
  247. package/lib/performance/notify-editor.js +1 -0
  248. package/lib/performance/offset-pagination.js +166 -0
  249. package/lib/performance/orm-owners.js +145 -0
  250. package/lib/performance/orm-queries.js +496 -0
  251. package/lib/performance/package-types.js +57 -0
  252. package/lib/performance/page-counts.js +262 -0
  253. package/lib/performance/parallel-reads-policy.js +41 -0
  254. package/lib/performance/parallel-reads.js +139 -0
  255. package/lib/performance/password-hashing.js +218 -0
  256. package/lib/performance/pg-fragments.js +300 -0
  257. package/lib/performance/pg-integrity.js +115 -0
  258. package/lib/performance/phase5-rules.js +539 -0
  259. package/lib/performance/plans.js +283 -0
  260. package/lib/performance/polyglot.js +193 -0
  261. package/lib/performance/pooling.js +200 -0
  262. package/lib/performance/postgres.js +182 -0
  263. package/lib/performance/prisma-aggregates.js +125 -0
  264. package/lib/performance/prisma-integrity.js +239 -0
  265. package/lib/performance/prisma.js +399 -0
  266. package/lib/performance/projects.js +431 -0
  267. package/lib/performance/promise-return-escapes-catch.js +96 -0
  268. package/lib/performance/pure-js-hashing.js +96 -0
  269. package/lib/performance/query-loop-batch.js +188 -0
  270. package/lib/performance/query-loop-bounds.js +219 -0
  271. package/lib/performance/query-loop-exits.js +171 -0
  272. package/lib/performance/query-loop-helpers.js +42 -0
  273. package/lib/performance/query-loop-memo.js +81 -0
  274. package/lib/performance/query-loop-pagination.js +130 -0
  275. package/lib/performance/query-loops.js +29 -0
  276. package/lib/performance/query-policy.js +94 -0
  277. package/lib/performance/query-results.js +179 -0
  278. package/lib/performance/queue-loops.js +87 -0
  279. package/lib/performance/recursive-watch.js +181 -0
  280. package/lib/performance/redis-client.js +19 -0
  281. package/lib/performance/redis-keys.js +78 -0
  282. package/lib/performance/redis.js +188 -0
  283. package/lib/performance/redundant-indexes.js +403 -0
  284. package/lib/performance/reference-checks.js +22 -0
  285. package/lib/performance/repeated.js +200 -0
  286. package/lib/performance/request-handlers.js +429 -0
  287. package/lib/performance/request-heavy-work.js +135 -0
  288. package/lib/performance/request-inputs.js +303 -0
  289. package/lib/performance/retry-backoff.js +132 -0
  290. package/lib/performance/return-in-finally.js +12 -0
  291. package/lib/performance/return-newline.js +54 -0
  292. package/lib/performance/review-context.js +434 -0
  293. package/lib/performance/rule-ids.js +357 -0
  294. package/lib/performance/scan-outcome.js +37 -0
  295. package/lib/performance/schema/context.js +145 -0
  296. package/lib/performance/schema/drizzle-schema.js +278 -0
  297. package/lib/performance/schema/model.js +169 -0
  298. package/lib/performance/schema/mongoose-schema.js +189 -0
  299. package/lib/performance/schema/prisma-schema.js +472 -0
  300. package/lib/performance/schema/project-indexes-events.js +494 -0
  301. package/lib/performance/schema/project-indexes.js +240 -0
  302. package/lib/performance/schema/query-site-support.js +61 -0
  303. package/lib/performance/schema/query-sites-drizzle.js +220 -0
  304. package/lib/performance/schema/query-sites-mongoose.js +140 -0
  305. package/lib/performance/schema/query-sites-prisma.js +201 -0
  306. package/lib/performance/schema/query-sites-sequelize.js +133 -0
  307. package/lib/performance/schema/query-sites-typeorm.js +180 -0
  308. package/lib/performance/schema/query-sites.js +19 -0
  309. package/lib/performance/schema/raw-sql-sites.js +284 -0
  310. package/lib/performance/schema/sequelize-schema.js +322 -0
  311. package/lib/performance/schema/ts-helpers.js +130 -0
  312. package/lib/performance/schema/typeorm-schema.js +262 -0
  313. package/lib/performance/schema-tooling.js +193 -0
  314. package/lib/performance/scope-evidence.js +137 -0
  315. package/lib/performance/sequential-loops.js +557 -0
  316. package/lib/performance/service-call-resolution.js +54 -0
  317. package/lib/performance/service-loop-collections.js +263 -0
  318. package/lib/performance/service-loop-operations.js +235 -0
  319. package/lib/performance/service-loops.js +416 -0
  320. package/lib/performance/session-store.js +86 -0
  321. package/lib/performance/site-fix.js +271 -0
  322. package/lib/performance/site-fixes/await-before-early-exit.js +121 -0
  323. package/lib/performance/site-fixes/backend-mastery-fixes.js +90 -0
  324. package/lib/performance/site-fixes/batch-loops.js +449 -0
  325. package/lib/performance/site-fixes/collection-copy.js +310 -0
  326. package/lib/performance/site-fixes/collection-existence.js +200 -0
  327. package/lib/performance/site-fixes/collection-find.js +195 -0
  328. package/lib/performance/site-fixes/collection-helpers.js +349 -0
  329. package/lib/performance/site-fixes/collection-lookup-declarations.js +47 -0
  330. package/lib/performance/site-fixes/collection-lookups.js +101 -0
  331. package/lib/performance/site-fixes/collection-membership.js +124 -0
  332. package/lib/performance/site-fixes/collections.js +18 -0
  333. package/lib/performance/site-fixes/database.js +455 -0
  334. package/lib/performance/site-fixes/delete-preflight.js +99 -0
  335. package/lib/performance/site-fixes/drizzle-index.js +239 -0
  336. package/lib/performance/site-fixes/error-handling.js +99 -0
  337. package/lib/performance/site-fixes/frontend-fixes.js +193 -0
  338. package/lib/performance/site-fixes/guard-queries.js +172 -0
  339. package/lib/performance/site-fixes/helpers.js +200 -0
  340. package/lib/performance/site-fixes/hoisting.js +155 -0
  341. package/lib/performance/site-fixes/http-timeouts.js +56 -0
  342. package/lib/performance/site-fixes/indexes.js +454 -0
  343. package/lib/performance/site-fixes/integrity-drizzle.js +188 -0
  344. package/lib/performance/site-fixes/integrity-wrap.js +45 -0
  345. package/lib/performance/site-fixes/integrity.js +555 -0
  346. package/lib/performance/site-fixes/json-parse.js +114 -0
  347. package/lib/performance/site-fixes/last-insert-id.js +230 -0
  348. package/lib/performance/site-fixes/list-queries.js +164 -0
  349. package/lib/performance/site-fixes/literal-awaits.js +431 -0
  350. package/lib/performance/site-fixes/method-calls.js +6 -0
  351. package/lib/performance/site-fixes/migration-column-rules.js +208 -0
  352. package/lib/performance/site-fixes/migration-context.js +317 -0
  353. package/lib/performance/site-fixes/migration-lock-rules.js +204 -0
  354. package/lib/performance/site-fixes/migration-placement.js +252 -0
  355. package/lib/performance/site-fixes/migrations.js +34 -0
  356. package/lib/performance/site-fixes/page-counts.js +88 -0
  357. package/lib/performance/site-fixes/prisma-aggregates.js +455 -0
  358. package/lib/performance/site-fixes/promise-catch.js +147 -0
  359. package/lib/performance/site-fixes/pure-js-hashing.js +68 -0
  360. package/lib/performance/site-fixes/query-loop-collections.js +202 -0
  361. package/lib/performance/site-fixes/query-loop-lookups.js +98 -0
  362. package/lib/performance/site-fixes/query-loop-materialization.js +279 -0
  363. package/lib/performance/site-fixes/query-loop-names.js +35 -0
  364. package/lib/performance/site-fixes/query-loop-nodes.js +162 -0
  365. package/lib/performance/site-fixes/query-loop-pg-redis.js +203 -0
  366. package/lib/performance/site-fixes/query-loop-prisma.js +304 -0
  367. package/lib/performance/site-fixes/query-loop-sites.js +317 -0
  368. package/lib/performance/site-fixes/query-loop-typeorm.js +294 -0
  369. package/lib/performance/site-fixes/query-loops.js +57 -0
  370. package/lib/performance/site-fixes/query-shapes.js +573 -0
  371. package/lib/performance/site-fixes/queue-loops.js +231 -0
  372. package/lib/performance/site-fixes/redis-keys.js +213 -0
  373. package/lib/performance/site-fixes/scope-names.js +30 -0
  374. package/lib/performance/site-fixes/service-loop-ast.js +85 -0
  375. package/lib/performance/site-fixes/service-loop-callee.js +57 -0
  376. package/lib/performance/site-fixes/service-loop-concurrent.js +88 -0
  377. package/lib/performance/site-fixes/service-loop-imports.js +68 -0
  378. package/lib/performance/site-fixes/service-loop-read-batch.js +255 -0
  379. package/lib/performance/site-fixes/service-loop-siblings.js +170 -0
  380. package/lib/performance/site-fixes/service-loop-signature.js +33 -0
  381. package/lib/performance/site-fixes/service-loop-sites.js +141 -0
  382. package/lib/performance/site-fixes/service-loop-write-batch.js +94 -0
  383. package/lib/performance/site-fixes/service-loops.js +153 -0
  384. package/lib/performance/site-fixes/small-rewrites.js +210 -0
  385. package/lib/performance/site-fixes/streams.js +150 -0
  386. package/lib/performance/site-fixes/sync-calls.js +485 -0
  387. package/lib/performance/site-fixes/sync-imports.js +170 -0
  388. package/lib/performance/site-fixes/transaction-escape.js +40 -0
  389. package/lib/performance/site-fixes/transaction-io.js +280 -0
  390. package/lib/performance/site-fixes/typeorm-updates.js +277 -0
  391. package/lib/performance/site-fixes/typeorm.js +239 -0
  392. package/lib/performance/site-fixes/types/module-binding.js +1 -0
  393. package/lib/performance/site-fixes/upload-limits.js +74 -0
  394. package/lib/performance/site-fixes/workbook-decodes.js +254 -0
  395. package/lib/performance/site-fixes/writes.js +342 -0
  396. package/lib/performance/sort-extreme.js +142 -0
  397. package/lib/performance/source-inputs.js +71 -0
  398. package/lib/performance/source-options.js +103 -0
  399. package/lib/performance/source-pillars.js +23 -0
  400. package/lib/performance/source-text.js +59 -0
  401. package/lib/performance/span-timing.js +54 -0
  402. package/lib/performance/sql/locations.js +91 -0
  403. package/lib/performance/sql/mysql-tokens.js +393 -0
  404. package/lib/performance/sql/pg-parser.js +330 -0
  405. package/lib/performance/stream-errors.js +650 -0
  406. package/lib/performance/traces.js +363 -0
  407. package/lib/performance/transaction-io.js +427 -0
  408. package/lib/performance/typeorm-projection.js +261 -0
  409. package/lib/performance/typeorm-transaction-loops.js +143 -0
  410. package/lib/performance/typeorm-unused-count.js +36 -0
  411. package/lib/performance/typeorm-updates.js +268 -0
  412. package/lib/performance/types/ast-grep-match.js +2 -0
  413. package/lib/performance/types/batch-plan.js +1 -0
  414. package/lib/performance/types/batched-fix-input.js +1 -0
  415. package/lib/performance/types/call-site.js +1 -0
  416. package/lib/performance/types/callee-helper.js +1 -0
  417. package/lib/performance/types/client-family.js +1 -0
  418. package/lib/performance/types/collections.js +1 -0
  419. package/lib/performance/types/contract-findings.js +3 -0
  420. package/lib/performance/types/db-cli.js +1 -0
  421. package/lib/performance/types/db-connection.js +1 -0
  422. package/lib/performance/types/db-model.js +3 -0
  423. package/lib/performance/types/db-plan-findings.js +1 -0
  424. package/lib/performance/types/db-plan.js +2 -0
  425. package/lib/performance/types/db-snapshot.js +1 -0
  426. package/lib/performance/types/declaration-link.js +2 -0
  427. package/lib/performance/types/decorator-call.js +1 -0
  428. package/lib/performance/types/drizzle-query.js +1 -0
  429. package/lib/performance/types/editor-report.js +1 -0
  430. package/lib/performance/types/find-lookup-facts.js +3 -0
  431. package/lib/performance/types/helper-function.js +1 -0
  432. package/lib/performance/types/hoist-anchor.js +1 -0
  433. package/lib/performance/types/http-call.js +1 -0
  434. package/lib/performance/types/lookup-construction.js +1 -0
  435. package/lib/performance/types/lookup-placement.js +1 -0
  436. package/lib/performance/types/loop-key-site.js +1 -0
  437. package/lib/performance/types/loop-lookup.js +1 -0
  438. package/lib/performance/types/method-call.js +1 -0
  439. package/lib/performance/types/migration-extraction.js +1 -0
  440. package/lib/performance/types/migration-files.js +1 -0
  441. package/lib/performance/types/migration-operations.js +1 -0
  442. package/lib/performance/types/migrations.js +1 -0
  443. package/lib/performance/types/model-fallback.js +2 -0
  444. package/lib/performance/types/mysql-statements.js +2 -0
  445. package/lib/performance/types/native-modules.js +1 -0
  446. package/lib/performance/types/native-typescript.js +1 -0
  447. package/lib/performance/types/otlp-attributes.js +1 -0
  448. package/lib/performance/types/otlp-trace.js +1 -0
  449. package/lib/performance/types/page-count-pair.js +1 -0
  450. package/lib/performance/types/parallel-reads.js +1 -0
  451. package/lib/performance/types/performance-policy.js +1 -0
  452. package/lib/performance/types/pg-statements.js +1 -0
  453. package/lib/performance/types/plain-property.js +1 -0
  454. package/lib/performance/types/postgres-registry.js +1 -0
  455. package/lib/performance/types/prisma-schema.js +1 -0
  456. package/lib/performance/types/program-scan.js +1 -0
  457. package/lib/performance/types/project-indexes.js +1 -0
  458. package/lib/performance/types/query-loops.js +1 -0
  459. package/lib/performance/types/query-site.js +1 -0
  460. package/lib/performance/types/related-location.js +2 -0
  461. package/lib/performance/types/repeat-owner.js +1 -0
  462. package/lib/performance/types/request-handler.js +1 -0
  463. package/lib/performance/types/request-input.js +1 -0
  464. package/lib/performance/types/schema-model.js +3 -0
  465. package/lib/performance/types/sibling-declaration.js +1 -0
  466. package/lib/performance/types/source-analyzer.js +1 -0
  467. package/lib/performance/types/source-check-values.js +1 -0
  468. package/lib/performance/types/source-command.js +1 -0
  469. package/lib/performance/types/source-position.js +2 -0
  470. package/lib/performance/types/source-scan-values.js +1 -0
  471. package/lib/performance/types/statement-range.js +2 -0
  472. package/lib/performance/types/typeorm-save-shape.js +1 -0
  473. package/lib/performance/types/typescript-binder.js +1 -0
  474. package/lib/performance/types/typescript-token-lookup.js +1 -0
  475. package/lib/performance/types/typescript-token-position.js +1 -0
  476. package/lib/performance/unbounded-list-queries.js +600 -0
  477. package/lib/performance/unscanned-javascript.js +29 -0
  478. package/lib/performance/upload-limits.js +68 -0
  479. package/lib/performance/vendor/README.md +7 -0
  480. package/lib/performance/vendor/typescript/LICENSE +55 -0
  481. package/lib/performance/vendor/typescript/NOTICE.txt +405 -0
  482. package/lib/performance/vendor/typescript/dist/api/compilerOptions.generated.js +8 -0
  483. package/lib/performance/vendor/typescript/dist/api/diagnosticFormatter.js +169 -0
  484. package/lib/performance/vendor/typescript/dist/api/fs.js +70 -0
  485. package/lib/performance/vendor/typescript/dist/api/fsCallbacks.js +111 -0
  486. package/lib/performance/vendor/typescript/dist/api/node/encoder.generated.js +74 -0
  487. package/lib/performance/vendor/typescript/dist/api/node/encoder.js +292 -0
  488. package/lib/performance/vendor/typescript/dist/api/node/msgpack.js +212 -0
  489. package/lib/performance/vendor/typescript/dist/api/node/node.generated.js +884 -0
  490. package/lib/performance/vendor/typescript/dist/api/node/node.infrastructure.js +102 -0
  491. package/lib/performance/vendor/typescript/dist/api/node/node.js +453 -0
  492. package/lib/performance/vendor/typescript/dist/api/node/protocol.generated.js +241 -0
  493. package/lib/performance/vendor/typescript/dist/api/node/protocol.js +33 -0
  494. package/lib/performance/vendor/typescript/dist/api/node/wtf8.js +130 -0
  495. package/lib/performance/vendor/typescript/dist/api/options.js +32 -0
  496. package/lib/performance/vendor/typescript/dist/api/path.js +884 -0
  497. package/lib/performance/vendor/typescript/dist/api/prepareCompilerOptions.generated.js +24 -0
  498. package/lib/performance/vendor/typescript/dist/api/proto.generated.js +21 -0
  499. package/lib/performance/vendor/typescript/dist/api/proto.js +50 -0
  500. package/lib/performance/vendor/typescript/dist/api/sourceFileCache.js +300 -0
  501. package/lib/performance/vendor/typescript/dist/api/sync/api.js +5408 -0
  502. package/lib/performance/vendor/typescript/dist/api/sync/client.js +174 -0
  503. package/lib/performance/vendor/typescript/dist/api/sync/generatorSupport.js +338 -0
  504. package/lib/performance/vendor/typescript/dist/api/syncChannel.js +526 -0
  505. package/lib/performance/vendor/typescript/dist/api/timing.js +149 -0
  506. package/lib/performance/vendor/typescript/dist/api/timingDump.js +38 -0
  507. package/lib/performance/vendor/typescript/dist/api/userPreferences.generated.js +3 -0
  508. package/lib/performance/vendor/typescript/dist/ast/ast.generated.js +4 -0
  509. package/lib/performance/vendor/typescript/dist/ast/ast.js +8 -0
  510. package/lib/performance/vendor/typescript/dist/ast/astnav.js +741 -0
  511. package/lib/performance/vendor/typescript/dist/ast/clone.js +104 -0
  512. package/lib/performance/vendor/typescript/dist/ast/factory.generated.js +5751 -0
  513. package/lib/performance/vendor/typescript/dist/ast/index.js +25 -0
  514. package/lib/performance/vendor/typescript/dist/ast/is.generated.js +1400 -0
  515. package/lib/performance/vendor/typescript/dist/ast/is.js +456 -0
  516. package/lib/performance/vendor/typescript/dist/ast/jsdoc.js +208 -0
  517. package/lib/performance/vendor/typescript/dist/ast/modifiers.js +41 -0
  518. package/lib/performance/vendor/typescript/dist/ast/scanner.js +2231 -0
  519. package/lib/performance/vendor/typescript/dist/ast/spanMap.js +417 -0
  520. package/lib/performance/vendor/typescript/dist/ast/utils.js +318 -0
  521. package/lib/performance/vendor/typescript/dist/ast/visitor.generated.js +979 -0
  522. package/lib/performance/vendor/typescript/dist/ast/visitor.js +87 -0
  523. package/lib/performance/vendor/typescript/dist/enums/caseSensitivity.js +7 -0
  524. package/lib/performance/vendor/typescript/dist/enums/characterCodes.js +130 -0
  525. package/lib/performance/vendor/typescript/dist/enums/checkFlags.js +36 -0
  526. package/lib/performance/vendor/typescript/dist/enums/commentDirectiveType.js +6 -0
  527. package/lib/performance/vendor/typescript/dist/enums/completionItemKind.js +30 -0
  528. package/lib/performance/vendor/typescript/dist/enums/diagnosticCategory.js +9 -0
  529. package/lib/performance/vendor/typescript/dist/enums/diagnosticDirectivePolicy.js +7 -0
  530. package/lib/performance/vendor/typescript/dist/enums/elementFlags.js +14 -0
  531. package/lib/performance/vendor/typescript/dist/enums/emitOnly.js +8 -0
  532. package/lib/performance/vendor/typescript/dist/enums/indexKind.js +7 -0
  533. package/lib/performance/vendor/typescript/dist/enums/internalSymbolName.js +25 -0
  534. package/lib/performance/vendor/typescript/dist/enums/jsDeclarationKind.js +12 -0
  535. package/lib/performance/vendor/typescript/dist/enums/jsxEmit.js +11 -0
  536. package/lib/performance/vendor/typescript/dist/enums/languageVariant.js +6 -0
  537. package/lib/performance/vendor/typescript/dist/enums/modifierFlags.js +44 -0
  538. package/lib/performance/vendor/typescript/dist/enums/moduleDetectionKind.js +9 -0
  539. package/lib/performance/vendor/typescript/dist/enums/moduleKind.js +19 -0
  540. package/lib/performance/vendor/typescript/dist/enums/moduleResolutionKind.js +11 -0
  541. package/lib/performance/vendor/typescript/dist/enums/newLineKind.js +8 -0
  542. package/lib/performance/vendor/typescript/dist/enums/nodeBuilderFlags.js +38 -0
  543. package/lib/performance/vendor/typescript/dist/enums/nodeFlags.js +46 -0
  544. package/lib/performance/vendor/typescript/dist/enums/objectFlags.js +53 -0
  545. package/lib/performance/vendor/typescript/dist/enums/outerExpressionKinds.js +18 -0
  546. package/lib/performance/vendor/typescript/dist/enums/regularExpressionFlags.js +14 -0
  547. package/lib/performance/vendor/typescript/dist/enums/scriptKind.js +11 -0
  548. package/lib/performance/vendor/typescript/dist/enums/scriptTarget.js +20 -0
  549. package/lib/performance/vendor/typescript/dist/enums/signatureFlags.js +17 -0
  550. package/lib/performance/vendor/typescript/dist/enums/signatureKind.js +7 -0
  551. package/lib/performance/vendor/typescript/dist/enums/spanMapFeature.js +27 -0
  552. package/lib/performance/vendor/typescript/dist/enums/spanMapFidelity.js +9 -0
  553. package/lib/performance/vendor/typescript/dist/enums/spanMapKind.js +8 -0
  554. package/lib/performance/vendor/typescript/dist/enums/symbolFlags.js +72 -0
  555. package/lib/performance/vendor/typescript/dist/enums/symbolOwnerKind.js +7 -0
  556. package/lib/performance/vendor/typescript/dist/enums/syntaxKind.js +392 -0
  557. package/lib/performance/vendor/typescript/dist/enums/tokenFlags.js +32 -0
  558. package/lib/performance/vendor/typescript/dist/enums/typeFlags.js +78 -0
  559. package/lib/performance/vendor/typescript/dist/enums/typeFormatFlags.js +31 -0
  560. package/lib/performance/vendor/typescript/dist/enums/typePredicateKind.js +9 -0
  561. package/lib/performance/vendor/typescript/dist/internal/utils.js +25 -0
  562. package/lib/performance/vendor/typescript/lib/getExePath.js +70 -0
  563. package/lib/performance/vendor/typescript/package.json +93 -0
  564. package/lib/performance/vendor/typescript/vendor/vscode-jsonrpc/License.txt +11 -0
  565. package/lib/performance/watch.js +99 -0
  566. package/lib/performance/workbook-decodes.js +147 -0
  567. package/lib/reliability/analyze.js +29 -0
  568. package/lib/reliability/boundary-access.js +521 -0
  569. package/lib/reliability/cli.js +20 -0
  570. package/lib/reliability/resource-leaks.js +526 -0
  571. package/lib/reliability/rule-ids.js +225 -0
  572. package/lib/reliability/site-fixes/boundary-access.js +80 -0
  573. package/lib/reliability/site-fixes/resource-leaks.js +125 -0
  574. package/lib/reliability/site-fixes/suspicious-logic.js +115 -0
  575. package/lib/reliability/source-helpers.js +32 -0
  576. package/lib/reliability/sql-insert-terminator.js +106 -0
  577. package/lib/reliability/standalone-sources.js +54 -0
  578. package/lib/reliability/suspicious-logic.js +364 -0
  579. package/lib/reliability/swallowed-errors.js +321 -0
  580. package/lib/reliability/usage.js +16 -0
  581. package/lib/reliability/walk.js +16 -0
  582. package/lib/security/analyze.js +129 -0
  583. package/lib/security/auth-crypto/comparison.js +97 -0
  584. package/lib/security/auth-crypto/hashing.js +302 -0
  585. package/lib/security/auth-crypto/index.js +32 -0
  586. package/lib/security/auth-crypto/jwt.js +468 -0
  587. package/lib/security/auth-crypto/plaintext-password.js +171 -0
  588. package/lib/security/auth-crypto/random.js +124 -0
  589. package/lib/security/auth-crypto/rate-limits.js +326 -0
  590. package/lib/security/auth-crypto/rule-ids.js +17 -0
  591. package/lib/security/auth-crypto/secrets.js +331 -0
  592. package/lib/security/auth-crypto/shared.js +105 -0
  593. package/lib/security/auth-crypto/transport-and-ciphers.js +217 -0
  594. package/lib/security/bindings.js +286 -0
  595. package/lib/security/cli.js +293 -0
  596. package/lib/security/declarations.js +25 -0
  597. package/lib/security/deps/advisory.js +142 -0
  598. package/lib/security/deps/cli.js +75 -0
  599. package/lib/security/deps/lockfiles.js +310 -0
  600. package/lib/security/deps/osv.js +217 -0
  601. package/lib/security/deps/rule-ids.js +6 -0
  602. package/lib/security/deps/scan.js +69 -0
  603. package/lib/security/examples/auth-crypto.cjs +57 -0
  604. package/lib/security/examples/deps.cjs +9 -0
  605. package/lib/security/examples/exposure.cjs +98 -0
  606. package/lib/security/examples/files.cjs +29 -0
  607. package/lib/security/examples/injection.cjs +53 -0
  608. package/lib/security/examples/moved.cjs +17 -0
  609. package/lib/security/examples/request-forgery.cjs +25 -0
  610. package/lib/security/exposure/backend-security-mastery.js +80 -0
  611. package/lib/security/exposure/cookies.js +173 -0
  612. package/lib/security/exposure/cors-origin-regex.js +177 -0
  613. package/lib/security/exposure/cors.js +217 -0
  614. package/lib/security/exposure/error-responses.js +437 -0
  615. package/lib/security/exposure/frontend-security.js +547 -0
  616. package/lib/security/exposure/graphql.js +131 -0
  617. package/lib/security/exposure/index.js +52 -0
  618. package/lib/security/exposure/literals.js +133 -0
  619. package/lib/security/exposure/logging.js +168 -0
  620. package/lib/security/exposure/mass-assignment.js +165 -0
  621. package/lib/security/exposure/password-response.js +315 -0
  622. package/lib/security/exposure/prototype-pollution.js +291 -0
  623. package/lib/security/exposure/reflected-xss.js +57 -0
  624. package/lib/security/exposure/report.js +10 -0
  625. package/lib/security/exposure/rule-ids.js +28 -0
  626. package/lib/security/exposure/storage-acl.js +87 -0
  627. package/lib/security/exposure/template-autoescape.js +39 -0
  628. package/lib/security/exposure/url-secrets.js +164 -0
  629. package/lib/security/exposure/validation-pipe.js +36 -0
  630. package/lib/security/exposure/xml.js +28 -0
  631. package/lib/security/file-context.js +82 -0
  632. package/lib/security/files/compose.js +79 -0
  633. package/lib/security/files/dockerfile.js +206 -0
  634. package/lib/security/files/index.js +100 -0
  635. package/lib/security/files/project-files.js +103 -0
  636. package/lib/security/files/review-directive.js +30 -0
  637. package/lib/security/files/rule-ids.js +10 -0
  638. package/lib/security/files/secret-values.js +98 -0
  639. package/lib/security/files/secrets.js +121 -0
  640. package/lib/security/injection/code.js +108 -0
  641. package/lib/security/injection/command.js +127 -0
  642. package/lib/security/injection/index.js +13 -0
  643. package/lib/security/injection/nosql.js +266 -0
  644. package/lib/security/injection/redos.js +609 -0
  645. package/lib/security/injection/regex.js +48 -0
  646. package/lib/security/injection/rule-ids.js +16 -0
  647. package/lib/security/injection/shared.js +119 -0
  648. package/lib/security/injection/sql.js +432 -0
  649. package/lib/security/pg-dynamic-query.js +30 -0
  650. package/lib/security/pg-identifier-guards.js +155 -0
  651. package/lib/security/phase5-rules.js +515 -0
  652. package/lib/security/polyglot.js +8 -0
  653. package/lib/security/request-forgery/index.js +11 -0
  654. package/lib/security/request-forgery/open-redirect.js +336 -0
  655. package/lib/security/request-forgery/path-traversal.js +103 -0
  656. package/lib/security/request-forgery/rule-ids.js +9 -0
  657. package/lib/security/request-forgery/shared.js +355 -0
  658. package/lib/security/request-forgery/ssrf.js +133 -0
  659. package/lib/security/request-forgery/upload-filename.js +75 -0
  660. package/lib/security/request-forgery/zip-slip.js +42 -0
  661. package/lib/security/rule-descriptions.js +84 -0
  662. package/lib/security/rule-ids.js +142 -0
  663. package/lib/security/scope/drizzle-policy.js +197 -0
  664. package/lib/security/scope/query-policy.js +156 -0
  665. package/lib/security/site-fixes/auth-crypto.js +223 -0
  666. package/lib/security/site-fixes/backend-security-fixes.js +86 -0
  667. package/lib/security/site-fixes/error-responses.js +84 -0
  668. package/lib/security/site-fixes/exposure.js +120 -0
  669. package/lib/security/site-fixes/files.js +45 -0
  670. package/lib/security/site-fixes/frontend-security-fixes.js +73 -0
  671. package/lib/security/site-fixes/injection.js +119 -0
  672. package/lib/security/site-fixes/jwt.js +89 -0
  673. package/lib/security/site-fixes/list-edits.js +16 -0
  674. package/lib/security/site-fixes/request-forgery.js +117 -0
  675. package/lib/security/site-fixes/secret-comparison.js +107 -0
  676. package/lib/security/site-fixes/template-autoescape.js +25 -0
  677. package/lib/security/taint/archive-sources.js +127 -0
  678. package/lib/security/taint/filename-guard.js +110 -0
  679. package/lib/security/taint/guards.js +274 -0
  680. package/lib/security/taint/index.js +559 -0
  681. package/lib/security/taint/propagate.js +117 -0
  682. package/lib/security/taint/sanitizers.js +67 -0
  683. package/lib/security/taint/sources.js +357 -0
  684. package/lib/security/taint/summaries.js +207 -0
  685. package/lib/security/taint/url-parts.js +264 -0
  686. package/lib/security/taint/validators.js +420 -0
  687. package/lib/security/types/condition-guards.js +1 -0
  688. package/lib/security/types/file-finding.js +1 -0
  689. package/lib/security/types/inspectable-type.js +1 -0
  690. package/lib/security/types/lockfile.js +1 -0
  691. package/lib/security/types/osv-vulnerability.js +1 -0
  692. package/lib/security/types/project-files.js +1 -0
  693. package/lib/security/types/propagation.js +1 -0
  694. package/lib/security/types/rule-example.js +1 -0
  695. package/lib/security/types/schema-call.js +1 -0
  696. package/lib/security/types/security-check.js +1 -0
  697. package/lib/shared/agent-init.js +235 -0
  698. package/lib/shared/agent-session.js +28 -0
  699. package/lib/shared/agent-verify.js +239 -0
  700. package/lib/shared/atomic-write.js +52 -0
  701. package/lib/shared/baseline-flags.js +33 -0
  702. package/lib/shared/baseline.js +237 -0
  703. package/lib/shared/build-output.js +22 -0
  704. package/lib/shared/check.js +254 -0
  705. package/lib/shared/config.js +286 -0
  706. package/lib/shared/coverage-notes.js +27 -0
  707. package/lib/shared/error-code.js +9 -0
  708. package/lib/shared/execution-context.js +278 -0
  709. package/lib/shared/explain.js +34 -0
  710. package/lib/shared/fix-command.js +23 -0
  711. package/lib/shared/fix-convergence.js +389 -0
  712. package/lib/shared/fix-handoff.js +57 -0
  713. package/lib/shared/fix-history.js +303 -0
  714. package/lib/shared/fix-hunks.js +108 -0
  715. package/lib/shared/fix-imports.js +233 -0
  716. package/lib/shared/fix-presentation-comments.js +253 -0
  717. package/lib/shared/fix-presentation-prettier.js +233 -0
  718. package/lib/shared/fix-presentation-rows.js +157 -0
  719. package/lib/shared/fix-presentation-style.js +230 -0
  720. package/lib/shared/fix-presentation.js +177 -0
  721. package/lib/shared/fix-rationales.js +151 -0
  722. package/lib/shared/fix-recipes.js +101 -0
  723. package/lib/shared/fix-safety.js +64 -0
  724. package/lib/shared/fix-terminal.js +65 -0
  725. package/lib/shared/fix-typecheck.js +188 -0
  726. package/lib/shared/fix.js +257 -0
  727. package/lib/shared/formats/contract-rules.js +9 -0
  728. package/lib/shared/formats/finding-location.js +31 -0
  729. package/lib/shared/formats/github.js +36 -0
  730. package/lib/shared/formats/index.js +29 -0
  731. package/lib/shared/formats/sarif.js +91 -0
  732. package/lib/shared/function-summaries.js +571 -0
  733. package/lib/shared/function-syntax.js +86 -0
  734. package/lib/shared/git-hook.js +153 -0
  735. package/lib/shared/git-paths.js +38 -0
  736. package/lib/shared/glob.js +53 -0
  737. package/lib/shared/heap-limit.js +71 -0
  738. package/lib/shared/hot-path-graph.js +268 -0
  739. package/lib/shared/hot-path.js +20 -0
  740. package/lib/shared/impact-levels.js +49 -0
  741. package/lib/shared/is-record.js +5 -0
  742. package/lib/shared/managed-blocks.js +54 -0
  743. package/lib/shared/notify-editor.js +50 -0
  744. package/lib/shared/pending-review.js +117 -0
  745. package/lib/shared/pillar-rules.js +6 -0
  746. package/lib/shared/pillars.js +384 -0
  747. package/lib/shared/polyglot-compatibility.js +105 -0
  748. package/lib/shared/project-root.js +35 -0
  749. package/lib/shared/real-target.js +23 -0
  750. package/lib/shared/reason-groups.js +20 -0
  751. package/lib/shared/review-delivery.js +33 -0
  752. package/lib/shared/review-mcp.js +262 -0
  753. package/lib/shared/review-request.js +59 -0
  754. package/lib/shared/rule-registry.js +57 -0
  755. package/lib/shared/scan-cache.js +234 -0
  756. package/lib/shared/shell-argument.js +9 -0
  757. package/lib/shared/source-report.js +156 -0
  758. package/lib/shared/types/baseline.js +1 -0
  759. package/lib/shared/types/checker-run.js +1 -0
  760. package/lib/shared/types/cli-finding.js +1 -0
  761. package/lib/shared/types/fix-hunks.js +1 -0
  762. package/lib/shared/types/fix-presentation.js +1 -0
  763. package/lib/shared/types/fix-run.js +1 -0
  764. package/lib/shared/types/function-summaries.js +1 -0
  765. package/lib/shared/types/managed-blocks.js +1 -0
  766. package/lib/shared/types/pillar-name.js +1 -0
  767. package/lib/shared/types/report-formats.js +1 -0
  768. package/lib/shared/types/review-event.js +1 -0
  769. package/lib/shared/types/review-history.js +1 -0
  770. package/lib/shared/types/settings.js +1 -0
  771. package/lib/shared/types/source-report.js +1 -0
  772. package/lib/shared/types/typescript-assignment-target.js +1 -0
  773. package/lib/shared/types/typescript-internals.js +1 -0
  774. package/lib/shared/types/typescript-module-resolution.js +1 -0
  775. package/lib/shared/types/typescript-outer-expression.js +1 -0
  776. package/lib/shared/types.js +1 -0
  777. package/lib/shared/workspaces.js +299 -0
  778. package/package.json +127 -4
  779. package/plugin/.claude-plugin/plugin.json +9 -0
  780. package/plugin/commands/loadwise.md +24 -0
  781. package/plugin/hooks/check-edited-file.js +142 -0
  782. package/plugin/hooks/hooks.json +17 -0
  783. package/polyglot/maintainability/rules.js +159 -0
  784. package/polyglot/maintainability/sgconfig.yml +12 -0
  785. package/polyglot/performance/rules/csharp.yml +104 -0
  786. package/polyglot/performance/rules/go.yml +123 -0
  787. package/polyglot/performance/rules/input.yml +37 -0
  788. package/polyglot/performance/rules/java.yml +115 -0
  789. package/polyglot/performance/rules/python.yml +159 -0
  790. package/polyglot/performance/rules/rust.yml +88 -0
  791. package/polyglot/performance/sgconfig.yml +8 -0
  792. package/polyglot/reliability/rules/csharp.yml +65 -0
  793. package/polyglot/reliability/rules/go.yml +76 -0
  794. package/polyglot/reliability/rules/java.yml +41 -0
  795. package/polyglot/reliability/rules/python.yml +32 -0
  796. package/polyglot/reliability/rules/rust.yml +34 -0
  797. package/polyglot/reliability/sgconfig.yml +8 -0
  798. package/polyglot/security/rules/csharp.yml +28 -0
  799. package/polyglot/security/rules/go.yml +42 -0
  800. package/polyglot/security/rules/java.yml +17 -0
  801. package/polyglot/security/rules/python.yml +48 -0
  802. package/polyglot/security/rules/rust.yml +23 -0
  803. package/polyglot/security/sgconfig.yml +8 -0
  804. package/schema/loadwise.config.schema.json +725 -0
@@ -0,0 +1,2231 @@
1
+ import { CharacterCodes } from "#enums/characterCodes";
2
+ import { CommentDirectiveType } from "#enums/commentDirectiveType";
3
+ import { LanguageVariant } from "#enums/languageVariant";
4
+ import { RegularExpressionFlags } from "#enums/regularExpressionFlags";
5
+ import { ScriptTarget } from "#enums/scriptTarget";
6
+ import { SyntaxKind } from "#enums/syntaxKind";
7
+ import { TokenFlags } from "#enums/tokenFlags";
8
+ // Internal-only, not exported
9
+ const EscapeSequenceScanningFlags = {
10
+ String: 1 << 0,
11
+ ReportErrors: 1 << 1,
12
+ RegularExpression: 1 << 2,
13
+ AnnexB: 1 << 3,
14
+ AnyUnicodeMode: 1 << 4,
15
+ AtomEscape: 1 << 5,
16
+ ReportInvalidEscapeErrors: (1 << 2) | (1 << 1),
17
+ AllowExtendedUnicodeEscape: (1 << 0) | (1 << 4),
18
+ };
19
+ export function tokenIsIdentifierOrKeyword(token) {
20
+ return token >= SyntaxKind.Identifier;
21
+ }
22
+ export function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
23
+ return token === SyntaxKind.GreaterThanToken || tokenIsIdentifierOrKeyword(token);
24
+ }
25
+ export const textToKeywordObj = {
26
+ abstract: SyntaxKind.AbstractKeyword,
27
+ accessor: SyntaxKind.AccessorKeyword,
28
+ any: SyntaxKind.AnyKeyword,
29
+ as: SyntaxKind.AsKeyword,
30
+ asserts: SyntaxKind.AssertsKeyword,
31
+ assert: SyntaxKind.AssertKeyword,
32
+ bigint: SyntaxKind.BigIntKeyword,
33
+ boolean: SyntaxKind.BooleanKeyword,
34
+ break: SyntaxKind.BreakKeyword,
35
+ case: SyntaxKind.CaseKeyword,
36
+ catch: SyntaxKind.CatchKeyword,
37
+ class: SyntaxKind.ClassKeyword,
38
+ continue: SyntaxKind.ContinueKeyword,
39
+ const: SyntaxKind.ConstKeyword,
40
+ ["" + "constructor"]: SyntaxKind.ConstructorKeyword,
41
+ debugger: SyntaxKind.DebuggerKeyword,
42
+ declare: SyntaxKind.DeclareKeyword,
43
+ default: SyntaxKind.DefaultKeyword,
44
+ defer: SyntaxKind.DeferKeyword,
45
+ delete: SyntaxKind.DeleteKeyword,
46
+ do: SyntaxKind.DoKeyword,
47
+ else: SyntaxKind.ElseKeyword,
48
+ enum: SyntaxKind.EnumKeyword,
49
+ export: SyntaxKind.ExportKeyword,
50
+ extends: SyntaxKind.ExtendsKeyword,
51
+ false: SyntaxKind.FalseKeyword,
52
+ finally: SyntaxKind.FinallyKeyword,
53
+ for: SyntaxKind.ForKeyword,
54
+ from: SyntaxKind.FromKeyword,
55
+ function: SyntaxKind.FunctionKeyword,
56
+ get: SyntaxKind.GetKeyword,
57
+ if: SyntaxKind.IfKeyword,
58
+ implements: SyntaxKind.ImplementsKeyword,
59
+ import: SyntaxKind.ImportKeyword,
60
+ in: SyntaxKind.InKeyword,
61
+ infer: SyntaxKind.InferKeyword,
62
+ instanceof: SyntaxKind.InstanceOfKeyword,
63
+ interface: SyntaxKind.InterfaceKeyword,
64
+ intrinsic: SyntaxKind.IntrinsicKeyword,
65
+ is: SyntaxKind.IsKeyword,
66
+ keyof: SyntaxKind.KeyOfKeyword,
67
+ let: SyntaxKind.LetKeyword,
68
+ module: SyntaxKind.ModuleKeyword,
69
+ namespace: SyntaxKind.NamespaceKeyword,
70
+ never: SyntaxKind.NeverKeyword,
71
+ new: SyntaxKind.NewKeyword,
72
+ null: SyntaxKind.NullKeyword,
73
+ number: SyntaxKind.NumberKeyword,
74
+ object: SyntaxKind.ObjectKeyword,
75
+ package: SyntaxKind.PackageKeyword,
76
+ private: SyntaxKind.PrivateKeyword,
77
+ protected: SyntaxKind.ProtectedKeyword,
78
+ public: SyntaxKind.PublicKeyword,
79
+ override: SyntaxKind.OverrideKeyword,
80
+ out: SyntaxKind.OutKeyword,
81
+ readonly: SyntaxKind.ReadonlyKeyword,
82
+ require: SyntaxKind.RequireKeyword,
83
+ global: SyntaxKind.GlobalKeyword,
84
+ return: SyntaxKind.ReturnKeyword,
85
+ satisfies: SyntaxKind.SatisfiesKeyword,
86
+ set: SyntaxKind.SetKeyword,
87
+ source: SyntaxKind.SourceKeyword,
88
+ static: SyntaxKind.StaticKeyword,
89
+ string: SyntaxKind.StringKeyword,
90
+ super: SyntaxKind.SuperKeyword,
91
+ switch: SyntaxKind.SwitchKeyword,
92
+ symbol: SyntaxKind.SymbolKeyword,
93
+ this: SyntaxKind.ThisKeyword,
94
+ throw: SyntaxKind.ThrowKeyword,
95
+ true: SyntaxKind.TrueKeyword,
96
+ try: SyntaxKind.TryKeyword,
97
+ type: SyntaxKind.TypeKeyword,
98
+ typeof: SyntaxKind.TypeOfKeyword,
99
+ undefined: SyntaxKind.UndefinedKeyword,
100
+ unique: SyntaxKind.UniqueKeyword,
101
+ unknown: SyntaxKind.UnknownKeyword,
102
+ using: SyntaxKind.UsingKeyword,
103
+ var: SyntaxKind.VarKeyword,
104
+ void: SyntaxKind.VoidKeyword,
105
+ while: SyntaxKind.WhileKeyword,
106
+ with: SyntaxKind.WithKeyword,
107
+ yield: SyntaxKind.YieldKeyword,
108
+ async: SyntaxKind.AsyncKeyword,
109
+ await: SyntaxKind.AwaitKeyword,
110
+ of: SyntaxKind.OfKeyword,
111
+ };
112
+ const textToKeyword = new Map(Object.entries(textToKeywordObj));
113
+ const textToToken = new Map(Object.entries({
114
+ ...textToKeywordObj,
115
+ "{": SyntaxKind.OpenBraceToken,
116
+ "}": SyntaxKind.CloseBraceToken,
117
+ "(": SyntaxKind.OpenParenToken,
118
+ ")": SyntaxKind.CloseParenToken,
119
+ "[": SyntaxKind.OpenBracketToken,
120
+ "]": SyntaxKind.CloseBracketToken,
121
+ ".": SyntaxKind.DotToken,
122
+ "...": SyntaxKind.DotDotDotToken,
123
+ ";": SyntaxKind.SemicolonToken,
124
+ ",": SyntaxKind.CommaToken,
125
+ "<": SyntaxKind.LessThanToken,
126
+ ">": SyntaxKind.GreaterThanToken,
127
+ "<=": SyntaxKind.LessThanEqualsToken,
128
+ ">=": SyntaxKind.GreaterThanEqualsToken,
129
+ "==": SyntaxKind.EqualsEqualsToken,
130
+ "!=": SyntaxKind.ExclamationEqualsToken,
131
+ "===": SyntaxKind.EqualsEqualsEqualsToken,
132
+ "!==": SyntaxKind.ExclamationEqualsEqualsToken,
133
+ "=>": SyntaxKind.EqualsGreaterThanToken,
134
+ "+": SyntaxKind.PlusToken,
135
+ "-": SyntaxKind.MinusToken,
136
+ "**": SyntaxKind.AsteriskAsteriskToken,
137
+ "*": SyntaxKind.AsteriskToken,
138
+ "/": SyntaxKind.SlashToken,
139
+ "%": SyntaxKind.PercentToken,
140
+ "++": SyntaxKind.PlusPlusToken,
141
+ "--": SyntaxKind.MinusMinusToken,
142
+ "<<": SyntaxKind.LessThanLessThanToken,
143
+ "</": SyntaxKind.LessThanSlashToken,
144
+ ">>": SyntaxKind.GreaterThanGreaterThanToken,
145
+ ">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken,
146
+ "&": SyntaxKind.AmpersandToken,
147
+ "|": SyntaxKind.BarToken,
148
+ "^": SyntaxKind.CaretToken,
149
+ "!": SyntaxKind.ExclamationToken,
150
+ "~": SyntaxKind.TildeToken,
151
+ "&&": SyntaxKind.AmpersandAmpersandToken,
152
+ "||": SyntaxKind.BarBarToken,
153
+ "?": SyntaxKind.QuestionToken,
154
+ "??": SyntaxKind.QuestionQuestionToken,
155
+ "?.": SyntaxKind.QuestionDotToken,
156
+ ":": SyntaxKind.ColonToken,
157
+ "=": SyntaxKind.EqualsToken,
158
+ "+=": SyntaxKind.PlusEqualsToken,
159
+ "-=": SyntaxKind.MinusEqualsToken,
160
+ "*=": SyntaxKind.AsteriskEqualsToken,
161
+ "**=": SyntaxKind.AsteriskAsteriskEqualsToken,
162
+ "/=": SyntaxKind.SlashEqualsToken,
163
+ "%=": SyntaxKind.PercentEqualsToken,
164
+ "<<=": SyntaxKind.LessThanLessThanEqualsToken,
165
+ ">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken,
166
+ ">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
167
+ "&=": SyntaxKind.AmpersandEqualsToken,
168
+ "|=": SyntaxKind.BarEqualsToken,
169
+ "^=": SyntaxKind.CaretEqualsToken,
170
+ "||=": SyntaxKind.BarBarEqualsToken,
171
+ "&&=": SyntaxKind.AmpersandAmpersandEqualsToken,
172
+ "??=": SyntaxKind.QuestionQuestionEqualsToken,
173
+ "@": SyntaxKind.AtToken,
174
+ "#": SyntaxKind.HashToken,
175
+ "`": SyntaxKind.BacktickToken,
176
+ }));
177
+ const charCodeToRegExpFlag = new Map([
178
+ [CharacterCodes.d, RegularExpressionFlags.HasIndices],
179
+ [CharacterCodes.g, RegularExpressionFlags.Global],
180
+ [CharacterCodes.i, RegularExpressionFlags.IgnoreCase],
181
+ [CharacterCodes.m, RegularExpressionFlags.Multiline],
182
+ [CharacterCodes.s, RegularExpressionFlags.DotAll],
183
+ [CharacterCodes.u, RegularExpressionFlags.Unicode],
184
+ [CharacterCodes.v, RegularExpressionFlags.UnicodeSets],
185
+ [CharacterCodes.y, RegularExpressionFlags.Sticky],
186
+ ]);
187
+ /**
188
+ * Generated by scripts/regenerate-unicode-identifier-parts.mjs on node v22.1.0 with unicode 15.1
189
+ * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords
190
+ * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and
191
+ * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start
192
+ */
193
+ // dprint-ignore
194
+ const unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2160, 2183, 2185, 2190, 2208, 2249, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3165, 3165, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3293, 3294, 3296, 3297, 3313, 3314, 3332, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5905, 5919, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6988, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12735, 12784, 12799, 13312, 19903, 19968, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42954, 42960, 42961, 42963, 42963, 42965, 42969, 42994, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43881, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 66928, 66938, 66940, 66954, 66956, 66962, 66964, 66965, 66967, 66977, 66979, 66993, 66995, 67001, 67003, 67004, 67072, 67382, 67392, 67413, 67424, 67431, 67456, 67461, 67463, 67504, 67506, 67514, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69248, 69289, 69296, 69297, 69376, 69404, 69415, 69415, 69424, 69445, 69488, 69505, 69552, 69572, 69600, 69622, 69635, 69687, 69745, 69746, 69749, 69749, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69959, 69959, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70207, 70208, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70753, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71488, 71494, 71680, 71723, 71840, 71903, 71935, 71942, 71945, 71945, 71948, 71955, 71957, 71958, 71960, 71983, 71999, 71999, 72001, 72001, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72368, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73474, 73474, 73476, 73488, 73490, 73523, 73648, 73648, 73728, 74649, 74752, 74862, 74880, 75075, 77712, 77808, 77824, 78895, 78913, 78918, 82944, 83526, 92160, 92728, 92736, 92766, 92784, 92862, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101589, 101632, 101640, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 122624, 122654, 122661, 122666, 122928, 122989, 123136, 123180, 123191, 123197, 123214, 123214, 123536, 123565, 123584, 123627, 124112, 124139, 124896, 124902, 124904, 124907, 124909, 124910, 124912, 124926, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173791, 173824, 177977, 177984, 178205, 178208, 183969, 183984, 191456, 191472, 192093, 194560, 195101, 196608, 201546, 201552, 205743];
195
+ // dprint-ignore
196
+ const unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2160, 2183, 2185, 2190, 2200, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2901, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3132, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3165, 3165, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3293, 3294, 3296, 3299, 3302, 3311, 3313, 3315, 3328, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3457, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3790, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5909, 5919, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6159, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6847, 6862, 6912, 6988, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12543, 12549, 12591, 12593, 12686, 12704, 12735, 12784, 12799, 13312, 19903, 19968, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42954, 42960, 42961, 42963, 42963, 42965, 42969, 42994, 43047, 43052, 43052, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43881, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 66928, 66938, 66940, 66954, 66956, 66962, 66964, 66965, 66967, 66977, 66979, 66993, 66995, 67001, 67003, 67004, 67072, 67382, 67392, 67413, 67424, 67431, 67456, 67461, 67463, 67504, 67506, 67514, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69248, 69289, 69291, 69292, 69296, 69297, 69373, 69404, 69415, 69415, 69424, 69456, 69488, 69509, 69552, 69572, 69600, 69622, 69632, 69702, 69734, 69749, 69759, 69818, 69826, 69826, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69959, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70094, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70209, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70753, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71488, 71494, 71680, 71738, 71840, 71913, 71935, 71942, 71945, 71945, 71948, 71955, 71957, 71958, 71960, 71989, 71991, 71992, 71995, 72003, 72016, 72025, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72368, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73472, 73488, 73490, 73530, 73534, 73538, 73552, 73561, 73648, 73648, 73728, 74649, 74752, 74862, 74880, 75075, 77712, 77808, 77824, 78895, 78912, 78933, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92784, 92862, 92864, 92873, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94180, 94192, 94193, 94208, 100343, 100352, 101589, 101632, 101640, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 118528, 118573, 118576, 118598, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122624, 122654, 122661, 122666, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 122928, 122989, 123023, 123023, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123536, 123566, 123584, 123641, 124112, 124153, 124896, 124902, 124904, 124907, 124909, 124910, 124912, 124926, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 130032, 130041, 131072, 173791, 173824, 177977, 177984, 178205, 178208, 183969, 183984, 191456, 191472, 192093, 194560, 195101, 196608, 201546, 201552, 205743, 917760, 917999];
197
+ const commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
198
+ const commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
199
+ const jsDocTagTerminators = new Set([" ", "\t", "\n", "\r", "}", "*"]);
200
+ function hasJSDocTag(text, offset, ...tags) {
201
+ for (const tag of tags) {
202
+ if (text.startsWith(tag, offset)) {
203
+ if (offset + tag.length === text.length) {
204
+ return true;
205
+ }
206
+ if (jsDocTagTerminators.has(text[offset + tag.length])) {
207
+ return true;
208
+ }
209
+ }
210
+ }
211
+ return false;
212
+ }
213
+ function scanJSDocCommentForTags(text, tokenFlags) {
214
+ let offset = 0;
215
+ while (true) {
216
+ const i = text.indexOf("@", offset);
217
+ if (i < 0) {
218
+ return tokenFlags;
219
+ }
220
+ offset = i + 1;
221
+ if (!(tokenFlags & TokenFlags.PrecedingJSDocWithDeprecated) && hasJSDocTag(text, offset, "deprecated")) {
222
+ tokenFlags |= TokenFlags.PrecedingJSDocWithDeprecated;
223
+ }
224
+ if (!(tokenFlags & TokenFlags.PrecedingJSDocWithSeeOrLink) && hasJSDocTag(text, offset, "see", "link", "linkcode", "linkplain")) {
225
+ tokenFlags |= TokenFlags.PrecedingJSDocWithSeeOrLink;
226
+ }
227
+ if ((tokenFlags & (TokenFlags.PrecedingJSDocWithDeprecated | TokenFlags.PrecedingJSDocWithSeeOrLink)) ===
228
+ (TokenFlags.PrecedingJSDocWithDeprecated | TokenFlags.PrecedingJSDocWithSeeOrLink)) {
229
+ return tokenFlags;
230
+ }
231
+ }
232
+ }
233
+ function lookupInUnicodeMap(code, map) {
234
+ if (code < map[0]) {
235
+ return false;
236
+ }
237
+ let lo = 0;
238
+ let hi = map.length;
239
+ let mid;
240
+ while (lo + 1 < hi) {
241
+ mid = lo + (hi - lo) / 2;
242
+ mid -= mid % 2;
243
+ if (map[mid] <= code && code <= map[mid + 1]) {
244
+ return true;
245
+ }
246
+ if (code < map[mid]) {
247
+ hi = mid;
248
+ }
249
+ else {
250
+ lo = mid + 2;
251
+ }
252
+ }
253
+ return false;
254
+ }
255
+ export function isUnicodeIdentifierStart(code) {
256
+ return lookupInUnicodeMap(code, unicodeESNextIdentifierStart);
257
+ }
258
+ function isUnicodeIdentifierPart(code) {
259
+ return lookupInUnicodeMap(code, unicodeESNextIdentifierPart);
260
+ }
261
+ function makeReverseMap(source) {
262
+ const result = [];
263
+ source.forEach((value, name) => {
264
+ result[value] = name;
265
+ });
266
+ return result;
267
+ }
268
+ const tokenStrings = makeReverseMap(textToToken);
269
+ export function tokenToString(t) {
270
+ return tokenStrings[t];
271
+ }
272
+ export function stringToToken(s) {
273
+ return textToToken.get(s);
274
+ }
275
+ export function characterCodeToRegularExpressionFlag(ch) {
276
+ return charCodeToRegExpFlag.get(ch);
277
+ }
278
+ export function computeLineStarts(text) {
279
+ const result = [];
280
+ let pos = 0;
281
+ let lineStart = 0;
282
+ while (pos < text.length) {
283
+ const ch = text.charCodeAt(pos);
284
+ pos++;
285
+ switch (ch) {
286
+ case CharacterCodes.carriageReturn:
287
+ if (text.charCodeAt(pos) === CharacterCodes.lineFeed) {
288
+ pos++;
289
+ }
290
+ // falls through
291
+ case CharacterCodes.lineFeed:
292
+ result.push(lineStart);
293
+ lineStart = pos;
294
+ break;
295
+ default:
296
+ if (ch > CharacterCodes.maxAsciiCharacter && isLineBreak(ch)) {
297
+ result.push(lineStart);
298
+ lineStart = pos;
299
+ }
300
+ break;
301
+ }
302
+ }
303
+ result.push(lineStart);
304
+ return result;
305
+ }
306
+ export function isWhiteSpaceLike(ch) {
307
+ return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
308
+ }
309
+ export function isWhiteSpaceSingleLine(ch) {
310
+ return ch === CharacterCodes.space ||
311
+ ch === CharacterCodes.tab ||
312
+ ch === CharacterCodes.verticalTab ||
313
+ ch === CharacterCodes.formFeed ||
314
+ ch === CharacterCodes.nonBreakingSpace ||
315
+ ch === CharacterCodes.nextLine ||
316
+ ch === CharacterCodes.ogham ||
317
+ ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace ||
318
+ ch === CharacterCodes.narrowNoBreakSpace ||
319
+ ch === CharacterCodes.mathematicalSpace ||
320
+ ch === CharacterCodes.ideographicSpace ||
321
+ ch === CharacterCodes.byteOrderMark;
322
+ }
323
+ export function isLineBreak(ch) {
324
+ return ch === CharacterCodes.lineFeed ||
325
+ ch === CharacterCodes.carriageReturn ||
326
+ ch === CharacterCodes.lineSeparator ||
327
+ ch === CharacterCodes.paragraphSeparator;
328
+ }
329
+ function isDigit(ch) {
330
+ return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
331
+ }
332
+ function isHexDigit(ch) {
333
+ return isDigit(ch) || ch >= CharacterCodes.A && ch <= CharacterCodes.F || ch >= CharacterCodes.a && ch <= CharacterCodes.f;
334
+ }
335
+ function isOctalDigit(ch) {
336
+ return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
337
+ }
338
+ export function couldStartTrivia(text, pos) {
339
+ const ch = text.charCodeAt(pos);
340
+ switch (ch) {
341
+ case CharacterCodes.carriageReturn:
342
+ case CharacterCodes.lineFeed:
343
+ case CharacterCodes.tab:
344
+ case CharacterCodes.verticalTab:
345
+ case CharacterCodes.formFeed:
346
+ case CharacterCodes.space:
347
+ case CharacterCodes.slash:
348
+ case CharacterCodes.lessThan:
349
+ case CharacterCodes.bar:
350
+ case CharacterCodes.equals:
351
+ case CharacterCodes.greaterThan:
352
+ return true;
353
+ case CharacterCodes.hash:
354
+ return pos === 0;
355
+ default:
356
+ return ch > CharacterCodes.maxAsciiCharacter;
357
+ }
358
+ }
359
+ export function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) {
360
+ if (pos < 0) {
361
+ return pos;
362
+ }
363
+ let canConsumeStar = false;
364
+ while (true) {
365
+ const ch = text.charCodeAt(pos);
366
+ switch (ch) {
367
+ case CharacterCodes.carriageReturn:
368
+ if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
369
+ pos++;
370
+ }
371
+ // falls through
372
+ case CharacterCodes.lineFeed:
373
+ pos++;
374
+ if (stopAfterLineBreak) {
375
+ return pos;
376
+ }
377
+ canConsumeStar = !!inJSDoc;
378
+ continue;
379
+ case CharacterCodes.tab:
380
+ case CharacterCodes.verticalTab:
381
+ case CharacterCodes.formFeed:
382
+ case CharacterCodes.space:
383
+ pos++;
384
+ continue;
385
+ case CharacterCodes.slash:
386
+ if (stopAtComments) {
387
+ break;
388
+ }
389
+ if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
390
+ pos += 2;
391
+ while (pos < text.length) {
392
+ if (isLineBreak(text.charCodeAt(pos))) {
393
+ break;
394
+ }
395
+ pos++;
396
+ }
397
+ canConsumeStar = false;
398
+ continue;
399
+ }
400
+ if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
401
+ pos += 2;
402
+ while (pos < text.length) {
403
+ if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
404
+ pos += 2;
405
+ break;
406
+ }
407
+ pos++;
408
+ }
409
+ canConsumeStar = false;
410
+ continue;
411
+ }
412
+ break;
413
+ case CharacterCodes.lessThan:
414
+ case CharacterCodes.bar:
415
+ case CharacterCodes.equals:
416
+ case CharacterCodes.greaterThan:
417
+ if (isConflictMarkerTrivia(text, pos)) {
418
+ pos = scanConflictMarkerTrivia(text, pos);
419
+ canConsumeStar = false;
420
+ continue;
421
+ }
422
+ break;
423
+ case CharacterCodes.hash:
424
+ if (pos === 0 && isShebangTrivia(text, pos)) {
425
+ pos = scanShebangTrivia(text, pos);
426
+ continue;
427
+ }
428
+ break;
429
+ case CharacterCodes.asterisk:
430
+ if (canConsumeStar) {
431
+ pos++;
432
+ canConsumeStar = false;
433
+ continue;
434
+ }
435
+ break;
436
+ default:
437
+ if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
438
+ pos++;
439
+ continue;
440
+ }
441
+ break;
442
+ }
443
+ return pos;
444
+ }
445
+ }
446
+ function isConflictMarkerTrivia(text, pos) {
447
+ if (pos >= text.length) {
448
+ return false;
449
+ }
450
+ const ch = text.charCodeAt(pos);
451
+ if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
452
+ if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan || ch === CharacterCodes.equals) {
453
+ if (pos + 6 < text.length && text.charCodeAt(pos + 1) === ch && text.charCodeAt(pos + 2) === ch && text.charCodeAt(pos + 3) === ch && text.charCodeAt(pos + 4) === ch && text.charCodeAt(pos + 5) === ch && text.charCodeAt(pos + 6) === ch) {
454
+ return ch === CharacterCodes.equals || text.charCodeAt(pos + 7) === CharacterCodes.space;
455
+ }
456
+ }
457
+ if (ch === CharacterCodes.bar && pos + 6 < text.length && text.charCodeAt(pos + 1) === ch && text.charCodeAt(pos + 2) === ch && text.charCodeAt(pos + 3) === ch && text.charCodeAt(pos + 4) === ch && text.charCodeAt(pos + 5) === ch && text.charCodeAt(pos + 6) === ch) {
458
+ return true;
459
+ }
460
+ }
461
+ return false;
462
+ }
463
+ function scanConflictMarkerTrivia(text, pos) {
464
+ const ch = text.charCodeAt(pos);
465
+ const len = text.length;
466
+ if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) {
467
+ while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
468
+ pos++;
469
+ }
470
+ }
471
+ else {
472
+ // Consume everything from the start of a ||||||| or ======= marker to the start
473
+ // of the next ======= or >>>>>>> marker.
474
+ pos += 7; // skip marker
475
+ while (pos < len) {
476
+ const currentChar = text.charCodeAt(pos);
477
+ if ((currentChar === CharacterCodes.equals || currentChar === CharacterCodes.greaterThan) && isConflictMarkerTrivia(text, pos)) {
478
+ break;
479
+ }
480
+ pos++;
481
+ }
482
+ }
483
+ return pos;
484
+ }
485
+ function isShebangTrivia(text, pos) {
486
+ return pos === 0 && text.charCodeAt(0) === CharacterCodes.hash && text.charCodeAt(1) === CharacterCodes.exclamation;
487
+ }
488
+ function scanShebangTrivia(text, pos) {
489
+ pos += 2;
490
+ while (pos < text.length) {
491
+ if (isLineBreak(text.charCodeAt(pos))) {
492
+ break;
493
+ }
494
+ pos++;
495
+ }
496
+ return pos;
497
+ }
498
+ function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
499
+ let pendingPos;
500
+ let pendingEnd;
501
+ let pendingKind;
502
+ let pendingHasTrailingNewLine;
503
+ let hasPendingCommentRange = false;
504
+ let collecting = trailing;
505
+ let accumulator = initial;
506
+ if (pos === 0) {
507
+ collecting = true;
508
+ const shebang = getShebang(text);
509
+ if (shebang) {
510
+ pos = shebang.length;
511
+ }
512
+ }
513
+ scan: while (pos >= 0 && pos < text.length) {
514
+ const ch = text.charCodeAt(pos);
515
+ switch (ch) {
516
+ case CharacterCodes.carriageReturn:
517
+ if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
518
+ pos++;
519
+ }
520
+ // falls through
521
+ case CharacterCodes.lineFeed:
522
+ pos++;
523
+ if (trailing) {
524
+ break scan;
525
+ }
526
+ collecting = true;
527
+ if (hasPendingCommentRange) {
528
+ pendingHasTrailingNewLine = true;
529
+ }
530
+ continue;
531
+ case CharacterCodes.tab:
532
+ case CharacterCodes.verticalTab:
533
+ case CharacterCodes.formFeed:
534
+ case CharacterCodes.space:
535
+ pos++;
536
+ continue;
537
+ case CharacterCodes.slash:
538
+ const nextChar = text.charCodeAt(pos + 1);
539
+ let hasTrailingNewLine = false;
540
+ if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) {
541
+ const kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia;
542
+ const startPos = pos;
543
+ pos += 2;
544
+ if (nextChar === CharacterCodes.slash) {
545
+ while (pos < text.length) {
546
+ if (isLineBreak(text.charCodeAt(pos))) {
547
+ hasTrailingNewLine = true;
548
+ break;
549
+ }
550
+ pos++;
551
+ }
552
+ }
553
+ else {
554
+ while (pos < text.length) {
555
+ if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
556
+ pos += 2;
557
+ break;
558
+ }
559
+ pos++;
560
+ }
561
+ }
562
+ if (collecting) {
563
+ if (hasPendingCommentRange) {
564
+ accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
565
+ if (!reduce && accumulator) {
566
+ return accumulator;
567
+ }
568
+ }
569
+ pendingPos = startPos;
570
+ pendingEnd = pos;
571
+ pendingKind = kind;
572
+ pendingHasTrailingNewLine = hasTrailingNewLine;
573
+ hasPendingCommentRange = true;
574
+ }
575
+ continue;
576
+ }
577
+ break scan;
578
+ default:
579
+ if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
580
+ if (hasPendingCommentRange && isLineBreak(ch)) {
581
+ pendingHasTrailingNewLine = true;
582
+ }
583
+ pos++;
584
+ continue;
585
+ }
586
+ break scan;
587
+ }
588
+ }
589
+ if (hasPendingCommentRange) {
590
+ accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
591
+ }
592
+ return accumulator;
593
+ }
594
+ function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments = []) {
595
+ comments.push({ kind, pos, end, hasTrailingNewLine });
596
+ return comments;
597
+ }
598
+ export function forEachLeadingCommentRange(text, pos, cb, state) {
599
+ return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state, /*initial*/ undefined);
600
+ }
601
+ export function forEachTrailingCommentRange(text, pos, cb, state) {
602
+ return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state, /*initial*/ undefined);
603
+ }
604
+ export function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
605
+ return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ false, cb, state, initial);
606
+ }
607
+ export function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
608
+ return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial);
609
+ }
610
+ export function getLeadingCommentRanges(text, pos) {
611
+ return reduceEachLeadingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined);
612
+ }
613
+ export function getTrailingCommentRanges(text, pos) {
614
+ return reduceEachTrailingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined);
615
+ }
616
+ export function getShebang(text) {
617
+ const shebang = /^#!.*/;
618
+ if (isShebangTrivia(text, 0)) {
619
+ const match = shebang.exec(text);
620
+ if (match) {
621
+ return match[0];
622
+ }
623
+ }
624
+ return undefined;
625
+ }
626
+ export function isIdentifierStart(ch, _languageVersion) {
627
+ return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
628
+ ch === CharacterCodes.$ || ch === CharacterCodes._ ||
629
+ ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch);
630
+ }
631
+ export function isIdentifierPart(ch, _languageVersion, identifierVariant) {
632
+ return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
633
+ ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ ||
634
+ // "-" and ":" are valid in JSX Identifiers
635
+ (identifierVariant === LanguageVariant.JSX ? (ch === CharacterCodes.minus || ch === CharacterCodes.colon) : false) ||
636
+ ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch);
637
+ }
638
+ export function isIdentifierText(name, _languageVersion, identifierVariant) {
639
+ let ch = name.codePointAt(0);
640
+ if (!isIdentifierStart(ch)) {
641
+ return false;
642
+ }
643
+ for (let i = charSize(ch); i < name.length; i += charSize(ch)) {
644
+ if (!isIdentifierPart(ch = name.codePointAt(i), undefined, identifierVariant)) {
645
+ return false;
646
+ }
647
+ }
648
+ return true;
649
+ }
650
+ function codePointAt(s, i) {
651
+ return s.codePointAt(i);
652
+ }
653
+ function charSize(ch) {
654
+ if (ch >= 0x10000) {
655
+ return 2;
656
+ }
657
+ if (ch === CharacterCodes.EOF) {
658
+ return 0;
659
+ }
660
+ return 1;
661
+ }
662
+ export function utf16EncodeAsString(codePoint) {
663
+ return String.fromCodePoint(codePoint);
664
+ }
665
+ function parsePseudoBigInt(stringValue) {
666
+ let log2Base;
667
+ switch (stringValue.charCodeAt(1)) {
668
+ case CharacterCodes.b:
669
+ case CharacterCodes.B:
670
+ log2Base = 1;
671
+ break;
672
+ case CharacterCodes.o:
673
+ case CharacterCodes.O:
674
+ log2Base = 3;
675
+ break;
676
+ case CharacterCodes.x:
677
+ case CharacterCodes.X:
678
+ log2Base = 4;
679
+ break;
680
+ default:
681
+ // decimals for now just peel the trailing "n" and return
682
+ const nIndex = stringValue.length - 1;
683
+ let nonZeroStart = 0;
684
+ while (stringValue.charCodeAt(nonZeroStart) === CharacterCodes._0) {
685
+ nonZeroStart++;
686
+ }
687
+ return stringValue.slice(nonZeroStart, nIndex) || "0";
688
+ }
689
+ // exit early for zero
690
+ const startIndex = 2;
691
+ const endIndex = stringValue.length - 1;
692
+ const bitsNeeded = (endIndex - startIndex) * log2Base;
693
+ // Stores the value specified by the string as a LE array of 16-bit integers
694
+ // using Uint16 instead of Uint32 so combining steps can use bitwise operators
695
+ const segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
696
+ // Add the digits, one at a time
697
+ for (let i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
698
+ const segment = bitOffset >>> 4;
699
+ const digitChar = stringValue.charCodeAt(i);
700
+ // Find character value
701
+ const digit = digitChar <= CharacterCodes._9
702
+ ? digitChar - CharacterCodes._0
703
+ : 10 + digitChar - (digitChar <= CharacterCodes.F ? CharacterCodes.A : CharacterCodes.a);
704
+ // Add bits into segment
705
+ const shiftedDigit = digit << (bitOffset & 15);
706
+ segments[segment] |= shiftedDigit;
707
+ // overflow to next segment
708
+ const residual = shiftedDigit >>> 16;
709
+ if (residual)
710
+ segments[segment + 1] |= residual;
711
+ }
712
+ // Repeatedly divide by 10 to find each decimal digit
713
+ let base10Value = "";
714
+ let firstNonzeroSegment = segments.length - 1;
715
+ let segmentsRemaining = true;
716
+ while (segmentsRemaining) {
717
+ let mod10 = 0;
718
+ segmentsRemaining = false;
719
+ for (let segment = firstNonzeroSegment; segment >= 0; segment--) {
720
+ const newSegment = mod10 << 16 | segments[segment];
721
+ const segmentValue = (newSegment / 10) | 0;
722
+ segments[segment] = segmentValue;
723
+ mod10 = newSegment - segmentValue * 10;
724
+ if (segmentValue && !segmentsRemaining) {
725
+ firstNonzeroSegment = segment;
726
+ segmentsRemaining = true;
727
+ }
728
+ }
729
+ base10Value = mod10 + base10Value;
730
+ }
731
+ return base10Value;
732
+ }
733
+ // Creates a scanner over a (possibly unspecified) range of a piece of text.
734
+ export function createScanner(skipTrivia, languageVariant = LanguageVariant.Standard, textInitial, start, length) {
735
+ // Why var? It avoids TDZ checks in the runtime which can be costly.
736
+ // See: https://github.com/microsoft/TypeScript/issues/52924
737
+ /* eslint-disable no-var */
738
+ var text = textInitial;
739
+ // Current position (end position of text of current token)
740
+ var pos;
741
+ // end of text
742
+ var end;
743
+ // Start position of whitespace before current token
744
+ var fullStartPos;
745
+ // Start position of text of current token
746
+ var tokenStart;
747
+ var token;
748
+ var tokenValue;
749
+ var tokenFlags;
750
+ var commentDirectives;
751
+ var skipJsDocLeadingAsterisks = 0;
752
+ setText(text, start, length);
753
+ var scanner = {
754
+ getTokenFullStart: () => fullStartPos,
755
+ getTokenEnd: () => pos,
756
+ getToken: () => token,
757
+ getTokenStart: () => tokenStart,
758
+ getTokenText: () => text.substring(tokenStart, pos),
759
+ getTokenValue: () => tokenValue,
760
+ hasUnicodeEscape: () => (tokenFlags & TokenFlags.UnicodeEscape) !== 0,
761
+ hasExtendedUnicodeEscape: () => (tokenFlags & TokenFlags.ExtendedUnicodeEscape) !== 0,
762
+ hasPrecedingLineBreak: () => (tokenFlags & TokenFlags.PrecedingLineBreak) !== 0,
763
+ hasPrecedingJSDocComment: () => (tokenFlags & TokenFlags.PrecedingJSDocComment) !== 0,
764
+ hasPrecedingJSDocLeadingAsterisks: () => (tokenFlags & TokenFlags.PrecedingJSDocLeadingAsterisks) !== 0,
765
+ hasPrecedingJSDocWithDeprecatedTag: () => (tokenFlags & TokenFlags.PrecedingJSDocWithDeprecated) !== 0,
766
+ hasPrecedingJSDocWithSeeOrLink: () => (tokenFlags & TokenFlags.PrecedingJSDocWithSeeOrLink) !== 0,
767
+ isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
768
+ isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
769
+ isUnterminated: () => (tokenFlags & TokenFlags.Unterminated) !== 0,
770
+ getCommentDirectives: () => commentDirectives,
771
+ getNumericLiteralFlags: () => tokenFlags & TokenFlags.NumericLiteralFlags,
772
+ getTokenFlags: () => tokenFlags,
773
+ reScanGreaterToken,
774
+ reScanAsteriskEqualsToken,
775
+ reScanSlashToken,
776
+ reScanTemplateToken,
777
+ reScanTemplateHeadOrNoSubstitutionTemplate,
778
+ scanJsxIdentifier,
779
+ scanJsxAttributeValue,
780
+ reScanJsxAttributeValue,
781
+ reScanJsxToken,
782
+ reScanLessThanToken,
783
+ reScanHashToken,
784
+ reScanQuestionToken,
785
+ reScanInvalidIdentifier,
786
+ scanJsxToken,
787
+ scanJsDocToken,
788
+ scanJSDocCommentTextToken,
789
+ scan,
790
+ getText,
791
+ clearCommentDirectives,
792
+ setText,
793
+ setLanguageVariant,
794
+ resetTokenState,
795
+ setSkipJsDocLeadingAsterisks,
796
+ tryScan,
797
+ lookAhead,
798
+ scanRange,
799
+ };
800
+ /* eslint-enable no-var */
801
+ return scanner;
802
+ function codePointUnchecked(pos) {
803
+ return codePointAt(text, pos);
804
+ }
805
+ function codePointChecked(pos) {
806
+ return pos >= 0 && pos < end ? codePointUnchecked(pos) : CharacterCodes.EOF;
807
+ }
808
+ function charCodeUnchecked(pos) {
809
+ return text.charCodeAt(pos);
810
+ }
811
+ function charCodeChecked(pos) {
812
+ return pos >= 0 && pos < end ? charCodeUnchecked(pos) : CharacterCodes.EOF;
813
+ }
814
+ function scanNumberFragment() {
815
+ let start = pos;
816
+ let allowSeparator = false;
817
+ let isPreviousTokenSeparator = false;
818
+ let result = "";
819
+ while (true) {
820
+ const ch = charCodeUnchecked(pos);
821
+ if (ch === CharacterCodes._) {
822
+ tokenFlags |= TokenFlags.ContainsSeparator;
823
+ if (allowSeparator) {
824
+ allowSeparator = false;
825
+ isPreviousTokenSeparator = true;
826
+ result += text.substring(start, pos);
827
+ }
828
+ else {
829
+ tokenFlags |= TokenFlags.ContainsInvalidSeparator;
830
+ }
831
+ pos++;
832
+ start = pos;
833
+ continue;
834
+ }
835
+ if (isDigit(ch)) {
836
+ allowSeparator = true;
837
+ isPreviousTokenSeparator = false;
838
+ pos++;
839
+ continue;
840
+ }
841
+ break;
842
+ }
843
+ if (charCodeUnchecked(pos - 1) === CharacterCodes._) {
844
+ tokenFlags |= TokenFlags.ContainsInvalidSeparator;
845
+ }
846
+ return result + text.substring(start, pos);
847
+ }
848
+ function scanNumber() {
849
+ let start = pos;
850
+ let mainFragment;
851
+ if (charCodeUnchecked(pos) === CharacterCodes._0) {
852
+ pos++;
853
+ if (charCodeUnchecked(pos) === CharacterCodes._) {
854
+ tokenFlags |= TokenFlags.ContainsSeparator | TokenFlags.ContainsInvalidSeparator;
855
+ pos--;
856
+ mainFragment = scanNumberFragment();
857
+ }
858
+ else if (!scanDigits()) {
859
+ tokenFlags |= TokenFlags.ContainsLeadingZero;
860
+ mainFragment = "" + +tokenValue;
861
+ }
862
+ else if (!tokenValue) {
863
+ mainFragment = "0";
864
+ }
865
+ else {
866
+ tokenValue = "" + parseInt(tokenValue, 8);
867
+ tokenFlags |= TokenFlags.Octal;
868
+ const withMinus = token === SyntaxKind.MinusToken;
869
+ const literal = (withMinus ? "-" : "") + "0o" + (+tokenValue).toString(8);
870
+ if (withMinus)
871
+ start--;
872
+ return SyntaxKind.NumericLiteral;
873
+ }
874
+ }
875
+ else {
876
+ mainFragment = scanNumberFragment();
877
+ }
878
+ let decimalFragment;
879
+ let scientificFragment;
880
+ if (charCodeUnchecked(pos) === CharacterCodes.dot) {
881
+ pos++;
882
+ decimalFragment = scanNumberFragment();
883
+ }
884
+ let end = pos;
885
+ if (charCodeUnchecked(pos) === CharacterCodes.E || charCodeUnchecked(pos) === CharacterCodes.e) {
886
+ pos++;
887
+ tokenFlags |= TokenFlags.Scientific;
888
+ if (charCodeUnchecked(pos) === CharacterCodes.plus || charCodeUnchecked(pos) === CharacterCodes.minus)
889
+ pos++;
890
+ const preNumericPart = pos;
891
+ const finalFragment = scanNumberFragment();
892
+ if (finalFragment) {
893
+ scientificFragment = text.substring(end, preNumericPart) + finalFragment;
894
+ end = pos;
895
+ }
896
+ }
897
+ let result;
898
+ if (tokenFlags & TokenFlags.ContainsSeparator) {
899
+ result = mainFragment;
900
+ if (decimalFragment) {
901
+ result += "." + decimalFragment;
902
+ }
903
+ if (scientificFragment) {
904
+ result += scientificFragment;
905
+ }
906
+ }
907
+ else {
908
+ result = text.substring(start, end);
909
+ }
910
+ if (tokenFlags & TokenFlags.ContainsLeadingZero) {
911
+ tokenValue = "" + +result;
912
+ return SyntaxKind.NumericLiteral;
913
+ }
914
+ if (decimalFragment !== undefined || tokenFlags & TokenFlags.Scientific) {
915
+ checkForIdentifierStartAfterNumericLiteral();
916
+ tokenValue = "" + +result;
917
+ return SyntaxKind.NumericLiteral;
918
+ }
919
+ else {
920
+ tokenValue = result;
921
+ const type = checkBigIntSuffix();
922
+ checkForIdentifierStartAfterNumericLiteral();
923
+ return type;
924
+ }
925
+ }
926
+ function checkForIdentifierStartAfterNumericLiteral() {
927
+ if (!isIdentifierStart(codePointUnchecked(pos))) {
928
+ return;
929
+ }
930
+ const identifierStart = pos;
931
+ const { length } = scanIdentifierParts();
932
+ if (!(length === 1 && text[identifierStart] === "n")) {
933
+ pos = identifierStart;
934
+ }
935
+ }
936
+ function scanDigits() {
937
+ const start = pos;
938
+ let isOctal = true;
939
+ while (isDigit(charCodeChecked(pos))) {
940
+ if (!isOctalDigit(charCodeUnchecked(pos))) {
941
+ isOctal = false;
942
+ }
943
+ pos++;
944
+ }
945
+ tokenValue = text.substring(start, pos);
946
+ return isOctal;
947
+ }
948
+ function scanExactNumberOfHexDigits(count, canHaveSeparators) {
949
+ const valueString = scanHexDigits(count, /*scanAsManyAsPossible*/ false, canHaveSeparators);
950
+ return valueString ? parseInt(valueString, 16) : -1;
951
+ }
952
+ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
953
+ return scanHexDigits(count, /*scanAsManyAsPossible*/ true, canHaveSeparators);
954
+ }
955
+ function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
956
+ let valueChars = [];
957
+ let allowSeparator = false;
958
+ while (valueChars.length < minCount || scanAsManyAsPossible) {
959
+ let ch = charCodeUnchecked(pos);
960
+ if (canHaveSeparators && ch === CharacterCodes._) {
961
+ tokenFlags |= TokenFlags.ContainsSeparator;
962
+ if (allowSeparator) {
963
+ allowSeparator = false;
964
+ }
965
+ pos++;
966
+ continue;
967
+ }
968
+ allowSeparator = canHaveSeparators;
969
+ if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {
970
+ ch += CharacterCodes.a - CharacterCodes.A;
971
+ }
972
+ else if (!((ch >= CharacterCodes._0 && ch <= CharacterCodes._9) ||
973
+ (ch >= CharacterCodes.a && ch <= CharacterCodes.f))) {
974
+ break;
975
+ }
976
+ valueChars.push(ch);
977
+ pos++;
978
+ }
979
+ if (valueChars.length < minCount) {
980
+ valueChars = [];
981
+ }
982
+ return String.fromCharCode(...valueChars);
983
+ }
984
+ function scanString(jsxAttributeString = false) {
985
+ const quote = charCodeUnchecked(pos);
986
+ pos++;
987
+ let result = "";
988
+ let start = pos;
989
+ while (true) {
990
+ if (pos >= end) {
991
+ result += text.substring(start, pos);
992
+ tokenFlags |= TokenFlags.Unterminated;
993
+ break;
994
+ }
995
+ const ch = charCodeUnchecked(pos);
996
+ if (ch === quote) {
997
+ result += text.substring(start, pos);
998
+ pos++;
999
+ break;
1000
+ }
1001
+ if (ch === CharacterCodes.backslash && !jsxAttributeString) {
1002
+ result += text.substring(start, pos);
1003
+ result += scanEscapeSequence(EscapeSequenceScanningFlags.String | EscapeSequenceScanningFlags.ReportErrors);
1004
+ start = pos;
1005
+ continue;
1006
+ }
1007
+ if ((ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn) && !jsxAttributeString) {
1008
+ result += text.substring(start, pos);
1009
+ tokenFlags |= TokenFlags.Unterminated;
1010
+ break;
1011
+ }
1012
+ pos++;
1013
+ }
1014
+ return result;
1015
+ }
1016
+ function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
1017
+ const startedWithBacktick = charCodeUnchecked(pos) === CharacterCodes.backtick;
1018
+ pos++;
1019
+ let start = pos;
1020
+ let contents = "";
1021
+ let resultingToken;
1022
+ while (true) {
1023
+ if (pos >= end) {
1024
+ contents += text.substring(start, pos);
1025
+ tokenFlags |= TokenFlags.Unterminated;
1026
+ resultingToken = startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateLiteral : SyntaxKind.TemplateTail;
1027
+ break;
1028
+ }
1029
+ const currChar = charCodeUnchecked(pos);
1030
+ if (currChar === CharacterCodes.backtick) {
1031
+ contents += text.substring(start, pos);
1032
+ pos++;
1033
+ resultingToken = startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateLiteral : SyntaxKind.TemplateTail;
1034
+ break;
1035
+ }
1036
+ if (currChar === CharacterCodes.$ && pos + 1 < end && charCodeUnchecked(pos + 1) === CharacterCodes.openBrace) {
1037
+ contents += text.substring(start, pos);
1038
+ pos += 2;
1039
+ resultingToken = startedWithBacktick ? SyntaxKind.TemplateHead : SyntaxKind.TemplateMiddle;
1040
+ break;
1041
+ }
1042
+ if (currChar === CharacterCodes.backslash) {
1043
+ contents += text.substring(start, pos);
1044
+ contents += scanEscapeSequence(EscapeSequenceScanningFlags.String | (shouldEmitInvalidEscapeError ? EscapeSequenceScanningFlags.ReportErrors : 0));
1045
+ start = pos;
1046
+ continue;
1047
+ }
1048
+ if (currChar === CharacterCodes.carriageReturn) {
1049
+ contents += text.substring(start, pos);
1050
+ pos++;
1051
+ if (pos < end && charCodeUnchecked(pos) === CharacterCodes.lineFeed) {
1052
+ pos++;
1053
+ }
1054
+ contents += "\n";
1055
+ start = pos;
1056
+ continue;
1057
+ }
1058
+ pos++;
1059
+ }
1060
+ tokenValue = contents;
1061
+ return resultingToken;
1062
+ }
1063
+ function scanEscapeSequence(flags) {
1064
+ const start = pos;
1065
+ pos++;
1066
+ if (pos >= end) {
1067
+ return "";
1068
+ }
1069
+ const ch = charCodeUnchecked(pos);
1070
+ pos++;
1071
+ switch (ch) {
1072
+ case CharacterCodes._0:
1073
+ if (pos >= end || !isDigit(charCodeUnchecked(pos))) {
1074
+ return "\0";
1075
+ }
1076
+ // falls through
1077
+ case CharacterCodes._1:
1078
+ case CharacterCodes._2:
1079
+ case CharacterCodes._3:
1080
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
1081
+ pos++;
1082
+ }
1083
+ // falls through
1084
+ case CharacterCodes._4:
1085
+ case CharacterCodes._5:
1086
+ case CharacterCodes._6:
1087
+ case CharacterCodes._7:
1088
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
1089
+ pos++;
1090
+ }
1091
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1092
+ if (flags & EscapeSequenceScanningFlags.ReportInvalidEscapeErrors) {
1093
+ const code = parseInt(text.substring(start + 1, pos), 8);
1094
+ return String.fromCharCode(code);
1095
+ }
1096
+ return text.substring(start, pos);
1097
+ case CharacterCodes._8:
1098
+ case CharacterCodes._9:
1099
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1100
+ if (flags & EscapeSequenceScanningFlags.ReportInvalidEscapeErrors) {
1101
+ return String.fromCharCode(ch);
1102
+ }
1103
+ return text.substring(start, pos);
1104
+ case CharacterCodes.b:
1105
+ return "\b";
1106
+ case CharacterCodes.t:
1107
+ return "\t";
1108
+ case CharacterCodes.n:
1109
+ return "\n";
1110
+ case CharacterCodes.v:
1111
+ return "\v";
1112
+ case CharacterCodes.f:
1113
+ return "\f";
1114
+ case CharacterCodes.r:
1115
+ return "\r";
1116
+ case CharacterCodes.singleQuote:
1117
+ return "'";
1118
+ case CharacterCodes.doubleQuote:
1119
+ return '"';
1120
+ case CharacterCodes.u:
1121
+ if (pos < end && charCodeUnchecked(pos) === CharacterCodes.openBrace) {
1122
+ pos -= 2;
1123
+ const result = scanExtendedUnicodeEscape();
1124
+ if (!(flags & EscapeSequenceScanningFlags.AllowExtendedUnicodeEscape)) {
1125
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1126
+ }
1127
+ return result;
1128
+ }
1129
+ // '\uDDDD'
1130
+ for (; pos < start + 6; pos++) {
1131
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
1132
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1133
+ return text.substring(start, pos);
1134
+ }
1135
+ }
1136
+ tokenFlags |= TokenFlags.UnicodeEscape;
1137
+ {
1138
+ const escapedValue = parseInt(text.substring(start + 2, pos), 16);
1139
+ const escapedValueString = String.fromCharCode(escapedValue);
1140
+ if (flags & EscapeSequenceScanningFlags.AnyUnicodeMode && escapedValue >= 0xD800 && escapedValue <= 0xDBFF &&
1141
+ pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== CharacterCodes.openBrace) {
1142
+ const nextStart = pos;
1143
+ let nextPos = pos + 2;
1144
+ for (; nextPos < nextStart + 6; nextPos++) {
1145
+ if (!isHexDigit(charCodeUnchecked(nextPos))) {
1146
+ return escapedValueString;
1147
+ }
1148
+ }
1149
+ const nextEscapedValue = parseInt(text.substring(nextStart + 2, nextPos), 16);
1150
+ if (nextEscapedValue >= 0xDC00 && nextEscapedValue <= 0xDFFF) {
1151
+ pos = nextPos;
1152
+ return escapedValueString + String.fromCharCode(nextEscapedValue);
1153
+ }
1154
+ }
1155
+ return escapedValueString;
1156
+ }
1157
+ case CharacterCodes.x:
1158
+ for (; pos < start + 4; pos++) {
1159
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
1160
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1161
+ return text.substring(start, pos);
1162
+ }
1163
+ }
1164
+ tokenFlags |= TokenFlags.HexEscape;
1165
+ return String.fromCharCode(parseInt(text.substring(start + 2, pos), 16));
1166
+ case CharacterCodes.carriageReturn:
1167
+ if (pos < end && charCodeUnchecked(pos) === CharacterCodes.lineFeed) {
1168
+ pos++;
1169
+ }
1170
+ // falls through
1171
+ case CharacterCodes.lineFeed:
1172
+ case CharacterCodes.lineSeparator:
1173
+ case CharacterCodes.paragraphSeparator:
1174
+ return "";
1175
+ default:
1176
+ return String.fromCharCode(ch);
1177
+ }
1178
+ }
1179
+ function scanExtendedUnicodeEscape() {
1180
+ const start = pos;
1181
+ pos += 3;
1182
+ const escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
1183
+ const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
1184
+ let isInvalidExtendedEscape = false;
1185
+ if (escapedValue < 0) {
1186
+ isInvalidExtendedEscape = true;
1187
+ }
1188
+ else if (escapedValue > 0x10FFFF) {
1189
+ isInvalidExtendedEscape = true;
1190
+ }
1191
+ if (pos >= end) {
1192
+ isInvalidExtendedEscape = true;
1193
+ }
1194
+ else if (charCodeUnchecked(pos) === CharacterCodes.closeBrace) {
1195
+ pos++;
1196
+ }
1197
+ else {
1198
+ isInvalidExtendedEscape = true;
1199
+ }
1200
+ if (isInvalidExtendedEscape) {
1201
+ tokenFlags |= TokenFlags.ContainsInvalidEscape;
1202
+ return text.substring(start, pos);
1203
+ }
1204
+ tokenFlags |= TokenFlags.ExtendedUnicodeEscape;
1205
+ return utf16EncodeAsString(escapedValue);
1206
+ }
1207
+ function peekUnicodeEscape() {
1208
+ if (pos + 5 < end && charCodeUnchecked(pos + 1) === CharacterCodes.u) {
1209
+ const start = pos;
1210
+ pos += 2;
1211
+ const value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false);
1212
+ pos = start;
1213
+ return value;
1214
+ }
1215
+ return -1;
1216
+ }
1217
+ function peekExtendedUnicodeEscape() {
1218
+ if (codePointUnchecked(pos + 1) === CharacterCodes.u && codePointUnchecked(pos + 2) === CharacterCodes.openBrace) {
1219
+ const start = pos;
1220
+ pos += 3;
1221
+ const escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
1222
+ const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
1223
+ pos = start;
1224
+ return escapedValue;
1225
+ }
1226
+ return -1;
1227
+ }
1228
+ function scanIdentifierParts() {
1229
+ let result = "";
1230
+ let start = pos;
1231
+ while (pos < end) {
1232
+ let ch = codePointUnchecked(pos);
1233
+ if (isIdentifierPart(ch)) {
1234
+ pos += charSize(ch);
1235
+ }
1236
+ else if (ch === CharacterCodes.backslash) {
1237
+ ch = peekExtendedUnicodeEscape();
1238
+ if (ch >= 0 && isIdentifierPart(ch)) {
1239
+ result += scanExtendedUnicodeEscape();
1240
+ start = pos;
1241
+ continue;
1242
+ }
1243
+ ch = peekUnicodeEscape();
1244
+ if (!(ch >= 0 && isIdentifierPart(ch))) {
1245
+ break;
1246
+ }
1247
+ tokenFlags |= TokenFlags.UnicodeEscape;
1248
+ result += text.substring(start, pos);
1249
+ result += utf16EncodeAsString(ch);
1250
+ pos += 6;
1251
+ start = pos;
1252
+ }
1253
+ else {
1254
+ break;
1255
+ }
1256
+ }
1257
+ result += text.substring(start, pos);
1258
+ return result;
1259
+ }
1260
+ function getIdentifierToken() {
1261
+ const len = tokenValue.length;
1262
+ if (len >= 2 && len <= 12) {
1263
+ const ch = tokenValue.charCodeAt(0);
1264
+ if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) {
1265
+ const keyword = textToKeyword.get(tokenValue);
1266
+ if (keyword !== undefined) {
1267
+ return token = keyword;
1268
+ }
1269
+ }
1270
+ }
1271
+ return token = SyntaxKind.Identifier;
1272
+ }
1273
+ function scanBinaryOrOctalDigits(base) {
1274
+ let value = "";
1275
+ let separatorAllowed = false;
1276
+ let isPreviousTokenSeparator = false;
1277
+ while (true) {
1278
+ const ch = charCodeUnchecked(pos);
1279
+ if (ch === CharacterCodes._) {
1280
+ tokenFlags |= TokenFlags.ContainsSeparator;
1281
+ if (separatorAllowed) {
1282
+ separatorAllowed = false;
1283
+ isPreviousTokenSeparator = true;
1284
+ }
1285
+ pos++;
1286
+ continue;
1287
+ }
1288
+ separatorAllowed = true;
1289
+ if (!isDigit(ch) || ch - CharacterCodes._0 >= base) {
1290
+ break;
1291
+ }
1292
+ value += text[pos];
1293
+ pos++;
1294
+ isPreviousTokenSeparator = false;
1295
+ }
1296
+ return value;
1297
+ }
1298
+ function checkBigIntSuffix() {
1299
+ if (charCodeUnchecked(pos) === CharacterCodes.n) {
1300
+ tokenValue += "n";
1301
+ if (tokenFlags & TokenFlags.BinaryOrOctalSpecifier) {
1302
+ tokenValue = parsePseudoBigInt(tokenValue) + "n";
1303
+ }
1304
+ pos++;
1305
+ return SyntaxKind.BigIntLiteral;
1306
+ }
1307
+ else {
1308
+ const numericValue = tokenFlags & TokenFlags.BinarySpecifier
1309
+ ? parseInt(tokenValue.slice(2), 2)
1310
+ : tokenFlags & TokenFlags.OctalSpecifier
1311
+ ? parseInt(tokenValue.slice(2), 8)
1312
+ : +tokenValue;
1313
+ tokenValue = "" + numericValue;
1314
+ return SyntaxKind.NumericLiteral;
1315
+ }
1316
+ }
1317
+ function scan() {
1318
+ fullStartPos = pos;
1319
+ tokenFlags = TokenFlags.None;
1320
+ while (true) {
1321
+ tokenStart = pos;
1322
+ if (pos >= end) {
1323
+ return token = SyntaxKind.EndOfFile;
1324
+ }
1325
+ const ch = codePointUnchecked(pos);
1326
+ if (pos === 0) {
1327
+ if (ch === CharacterCodes.hash && isShebangTrivia(text, pos)) {
1328
+ pos = scanShebangTrivia(text, pos);
1329
+ if (skipTrivia) {
1330
+ continue;
1331
+ }
1332
+ else {
1333
+ return token = SyntaxKind.Unknown;
1334
+ }
1335
+ }
1336
+ }
1337
+ switch (ch) {
1338
+ case CharacterCodes.lineFeed:
1339
+ case CharacterCodes.carriageReturn:
1340
+ tokenFlags |= TokenFlags.PrecedingLineBreak;
1341
+ if (skipTrivia) {
1342
+ pos++;
1343
+ continue;
1344
+ }
1345
+ else {
1346
+ if (ch === CharacterCodes.carriageReturn && pos + 1 < end && charCodeUnchecked(pos + 1) === CharacterCodes.lineFeed) {
1347
+ pos += 2;
1348
+ }
1349
+ else {
1350
+ pos++;
1351
+ }
1352
+ return token = SyntaxKind.NewLineTrivia;
1353
+ }
1354
+ case CharacterCodes.tab:
1355
+ case CharacterCodes.verticalTab:
1356
+ case CharacterCodes.formFeed:
1357
+ case CharacterCodes.space:
1358
+ case CharacterCodes.nonBreakingSpace:
1359
+ case CharacterCodes.ogham:
1360
+ case CharacterCodes.enQuad:
1361
+ case CharacterCodes.emQuad:
1362
+ case CharacterCodes.enSpace:
1363
+ case CharacterCodes.emSpace:
1364
+ case CharacterCodes.threePerEmSpace:
1365
+ case CharacterCodes.fourPerEmSpace:
1366
+ case CharacterCodes.sixPerEmSpace:
1367
+ case CharacterCodes.figureSpace:
1368
+ case CharacterCodes.punctuationSpace:
1369
+ case CharacterCodes.thinSpace:
1370
+ case CharacterCodes.hairSpace:
1371
+ case CharacterCodes.zeroWidthSpace:
1372
+ case CharacterCodes.narrowNoBreakSpace:
1373
+ case CharacterCodes.mathematicalSpace:
1374
+ case CharacterCodes.ideographicSpace:
1375
+ case CharacterCodes.byteOrderMark:
1376
+ if (skipTrivia) {
1377
+ pos++;
1378
+ continue;
1379
+ }
1380
+ else {
1381
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
1382
+ pos++;
1383
+ }
1384
+ return token = SyntaxKind.WhitespaceTrivia;
1385
+ }
1386
+ case CharacterCodes.exclamation:
1387
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1388
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1389
+ return pos += 3, token = SyntaxKind.ExclamationEqualsEqualsToken;
1390
+ }
1391
+ return pos += 2, token = SyntaxKind.ExclamationEqualsToken;
1392
+ }
1393
+ pos++;
1394
+ return token = SyntaxKind.ExclamationToken;
1395
+ case CharacterCodes.doubleQuote:
1396
+ case CharacterCodes.singleQuote:
1397
+ tokenValue = scanString();
1398
+ return token = SyntaxKind.StringLiteral;
1399
+ case CharacterCodes.backtick:
1400
+ return token = scanTemplateAndSetTokenValue(/*shouldEmitInvalidEscapeError*/ false);
1401
+ case CharacterCodes.percent:
1402
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1403
+ return pos += 2, token = SyntaxKind.PercentEqualsToken;
1404
+ }
1405
+ pos++;
1406
+ return token = SyntaxKind.PercentToken;
1407
+ case CharacterCodes.ampersand:
1408
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.ampersand) {
1409
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1410
+ return pos += 3, token = SyntaxKind.AmpersandAmpersandEqualsToken;
1411
+ }
1412
+ return pos += 2, token = SyntaxKind.AmpersandAmpersandToken;
1413
+ }
1414
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1415
+ return pos += 2, token = SyntaxKind.AmpersandEqualsToken;
1416
+ }
1417
+ pos++;
1418
+ return token = SyntaxKind.AmpersandToken;
1419
+ case CharacterCodes.openParen:
1420
+ pos++;
1421
+ return token = SyntaxKind.OpenParenToken;
1422
+ case CharacterCodes.closeParen:
1423
+ pos++;
1424
+ return token = SyntaxKind.CloseParenToken;
1425
+ case CharacterCodes.asterisk:
1426
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1427
+ return pos += 2, token = SyntaxKind.AsteriskEqualsToken;
1428
+ }
1429
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.asterisk) {
1430
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1431
+ return pos += 3, token = SyntaxKind.AsteriskAsteriskEqualsToken;
1432
+ }
1433
+ return pos += 2, token = SyntaxKind.AsteriskAsteriskToken;
1434
+ }
1435
+ pos++;
1436
+ if (skipJsDocLeadingAsterisks &&
1437
+ (tokenFlags & TokenFlags.PrecedingJSDocLeadingAsterisks) === 0 &&
1438
+ (tokenFlags & TokenFlags.PrecedingLineBreak)) {
1439
+ tokenFlags |= TokenFlags.PrecedingJSDocLeadingAsterisks;
1440
+ continue;
1441
+ }
1442
+ return token = SyntaxKind.AsteriskToken;
1443
+ case CharacterCodes.plus:
1444
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.plus) {
1445
+ return pos += 2, token = SyntaxKind.PlusPlusToken;
1446
+ }
1447
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1448
+ return pos += 2, token = SyntaxKind.PlusEqualsToken;
1449
+ }
1450
+ pos++;
1451
+ return token = SyntaxKind.PlusToken;
1452
+ case CharacterCodes.comma:
1453
+ pos++;
1454
+ return token = SyntaxKind.CommaToken;
1455
+ case CharacterCodes.minus:
1456
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.minus) {
1457
+ return pos += 2, token = SyntaxKind.MinusMinusToken;
1458
+ }
1459
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1460
+ return pos += 2, token = SyntaxKind.MinusEqualsToken;
1461
+ }
1462
+ pos++;
1463
+ return token = SyntaxKind.MinusToken;
1464
+ case CharacterCodes.dot:
1465
+ if (isDigit(charCodeUnchecked(pos + 1))) {
1466
+ scanNumber();
1467
+ return token = SyntaxKind.NumericLiteral;
1468
+ }
1469
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.dot && charCodeUnchecked(pos + 2) === CharacterCodes.dot) {
1470
+ return pos += 3, token = SyntaxKind.DotDotDotToken;
1471
+ }
1472
+ pos++;
1473
+ return token = SyntaxKind.DotToken;
1474
+ case CharacterCodes.slash:
1475
+ // Single-line comment
1476
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.slash) {
1477
+ pos += 2;
1478
+ while (pos < end) {
1479
+ if (isLineBreak(charCodeUnchecked(pos))) {
1480
+ break;
1481
+ }
1482
+ pos++;
1483
+ }
1484
+ commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenStart, pos), commentDirectiveRegExSingleLine, tokenStart);
1485
+ if (skipTrivia) {
1486
+ continue;
1487
+ }
1488
+ else {
1489
+ return token = SyntaxKind.SingleLineCommentTrivia;
1490
+ }
1491
+ }
1492
+ // Multi-line comment
1493
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.asterisk) {
1494
+ pos += 2;
1495
+ const isJSDoc = charCodeUnchecked(pos) === CharacterCodes.asterisk && charCodeUnchecked(pos + 1) !== CharacterCodes.slash;
1496
+ let commentClosed = false;
1497
+ let lastLineStart = tokenStart;
1498
+ while (pos < end) {
1499
+ const ch = charCodeUnchecked(pos);
1500
+ if (ch === CharacterCodes.asterisk && charCodeUnchecked(pos + 1) === CharacterCodes.slash) {
1501
+ pos += 2;
1502
+ commentClosed = true;
1503
+ break;
1504
+ }
1505
+ pos++;
1506
+ if (isLineBreak(ch)) {
1507
+ lastLineStart = pos;
1508
+ tokenFlags |= TokenFlags.PrecedingLineBreak;
1509
+ }
1510
+ }
1511
+ if (isJSDoc) {
1512
+ tokenFlags |= TokenFlags.PrecedingJSDocComment;
1513
+ tokenFlags = scanJSDocCommentForTags(text.slice(tokenStart, pos), tokenFlags);
1514
+ }
1515
+ commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
1516
+ if (skipTrivia) {
1517
+ continue;
1518
+ }
1519
+ else {
1520
+ if (!commentClosed) {
1521
+ tokenFlags |= TokenFlags.Unterminated;
1522
+ }
1523
+ return token = SyntaxKind.MultiLineCommentTrivia;
1524
+ }
1525
+ }
1526
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1527
+ return pos += 2, token = SyntaxKind.SlashEqualsToken;
1528
+ }
1529
+ pos++;
1530
+ return token = SyntaxKind.SlashToken;
1531
+ case CharacterCodes._0:
1532
+ if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.X || charCodeUnchecked(pos + 1) === CharacterCodes.x)) {
1533
+ pos += 2;
1534
+ tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
1535
+ if (!tokenValue) {
1536
+ tokenValue = "0";
1537
+ }
1538
+ tokenValue = "0x" + tokenValue;
1539
+ tokenFlags |= TokenFlags.HexSpecifier;
1540
+ return token = checkBigIntSuffix();
1541
+ }
1542
+ else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.B || charCodeUnchecked(pos + 1) === CharacterCodes.b)) {
1543
+ pos += 2;
1544
+ tokenValue = scanBinaryOrOctalDigits(2);
1545
+ if (!tokenValue) {
1546
+ tokenValue = "0";
1547
+ }
1548
+ tokenValue = "0b" + tokenValue;
1549
+ tokenFlags |= TokenFlags.BinarySpecifier;
1550
+ return token = checkBigIntSuffix();
1551
+ }
1552
+ else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.O || charCodeUnchecked(pos + 1) === CharacterCodes.o)) {
1553
+ pos += 2;
1554
+ tokenValue = scanBinaryOrOctalDigits(8);
1555
+ if (!tokenValue) {
1556
+ tokenValue = "0";
1557
+ }
1558
+ tokenValue = "0o" + tokenValue;
1559
+ tokenFlags |= TokenFlags.OctalSpecifier;
1560
+ return token = checkBigIntSuffix();
1561
+ }
1562
+ // falls through
1563
+ case CharacterCodes._1:
1564
+ case CharacterCodes._2:
1565
+ case CharacterCodes._3:
1566
+ case CharacterCodes._4:
1567
+ case CharacterCodes._5:
1568
+ case CharacterCodes._6:
1569
+ case CharacterCodes._7:
1570
+ case CharacterCodes._8:
1571
+ case CharacterCodes._9:
1572
+ return token = scanNumber();
1573
+ case CharacterCodes.colon:
1574
+ pos++;
1575
+ return token = SyntaxKind.ColonToken;
1576
+ case CharacterCodes.semicolon:
1577
+ pos++;
1578
+ return token = SyntaxKind.SemicolonToken;
1579
+ case CharacterCodes.lessThan:
1580
+ if (isConflictMarkerTrivia(text, pos)) {
1581
+ pos = scanConflictMarkerTrivia(text, pos);
1582
+ if (skipTrivia) {
1583
+ continue;
1584
+ }
1585
+ else {
1586
+ return token = SyntaxKind.ConflictMarkerTrivia;
1587
+ }
1588
+ }
1589
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.lessThan) {
1590
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1591
+ return pos += 3, token = SyntaxKind.LessThanLessThanEqualsToken;
1592
+ }
1593
+ return pos += 2, token = SyntaxKind.LessThanLessThanToken;
1594
+ }
1595
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1596
+ return pos += 2, token = SyntaxKind.LessThanEqualsToken;
1597
+ }
1598
+ if (languageVariant === LanguageVariant.JSX &&
1599
+ charCodeUnchecked(pos + 1) === CharacterCodes.slash &&
1600
+ charCodeUnchecked(pos + 2) !== CharacterCodes.asterisk) {
1601
+ return pos += 2, token = SyntaxKind.LessThanSlashToken;
1602
+ }
1603
+ pos++;
1604
+ return token = SyntaxKind.LessThanToken;
1605
+ case CharacterCodes.equals:
1606
+ if (isConflictMarkerTrivia(text, pos)) {
1607
+ pos = scanConflictMarkerTrivia(text, pos);
1608
+ if (skipTrivia) {
1609
+ continue;
1610
+ }
1611
+ else {
1612
+ return token = SyntaxKind.ConflictMarkerTrivia;
1613
+ }
1614
+ }
1615
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1616
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1617
+ return pos += 3, token = SyntaxKind.EqualsEqualsEqualsToken;
1618
+ }
1619
+ return pos += 2, token = SyntaxKind.EqualsEqualsToken;
1620
+ }
1621
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.greaterThan) {
1622
+ return pos += 2, token = SyntaxKind.EqualsGreaterThanToken;
1623
+ }
1624
+ pos++;
1625
+ return token = SyntaxKind.EqualsToken;
1626
+ case CharacterCodes.greaterThan:
1627
+ if (isConflictMarkerTrivia(text, pos)) {
1628
+ pos = scanConflictMarkerTrivia(text, pos);
1629
+ if (skipTrivia) {
1630
+ continue;
1631
+ }
1632
+ else {
1633
+ return token = SyntaxKind.ConflictMarkerTrivia;
1634
+ }
1635
+ }
1636
+ pos++;
1637
+ return token = SyntaxKind.GreaterThanToken;
1638
+ case CharacterCodes.question:
1639
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.dot && !isDigit(charCodeUnchecked(pos + 2))) {
1640
+ return pos += 2, token = SyntaxKind.QuestionDotToken;
1641
+ }
1642
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.question) {
1643
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1644
+ return pos += 3, token = SyntaxKind.QuestionQuestionEqualsToken;
1645
+ }
1646
+ return pos += 2, token = SyntaxKind.QuestionQuestionToken;
1647
+ }
1648
+ pos++;
1649
+ return token = SyntaxKind.QuestionToken;
1650
+ case CharacterCodes.openBracket:
1651
+ pos++;
1652
+ return token = SyntaxKind.OpenBracketToken;
1653
+ case CharacterCodes.closeBracket:
1654
+ pos++;
1655
+ return token = SyntaxKind.CloseBracketToken;
1656
+ case CharacterCodes.caret:
1657
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1658
+ return pos += 2, token = SyntaxKind.CaretEqualsToken;
1659
+ }
1660
+ pos++;
1661
+ return token = SyntaxKind.CaretToken;
1662
+ case CharacterCodes.openBrace:
1663
+ pos++;
1664
+ return token = SyntaxKind.OpenBraceToken;
1665
+ case CharacterCodes.bar:
1666
+ if (isConflictMarkerTrivia(text, pos)) {
1667
+ pos = scanConflictMarkerTrivia(text, pos);
1668
+ if (skipTrivia) {
1669
+ continue;
1670
+ }
1671
+ else {
1672
+ return token = SyntaxKind.ConflictMarkerTrivia;
1673
+ }
1674
+ }
1675
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.bar) {
1676
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1677
+ return pos += 3, token = SyntaxKind.BarBarEqualsToken;
1678
+ }
1679
+ return pos += 2, token = SyntaxKind.BarBarToken;
1680
+ }
1681
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1682
+ return pos += 2, token = SyntaxKind.BarEqualsToken;
1683
+ }
1684
+ pos++;
1685
+ return token = SyntaxKind.BarToken;
1686
+ case CharacterCodes.closeBrace:
1687
+ pos++;
1688
+ return token = SyntaxKind.CloseBraceToken;
1689
+ case CharacterCodes.tilde:
1690
+ pos++;
1691
+ return token = SyntaxKind.TildeToken;
1692
+ case CharacterCodes.at:
1693
+ pos++;
1694
+ return token = SyntaxKind.AtToken;
1695
+ case CharacterCodes.backslash: {
1696
+ const extendedCookedChar = peekExtendedUnicodeEscape();
1697
+ if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) {
1698
+ tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
1699
+ return token = getIdentifierToken();
1700
+ }
1701
+ const cookedChar = peekUnicodeEscape();
1702
+ if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
1703
+ pos += 6;
1704
+ tokenFlags |= TokenFlags.UnicodeEscape;
1705
+ tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
1706
+ return token = getIdentifierToken();
1707
+ }
1708
+ pos++;
1709
+ return token = SyntaxKind.Unknown;
1710
+ }
1711
+ case CharacterCodes.hash:
1712
+ if (pos !== 0 && text[pos + 1] === "!") {
1713
+ pos++;
1714
+ return token = SyntaxKind.Unknown;
1715
+ }
1716
+ {
1717
+ const charAfterHash = codePointUnchecked(pos + 1);
1718
+ if (charAfterHash === CharacterCodes.backslash) {
1719
+ pos++;
1720
+ const extendedCookedChar = peekExtendedUnicodeEscape();
1721
+ if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) {
1722
+ tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts();
1723
+ return token = SyntaxKind.PrivateIdentifier;
1724
+ }
1725
+ const cookedChar = peekUnicodeEscape();
1726
+ if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
1727
+ pos += 6;
1728
+ tokenFlags |= TokenFlags.UnicodeEscape;
1729
+ tokenValue = "#" + String.fromCharCode(cookedChar) + scanIdentifierParts();
1730
+ return token = SyntaxKind.PrivateIdentifier;
1731
+ }
1732
+ pos--;
1733
+ }
1734
+ if (isIdentifierStart(charAfterHash)) {
1735
+ pos++;
1736
+ scanIdentifier(charAfterHash);
1737
+ }
1738
+ else {
1739
+ tokenValue = "#";
1740
+ }
1741
+ return token = SyntaxKind.PrivateIdentifier;
1742
+ }
1743
+ case CharacterCodes.replacementCharacter:
1744
+ pos = end;
1745
+ return token = SyntaxKind.NonTextFileMarkerTrivia;
1746
+ default: {
1747
+ const identifierKind = scanIdentifier(ch);
1748
+ if (identifierKind) {
1749
+ return token = identifierKind;
1750
+ }
1751
+ else if (isWhiteSpaceSingleLine(ch)) {
1752
+ pos += charSize(ch);
1753
+ continue;
1754
+ }
1755
+ else if (isLineBreak(ch)) {
1756
+ tokenFlags |= TokenFlags.PrecedingLineBreak;
1757
+ pos += charSize(ch);
1758
+ continue;
1759
+ }
1760
+ const size = charSize(ch);
1761
+ pos += size;
1762
+ return token = SyntaxKind.Unknown;
1763
+ }
1764
+ }
1765
+ }
1766
+ }
1767
+ function reScanInvalidIdentifier() {
1768
+ pos = tokenStart = fullStartPos;
1769
+ tokenFlags = 0;
1770
+ const ch = codePointUnchecked(pos);
1771
+ const identifierKind = scanIdentifier(ch);
1772
+ if (identifierKind) {
1773
+ return token = identifierKind;
1774
+ }
1775
+ pos += charSize(ch);
1776
+ return token; // Still `SyntaxKind.Unknown`
1777
+ }
1778
+ function scanIdentifier(startCharacter) {
1779
+ let ch = startCharacter;
1780
+ if (isIdentifierStart(ch)) {
1781
+ pos += charSize(ch);
1782
+ while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos)))
1783
+ pos += charSize(ch);
1784
+ tokenValue = text.substring(tokenStart, pos);
1785
+ if (ch === CharacterCodes.backslash) {
1786
+ tokenValue += scanIdentifierParts();
1787
+ }
1788
+ return getIdentifierToken();
1789
+ }
1790
+ }
1791
+ function reScanGreaterToken() {
1792
+ if (token === SyntaxKind.GreaterThanToken) {
1793
+ if (charCodeUnchecked(pos) === CharacterCodes.greaterThan) {
1794
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.greaterThan) {
1795
+ if (charCodeUnchecked(pos + 2) === CharacterCodes.equals) {
1796
+ return pos += 3, token = SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken;
1797
+ }
1798
+ return pos += 2, token = SyntaxKind.GreaterThanGreaterThanGreaterThanToken;
1799
+ }
1800
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.equals) {
1801
+ return pos += 2, token = SyntaxKind.GreaterThanGreaterThanEqualsToken;
1802
+ }
1803
+ pos++;
1804
+ return token = SyntaxKind.GreaterThanGreaterThanToken;
1805
+ }
1806
+ if (charCodeUnchecked(pos) === CharacterCodes.equals) {
1807
+ pos++;
1808
+ return token = SyntaxKind.GreaterThanEqualsToken;
1809
+ }
1810
+ }
1811
+ return token;
1812
+ }
1813
+ function reScanAsteriskEqualsToken() {
1814
+ pos = tokenStart + 1;
1815
+ return token = SyntaxKind.EqualsToken;
1816
+ }
1817
+ function reScanSlashToken() {
1818
+ if (token === SyntaxKind.SlashToken || token === SyntaxKind.SlashEqualsToken) {
1819
+ const startOfRegExpBody = tokenStart + 1;
1820
+ pos = startOfRegExpBody;
1821
+ let inEscape = false;
1822
+ let inCharacterClass = false;
1823
+ while (true) {
1824
+ const ch = charCodeChecked(pos);
1825
+ if (ch === CharacterCodes.EOF || isLineBreak(ch)) {
1826
+ tokenFlags |= TokenFlags.Unterminated;
1827
+ break;
1828
+ }
1829
+ if (inEscape) {
1830
+ inEscape = false;
1831
+ }
1832
+ else if (ch === CharacterCodes.slash && !inCharacterClass) {
1833
+ break;
1834
+ }
1835
+ else if (ch === CharacterCodes.openBracket) {
1836
+ inCharacterClass = true;
1837
+ }
1838
+ else if (ch === CharacterCodes.backslash) {
1839
+ inEscape = true;
1840
+ }
1841
+ else if (ch === CharacterCodes.closeBracket) {
1842
+ inCharacterClass = false;
1843
+ }
1844
+ pos++;
1845
+ }
1846
+ if (tokenFlags & TokenFlags.Unterminated) {
1847
+ // Find best recovery position
1848
+ pos = startOfRegExpBody;
1849
+ inEscape = false;
1850
+ let characterClassDepth = 0;
1851
+ let inDecimalQuantifier = false;
1852
+ let groupDepth = 0;
1853
+ while (pos < end && !isLineBreak(charCodeUnchecked(pos))) {
1854
+ const ch = charCodeUnchecked(pos);
1855
+ if (inEscape) {
1856
+ inEscape = false;
1857
+ }
1858
+ else if (ch === CharacterCodes.backslash) {
1859
+ inEscape = true;
1860
+ }
1861
+ else if (ch === CharacterCodes.openBracket) {
1862
+ characterClassDepth++;
1863
+ }
1864
+ else if (ch === CharacterCodes.closeBracket && characterClassDepth) {
1865
+ characterClassDepth--;
1866
+ }
1867
+ else if (!characterClassDepth) {
1868
+ if (ch === CharacterCodes.openBrace) {
1869
+ inDecimalQuantifier = true;
1870
+ }
1871
+ else if (ch === CharacterCodes.closeBrace && inDecimalQuantifier) {
1872
+ inDecimalQuantifier = false;
1873
+ }
1874
+ else if (!inDecimalQuantifier) {
1875
+ if (ch === CharacterCodes.openParen) {
1876
+ groupDepth++;
1877
+ }
1878
+ else if (ch === CharacterCodes.closeParen && groupDepth) {
1879
+ groupDepth--;
1880
+ }
1881
+ else if (ch === CharacterCodes.closeParen || ch === CharacterCodes.closeBracket || ch === CharacterCodes.closeBrace) {
1882
+ break;
1883
+ }
1884
+ }
1885
+ }
1886
+ pos++;
1887
+ }
1888
+ while (isWhiteSpaceLike(charCodeChecked(pos - 1)) || charCodeChecked(pos - 1) === CharacterCodes.semicolon)
1889
+ pos--;
1890
+ }
1891
+ else {
1892
+ pos++;
1893
+ let regExpFlags = RegularExpressionFlags.None;
1894
+ while (true) {
1895
+ const ch = codePointChecked(pos);
1896
+ if (ch === CharacterCodes.EOF || !isIdentifierPart(ch)) {
1897
+ break;
1898
+ }
1899
+ const size = charSize(ch);
1900
+ const flag = characterCodeToRegularExpressionFlag(ch);
1901
+ if (flag !== undefined) {
1902
+ regExpFlags |= flag;
1903
+ }
1904
+ pos += size;
1905
+ }
1906
+ }
1907
+ tokenValue = text.substring(tokenStart, pos);
1908
+ token = SyntaxKind.RegularExpressionLiteral;
1909
+ }
1910
+ return token;
1911
+ }
1912
+ function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
1913
+ const type = getDirectiveFromComment(text.trimStart(), commentDirectiveRegEx);
1914
+ if (type === undefined) {
1915
+ return commentDirectives;
1916
+ }
1917
+ if (!commentDirectives) {
1918
+ commentDirectives = [];
1919
+ }
1920
+ commentDirectives.push({
1921
+ range: { pos: lineStart, end: pos },
1922
+ type,
1923
+ });
1924
+ return commentDirectives;
1925
+ }
1926
+ function getDirectiveFromComment(text, commentDirectiveRegEx) {
1927
+ const match = commentDirectiveRegEx.exec(text);
1928
+ if (!match) {
1929
+ return undefined;
1930
+ }
1931
+ switch (match[1]) {
1932
+ case "ts-expect-error":
1933
+ return CommentDirectiveType.ExpectError;
1934
+ case "ts-ignore":
1935
+ return CommentDirectiveType.Ignore;
1936
+ }
1937
+ return undefined;
1938
+ }
1939
+ function reScanTemplateToken(isTaggedTemplate) {
1940
+ pos = tokenStart;
1941
+ return token = scanTemplateAndSetTokenValue(!isTaggedTemplate);
1942
+ }
1943
+ function reScanTemplateHeadOrNoSubstitutionTemplate() {
1944
+ pos = tokenStart;
1945
+ return token = scanTemplateAndSetTokenValue(/*shouldEmitInvalidEscapeError*/ true);
1946
+ }
1947
+ function reScanJsxToken(allowMultilineJsxText = true) {
1948
+ pos = tokenStart = fullStartPos;
1949
+ return token = scanJsxToken(allowMultilineJsxText);
1950
+ }
1951
+ function reScanLessThanToken() {
1952
+ if (token === SyntaxKind.LessThanLessThanToken) {
1953
+ pos = tokenStart + 1;
1954
+ return token = SyntaxKind.LessThanToken;
1955
+ }
1956
+ return token;
1957
+ }
1958
+ function reScanHashToken() {
1959
+ if (token === SyntaxKind.PrivateIdentifier) {
1960
+ pos = tokenStart + 1;
1961
+ return token = SyntaxKind.HashToken;
1962
+ }
1963
+ return token;
1964
+ }
1965
+ function reScanQuestionToken() {
1966
+ pos = tokenStart + 1;
1967
+ return token = SyntaxKind.QuestionToken;
1968
+ }
1969
+ function scanJsxToken(allowMultilineJsxText = true) {
1970
+ fullStartPos = tokenStart = pos;
1971
+ if (pos >= end) {
1972
+ return token = SyntaxKind.EndOfFile;
1973
+ }
1974
+ let char = charCodeUnchecked(pos);
1975
+ if (char === CharacterCodes.lessThan) {
1976
+ if (charCodeUnchecked(pos + 1) === CharacterCodes.slash) {
1977
+ pos += 2;
1978
+ return token = SyntaxKind.LessThanSlashToken;
1979
+ }
1980
+ pos++;
1981
+ return token = SyntaxKind.LessThanToken;
1982
+ }
1983
+ if (char === CharacterCodes.openBrace) {
1984
+ pos++;
1985
+ return token = SyntaxKind.OpenBraceToken;
1986
+ }
1987
+ let firstNonWhitespace = 0;
1988
+ while (pos < end) {
1989
+ char = charCodeUnchecked(pos);
1990
+ if (char === CharacterCodes.openBrace) {
1991
+ break;
1992
+ }
1993
+ if (char === CharacterCodes.lessThan) {
1994
+ if (isConflictMarkerTrivia(text, pos)) {
1995
+ pos = scanConflictMarkerTrivia(text, pos);
1996
+ return token = SyntaxKind.ConflictMarkerTrivia;
1997
+ }
1998
+ break;
1999
+ }
2000
+ if (isLineBreak(char) && firstNonWhitespace === 0) {
2001
+ firstNonWhitespace = -1;
2002
+ }
2003
+ else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) {
2004
+ break;
2005
+ }
2006
+ else if (!isWhiteSpaceLike(char)) {
2007
+ firstNonWhitespace = pos;
2008
+ }
2009
+ pos++;
2010
+ }
2011
+ tokenValue = text.substring(fullStartPos, pos);
2012
+ return firstNonWhitespace === -1 ? SyntaxKind.JsxTextAllWhiteSpaces : SyntaxKind.JsxText;
2013
+ }
2014
+ function scanJsxIdentifier() {
2015
+ if (tokenIsIdentifierOrKeyword(token)) {
2016
+ while (pos < end) {
2017
+ const ch = charCodeUnchecked(pos);
2018
+ if (ch === CharacterCodes.minus) {
2019
+ tokenValue += "-";
2020
+ pos++;
2021
+ continue;
2022
+ }
2023
+ const oldPos = pos;
2024
+ tokenValue += scanIdentifierParts();
2025
+ if (pos === oldPos) {
2026
+ break;
2027
+ }
2028
+ }
2029
+ return getIdentifierToken();
2030
+ }
2031
+ return token;
2032
+ }
2033
+ function scanJsxAttributeValue() {
2034
+ fullStartPos = pos;
2035
+ switch (charCodeUnchecked(pos)) {
2036
+ case CharacterCodes.doubleQuote:
2037
+ case CharacterCodes.singleQuote:
2038
+ tokenValue = scanString(/*jsxAttributeString*/ true);
2039
+ return token = SyntaxKind.StringLiteral;
2040
+ default:
2041
+ return scan();
2042
+ }
2043
+ }
2044
+ function reScanJsxAttributeValue() {
2045
+ pos = tokenStart = fullStartPos;
2046
+ return scanJsxAttributeValue();
2047
+ }
2048
+ function scanJSDocCommentTextToken(inBackticks) {
2049
+ fullStartPos = tokenStart = pos;
2050
+ tokenFlags = TokenFlags.None;
2051
+ if (pos >= end) {
2052
+ return token = SyntaxKind.EndOfFile;
2053
+ }
2054
+ for (let ch = charCodeUnchecked(pos); pos < end && (!isLineBreak(ch) && ch !== CharacterCodes.backtick); ch = codePointUnchecked(++pos)) {
2055
+ if (!inBackticks) {
2056
+ if (ch === CharacterCodes.openBrace) {
2057
+ break;
2058
+ }
2059
+ else if (ch === CharacterCodes.at
2060
+ && pos - 1 >= 0 && isWhiteSpaceSingleLine(charCodeUnchecked(pos - 1))
2061
+ && pos + 1 < end && isIdentifierStart(charCodeUnchecked(pos + 1))) {
2062
+ break;
2063
+ }
2064
+ }
2065
+ }
2066
+ if (pos === tokenStart) {
2067
+ return scanJsDocToken();
2068
+ }
2069
+ tokenValue = text.substring(tokenStart, pos);
2070
+ return token = SyntaxKind.JSDocCommentTextToken;
2071
+ }
2072
+ function scanJsDocToken() {
2073
+ fullStartPos = tokenStart = pos;
2074
+ tokenFlags = TokenFlags.None;
2075
+ if (pos >= end) {
2076
+ return token = SyntaxKind.EndOfFile;
2077
+ }
2078
+ const ch = codePointUnchecked(pos);
2079
+ pos += charSize(ch);
2080
+ switch (ch) {
2081
+ case CharacterCodes.tab:
2082
+ case CharacterCodes.verticalTab:
2083
+ case CharacterCodes.formFeed:
2084
+ case CharacterCodes.space:
2085
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
2086
+ pos++;
2087
+ }
2088
+ return token = SyntaxKind.WhitespaceTrivia;
2089
+ case CharacterCodes.at:
2090
+ return token = SyntaxKind.AtToken;
2091
+ case CharacterCodes.carriageReturn:
2092
+ if (charCodeUnchecked(pos) === CharacterCodes.lineFeed) {
2093
+ pos++;
2094
+ }
2095
+ // falls through
2096
+ case CharacterCodes.lineFeed:
2097
+ tokenFlags |= TokenFlags.PrecedingLineBreak;
2098
+ return token = SyntaxKind.NewLineTrivia;
2099
+ case CharacterCodes.asterisk:
2100
+ return token = SyntaxKind.AsteriskToken;
2101
+ case CharacterCodes.openBrace:
2102
+ return token = SyntaxKind.OpenBraceToken;
2103
+ case CharacterCodes.closeBrace:
2104
+ return token = SyntaxKind.CloseBraceToken;
2105
+ case CharacterCodes.openBracket:
2106
+ return token = SyntaxKind.OpenBracketToken;
2107
+ case CharacterCodes.closeBracket:
2108
+ return token = SyntaxKind.CloseBracketToken;
2109
+ case CharacterCodes.openParen:
2110
+ return token = SyntaxKind.OpenParenToken;
2111
+ case CharacterCodes.closeParen:
2112
+ return token = SyntaxKind.CloseParenToken;
2113
+ case CharacterCodes.lessThan:
2114
+ return token = SyntaxKind.LessThanToken;
2115
+ case CharacterCodes.greaterThan:
2116
+ return token = SyntaxKind.GreaterThanToken;
2117
+ case CharacterCodes.equals:
2118
+ return token = SyntaxKind.EqualsToken;
2119
+ case CharacterCodes.comma:
2120
+ return token = SyntaxKind.CommaToken;
2121
+ case CharacterCodes.dot:
2122
+ return token = SyntaxKind.DotToken;
2123
+ case CharacterCodes.backtick:
2124
+ return token = SyntaxKind.BacktickToken;
2125
+ case CharacterCodes.hash:
2126
+ return token = SyntaxKind.HashToken;
2127
+ case CharacterCodes.backslash:
2128
+ pos--;
2129
+ {
2130
+ const extendedCookedChar = peekExtendedUnicodeEscape();
2131
+ if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) {
2132
+ tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
2133
+ return token = getIdentifierToken();
2134
+ }
2135
+ const cookedChar = peekUnicodeEscape();
2136
+ if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
2137
+ pos += 6;
2138
+ tokenFlags |= TokenFlags.UnicodeEscape;
2139
+ tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
2140
+ return token = getIdentifierToken();
2141
+ }
2142
+ }
2143
+ pos++;
2144
+ return token = SyntaxKind.Unknown;
2145
+ }
2146
+ if (isIdentifierStart(ch)) {
2147
+ let char = ch;
2148
+ while (pos < end && (isIdentifierPart(char = codePointUnchecked(pos)) || char === CharacterCodes.minus))
2149
+ pos += charSize(char);
2150
+ tokenValue = text.substring(tokenStart, pos);
2151
+ if (char === CharacterCodes.backslash) {
2152
+ tokenValue += scanIdentifierParts();
2153
+ }
2154
+ return token = getIdentifierToken();
2155
+ }
2156
+ else {
2157
+ return token = SyntaxKind.Unknown;
2158
+ }
2159
+ }
2160
+ function speculationHelper(callback, isLookahead) {
2161
+ const savePos = pos;
2162
+ const saveStartPos = fullStartPos;
2163
+ const saveTokenPos = tokenStart;
2164
+ const saveToken = token;
2165
+ const saveTokenValue = tokenValue;
2166
+ const saveTokenFlags = tokenFlags;
2167
+ const result = callback();
2168
+ if (!result || isLookahead) {
2169
+ pos = savePos;
2170
+ fullStartPos = saveStartPos;
2171
+ tokenStart = saveTokenPos;
2172
+ token = saveToken;
2173
+ tokenValue = saveTokenValue;
2174
+ tokenFlags = saveTokenFlags;
2175
+ }
2176
+ return result;
2177
+ }
2178
+ function scanRange(start, length, callback) {
2179
+ const saveEnd = end;
2180
+ const savePos = pos;
2181
+ const saveStartPos = fullStartPos;
2182
+ const saveTokenPos = tokenStart;
2183
+ const saveToken = token;
2184
+ const saveTokenValue = tokenValue;
2185
+ const saveTokenFlags = tokenFlags;
2186
+ const saveErrorExpectations = commentDirectives;
2187
+ setText(text, start, length);
2188
+ const result = callback();
2189
+ end = saveEnd;
2190
+ pos = savePos;
2191
+ fullStartPos = saveStartPos;
2192
+ tokenStart = saveTokenPos;
2193
+ token = saveToken;
2194
+ tokenValue = saveTokenValue;
2195
+ tokenFlags = saveTokenFlags;
2196
+ commentDirectives = saveErrorExpectations;
2197
+ return result;
2198
+ }
2199
+ function lookAhead(callback) {
2200
+ return speculationHelper(callback, /*isLookahead*/ true);
2201
+ }
2202
+ function tryScan(callback) {
2203
+ return speculationHelper(callback, /*isLookahead*/ false);
2204
+ }
2205
+ function getText() {
2206
+ return text;
2207
+ }
2208
+ function clearCommentDirectives() {
2209
+ commentDirectives = undefined;
2210
+ }
2211
+ function setText(newText, start, length) {
2212
+ text = newText || "";
2213
+ end = length === undefined ? text.length : start + length;
2214
+ resetTokenState(start || 0);
2215
+ }
2216
+ function setLanguageVariant(variant) {
2217
+ languageVariant = variant;
2218
+ }
2219
+ function resetTokenState(position) {
2220
+ pos = position;
2221
+ fullStartPos = position;
2222
+ tokenStart = position;
2223
+ token = SyntaxKind.Unknown;
2224
+ tokenValue = undefined;
2225
+ tokenFlags = TokenFlags.None;
2226
+ }
2227
+ function setSkipJsDocLeadingAsterisks(skip) {
2228
+ skipJsDocLeadingAsterisks += skip ? 1 : -1;
2229
+ }
2230
+ }
2231
+ //# sourceMappingURL=scanner.js.map