@openrewrite/rewrite 8.67.0-20251105-091131 → 8.67.0-20251105-102503

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.
@@ -331,6 +331,36 @@ export interface RewriteRule {
331
331
  * ```
332
332
  */
333
333
  andThen(next: RewriteRule): RewriteRule;
334
+
335
+ /**
336
+ * Creates a composite rule that tries this rule first, and if it doesn't match, tries an alternative rule.
337
+ *
338
+ * The resulting rule:
339
+ * 1. First applies this rule to the input node
340
+ * 2. If this rule matches and transforms the node, returns the result
341
+ * 3. If this rule returns undefined (no match), tries the alternative rule on the original node
342
+ *
343
+ * @param alternative The rule to try if this rule doesn't match
344
+ * @returns A new RewriteRule that tries both rules with fallback behavior
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * // Try specific pattern first, fall back to general pattern
349
+ * const specific = rewrite(() => ({
350
+ * before: pattern`foo(${capture('x')}, 0)`,
351
+ * after: template`bar(${capture('x')})`
352
+ * }));
353
+ *
354
+ * const general = rewrite(() => ({
355
+ * before: pattern`foo(${capture('x')}, ${capture('y')})`,
356
+ * after: template`baz(${capture('x')}, ${capture('y')})`
357
+ * }));
358
+ *
359
+ * const combined = specific.orElse(general);
360
+ * // Will try specific pattern first, if no match, try general pattern
361
+ * ```
362
+ */
363
+ orElse(alternative: RewriteRule): RewriteRule;
334
364
  }
335
365
 
336
366
  /**
@@ -338,5 +368,5 @@ export interface RewriteRule {
338
368
  */
339
369
  export interface RewriteConfig {
340
370
  before: Pattern | Pattern[],
341
- after: Template | ((match: MatchResult) => Promise<J>)
371
+ after: Template | ((match: MatchResult) => Template)
342
372
  }