import { TreeVisitor } from './visitor'; import { Cursor, SourceFile, Tree } from './tree'; import { Recipe } from "./recipe"; import { ExecutionContext } from "./execution"; /** * Recipe-identity placeholder for use as a precondition. * * Captures a Java recipe class name + options without instantiating the * recipe or firing an RPC. The framework introspects a * ``check(RecipeRef, editor)`` wrapper at PrepareRecipe time and emits * the recipe identity directly in * ``PrepareRecipeResponse.editPreconditions``. The Java host's * ``PreparedRecipeCache.instantiateVisitor`` constructs the recipe via * Jackson and uses its visitor. * * This avoids requiring the recipe author to do an RPC at ``editor()`` * construction time, which would otherwise block in-process unit tests * that don't have an active RPC connection. * * If ``localVisitor`` is provided, in-process callers (without an active * RPC connection) evaluate the gate against that visitor instead of * short-circuiting to "always matches". This preserves real filtering * behavior in unit tests while still letting the host evaluate the gate * over the wire when an RPC connection is present. * * Helpers in ``@openrewrite/rewrite/javascript/preconditions`` * (``usesMethod``, ``usesType``, ``hasSourcePath``, ``findMethods``, * ``findTypes``) return ``RecipeRef`` instances populated with the * matching native TS visitor where one exists. */ export declare class RecipeRef { readonly recipeName: string; readonly options: Readonly>; readonly localVisitor?: TreeVisitor | undefined; constructor(recipeName: string, options?: Readonly>, localVisitor?: TreeVisitor | undefined); } /** * Composite of nested precondition operands joined by an operator. * * Mirrors Java's ``Preconditions.or``/``and``/``not``: a gate that * short-circuits over its operands. ``op`` is one of ``"or"`` / ``"and"`` / * ``"not"``. Operands may be ``TreeVisitor``, ``Recipe``, ``RecipeRef``, * or another ``CompositePrecondition``. * * The framework promotes the composite to a structured wire entry at * PrepareRecipe time; the Java host's ``RewriteRpc.matchAll`` rebuilds * the visitor via the matching ``Preconditions`` factory so the gate runs * locally and the visit RPC is skipped for files the gate rejects. */ export declare class CompositePrecondition { readonly op: "or" | "and" | "not"; readonly operands: ReadonlyArray; constructor(op: "or" | "and" | "not", operands: ReadonlyArray); } export type CheckArg = Recipe | TreeVisitor | RecipeRef | CompositePrecondition; export declare function check(checkCondition: CheckArg | Promise | boolean, v: TreeVisitor | Promise>): Promise>; /** * OR-compose precondition checks. Mirrors Java's * ``Preconditions.or(visitor...)``: the gate matches if any operand * matches. Requires at least two operands; a single-operand OR has no * value over a bare ``check``. */ export declare function or(...operands: CheckArg[]): CompositePrecondition; /** * AND-compose precondition checks. The outer ``editPreconditions`` list * is already AND-composed by the host, so this is mainly useful as an * operand of ``or``/``not``. */ export declare function and(...operands: CheckArg[]): CompositePrecondition; /** * Negate a precondition check. Mirrors Java's ``Preconditions.not(visitor)``: * the gate matches iff the operand does not. */ export declare function not(operand: CheckArg): CompositePrecondition; export declare class Check extends TreeVisitor { readonly check: CheckArg; readonly v: TreeVisitor; constructor(check: CheckArg, v: TreeVisitor); isAcceptable(sourceFile: SourceFile, ctx: ExecutionContext): Promise; visit(tree: Tree, ctx: ExecutionContext, parent?: Cursor): Promise; private runLeafCheck; private checkVisitor; } //# sourceMappingURL=preconditions.d.ts.map