import { Markers } from "../markers"; import { SourceFile, Tree } from "../tree"; export interface Json extends Tree { readonly prefix: Json.Space; } export declare namespace Json { const Kind: { readonly Array: "org.openrewrite.json.tree.Json$Array"; readonly Document: "org.openrewrite.json.tree.Json$Document"; readonly Empty: "org.openrewrite.json.tree.Json$Empty"; readonly Identifier: "org.openrewrite.json.tree.Json$Identifier"; readonly Literal: "org.openrewrite.json.tree.Json$Literal"; readonly Member: "org.openrewrite.json.tree.Json$Member"; readonly Object: "org.openrewrite.json.tree.Json$JsonObject"; readonly Space: "org.openrewrite.json.tree.Space"; readonly Comment: "org.openrewrite.json.tree.Comment"; readonly RightPadded: "org.openrewrite.json.tree.JsonRightPadded"; }; type Key = Identifier | Literal; type Value = Array | Empty | Json.Object | Literal; interface Comment { readonly kind: typeof Kind.Comment; readonly multiline: boolean; readonly text: string; readonly suffix: string; readonly markers: Markers; } interface Array extends Json { readonly kind: typeof Kind.Array; readonly values: RightPadded[]; } interface Document extends SourceFile, Json { readonly kind: typeof Kind.Document; readonly value: Value; readonly eof: Space; } interface Empty extends Json { readonly kind: typeof Kind.Empty; } interface Identifier extends Json { readonly kind: typeof Kind.Identifier; readonly name: string; } interface Literal extends Json { readonly kind: typeof Kind.Literal; readonly source: string; readonly value?: any; } interface Member extends Json { readonly kind: typeof Kind.Member; readonly key: RightPadded; readonly value: Value; } interface Object extends Json { readonly kind: typeof Kind.Object; readonly members: RightPadded[]; } interface Space { readonly kind: typeof Kind.Space; readonly comments: Comment[]; readonly whitespace: string; } interface RightPadded { readonly kind: typeof Json.Kind.RightPadded; readonly element: T; readonly after: Space; readonly markers: Markers; } } export declare const emptySpace: Json.Space; /** * Parse a formatting string into a Space object, extracting comments. * Mirrors the Java Space.format() method. */ export declare function space(formatting: string): Json.Space; export declare function isJson(tree: any): tree is Json; export declare function isLiteral(json: Json): json is Json.Literal; export declare function isObject(json: Json): json is Json.Object; export declare function isArray(json: Json): json is Json.Array; export declare function isIdentifier(json: Json): json is Json.Identifier; export declare function isMember(json: Json): json is Json.Member; /** * Gets the key name from a Json.Member. * Handles both string literals (quoted keys) and identifiers (unquoted keys). * * @param member The JSON member to extract the key name from * @returns The key name as a string, or undefined if extraction fails */ export declare function getMemberKeyName(member: Json.Member): string | undefined; /** * Detects the indentation used in a JSON document by examining existing members or array elements. * Returns the base indent string (e.g., " " for 2 spaces, " " for 4 spaces). * * @param doc The JSON document to analyze * @returns The detected indent string, or " " (4 spaces) as default */ export declare function detectIndent(doc: Json.Document): string; /** * Creates a RightPadded wrapper for a JSON element. * * @param element The JSON element to wrap * @param after The trailing space after the element * @param markers Optional markers to attach * @returns A RightPadded wrapper containing the element */ export declare function rightPadded(element: T, after: Json.Space, markers?: Markers): Json.RightPadded; //# sourceMappingURL=tree.d.ts.map