(j: any, root: any, rop: ResolvedOp, source: string)
| 500 | // ── Mutation application ───────────────────────────────────────────────── |
| 501 | |
| 502 | function applyOp(j: any, root: any, rop: ResolvedOp, source: string): string | undefined { |
| 503 | const { op, node } = rop; |
| 504 | |
| 505 | switch (op.op) { |
| 506 | case "updateClass": { |
| 507 | const updates: ClassNameUpdate[] = op.updates.map((u: Extract<BatchOperation, { op: "updateClass" }>["updates"][number]) => ({ |
| 508 | tailwindPrefix: u.tailwindPrefix, |
| 509 | tailwindToken: u.tailwindToken, |
| 510 | value: u.value, |
| 511 | relatedPrefixes: u.relatedPrefixes, |
| 512 | classPattern: u.classPattern, |
| 513 | standalone: u.standalone, |
| 514 | })); |
| 515 | mutateClassName(j, node, updates); |
| 516 | return undefined; |
| 517 | } |
| 518 | |
| 519 | case "updateText": { |
| 520 | if (node) { |
| 521 | const boundFallback = replaceBoundStringLiteralInElement(j, root, node, op.originalText, op.newText); |
| 522 | if (boundFallback) { |
| 523 | return undefined; |
| 524 | } |
| 525 | |
| 526 | const found = mutateTextContent(node, op.originalText, op.newText, source, op.cursorOffset, op.textAnchor); |
| 527 | if (found) { |
| 528 | return undefined; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | const fallback = replaceStringLiteralInFile(j, root, op.originalText, op.newText); |
| 533 | if (fallback.replaced) { |
| 534 | return undefined; |
| 535 | } |
| 536 | if (fallback.ambiguous) { |
| 537 | return `Text "${op.originalText}" matched multiple string literals in this file; refusing ambiguous rewrite`; |
| 538 | } |
| 539 | return `No matching text "${op.originalText}" found in element at ${op.line}:${op.col}`; |
| 540 | } |
| 541 | |
| 542 | case "reorder": { |
| 543 | mutateReorder(j, root, op.fromLine, op.toLine); |
| 544 | return undefined; |
| 545 | } |
| 546 | |
| 547 | case "moveSpacing": { |
| 548 | // Detect the right mechanism for this element |
| 549 | const mechanism = detectMoveMechanism(node, op.axis); |
| 550 | |
| 551 | if (mechanism === "framer-motion") { |
| 552 | return applyFramerMotionMove(node, op); |
| 553 | } |
| 554 | |
| 555 | // Default: CSS translate class |
| 556 | const basePrefix = op.axis === "x" ? "translate-x" : "translate-y"; |
| 557 | const classPattern = `^-?${basePrefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(-|$)`; |
| 558 | const classPatternRe = new RegExp(classPattern); |
| 559 |
no test coverage detected