import { SourceFile, Tree } from "../tree"; export interface Yaml extends Tree { readonly prefix: string; } export declare namespace Yaml { const Kind: { readonly Documents: "org.openrewrite.yaml.tree.Yaml$Documents"; readonly Document: "org.openrewrite.yaml.tree.Yaml$Document"; readonly DocumentEnd: "org.openrewrite.yaml.tree.Yaml$Document$End"; readonly Directive: "org.openrewrite.yaml.tree.Yaml$Directive"; readonly Mapping: "org.openrewrite.yaml.tree.Yaml$Mapping"; readonly MappingEntry: "org.openrewrite.yaml.tree.Yaml$Mapping$Entry"; readonly Scalar: "org.openrewrite.yaml.tree.Yaml$Scalar"; readonly Sequence: "org.openrewrite.yaml.tree.Yaml$Sequence"; readonly SequenceEntry: "org.openrewrite.yaml.tree.Yaml$Sequence$Entry"; readonly Alias: "org.openrewrite.yaml.tree.Yaml$Alias"; readonly Anchor: "org.openrewrite.yaml.tree.Yaml$Anchor"; readonly Tag: "org.openrewrite.yaml.tree.Yaml$Tag"; }; enum ScalarStyle { DOUBLE_QUOTED = "DOUBLE_QUOTED", SINGLE_QUOTED = "SINGLE_QUOTED", LITERAL = "LITERAL", FOLDED = "FOLDED", PLAIN = "PLAIN" } enum TagKind { LOCAL = "LOCAL", IMPLICIT_GLOBAL = "IMPLICIT_GLOBAL", EXPLICIT_GLOBAL = "EXPLICIT_GLOBAL" } /** * Either a Scalar or an Alias can be a key in a mapping */ type YamlKey = Scalar | Alias; /** * Block types are Scalar, Mapping, Sequence, or Alias */ type Block = Scalar | Mapping | Sequence | Alias; /** * A YAML file containing multiple documents */ interface Documents extends SourceFile, Yaml { readonly kind: typeof Kind.Documents; readonly documents: Document[]; readonly suffix: string | undefined; } /** * A single YAML document within a Documents container */ interface Document extends Yaml { readonly kind: typeof Kind.Document; /** * Optional list of directives that precede this document. * Directives include %YAML and %TAG. */ readonly directives: Directive[]; /** * True if the document explicitly starts with "---" */ readonly explicit: boolean; readonly block: Block; readonly end: DocumentEnd; } /** * Document end marker. May or may not be explicit ("...") */ interface DocumentEnd extends Yaml { readonly kind: typeof Kind.DocumentEnd; /** * True if the document end is explicitly marked with "..." */ readonly explicit: boolean; } /** * A YAML directive, such as %YAML or %TAG. * * Examples: * %YAML 1.2 * %TAG !yaml! tag:yaml.org,2002: */ interface Directive extends Yaml { readonly kind: typeof Kind.Directive; /** * The content of the directive after the '%' character. * For example, "YAML 1.2" or "TAG !yaml! tag:yaml.org,2002:". */ readonly value: string; /** * Whitespace/content after the directive value, typically a newline. */ readonly suffix: string; } /** * A scalar value in YAML (string, number, boolean, etc.) */ interface Scalar extends Yaml { readonly kind: typeof Kind.Scalar; readonly style: ScalarStyle; readonly anchor: Anchor | undefined; readonly tag: Tag | undefined; readonly value: string; } /** * A YAML mapping (object/dictionary) */ interface Mapping extends Yaml { readonly kind: typeof Kind.Mapping; /** * When non-null, indicates this is an inline mapping and contains the whitespace before '{' */ readonly openingBracePrefix: string | undefined; readonly entries: MappingEntry[]; /** * When non-null, indicates this is an inline mapping and contains the whitespace before '}' */ readonly closingBracePrefix: string | undefined; readonly anchor: Anchor | undefined; readonly tag: Tag | undefined; } /** * A single key-value pair in a mapping */ interface MappingEntry extends Yaml { readonly kind: typeof Kind.MappingEntry; readonly key: YamlKey; /** * Whitespace before the mapping value indicator ':' */ readonly beforeMappingValueIndicator: string; readonly value: Block; } /** * A YAML sequence (array/list) */ interface Sequence extends Yaml { readonly kind: typeof Kind.Sequence; /** * When non-null, indicates this is an inline sequence and contains the whitespace before '[' */ readonly openingBracketPrefix: string | undefined; readonly entries: SequenceEntry[]; /** * When non-null, indicates this is an inline sequence and contains the whitespace before ']' */ readonly closingBracketPrefix: string | undefined; readonly anchor: Anchor | undefined; readonly tag: Tag | undefined; } /** * A single entry in a sequence */ interface SequenceEntry extends Yaml { readonly kind: typeof Kind.SequenceEntry; readonly block: Block; /** * True when this entry is part of a block sequence (uses '-') * False when this entry is part of an inline sequence (uses '[' and ']') */ readonly dash: boolean; /** * When non-null, contains the whitespace before the trailing comma in inline sequences */ readonly trailingCommaPrefix: string | undefined; } /** * An alias reference to an anchor (*anchorName) */ interface Alias extends Yaml { readonly kind: typeof Kind.Alias; readonly anchor: Anchor; } /** * An anchor definition (&anchorName) */ interface Anchor extends Yaml { readonly kind: typeof Kind.Anchor; readonly postfix: string; readonly key: string; } /** * A YAML tag (!tag, !!tag, or !) */ interface Tag extends Yaml { readonly kind: typeof Kind.Tag; readonly name: string; readonly suffix: string; readonly tagKind: TagKind; } } export declare function isYaml(tree: any): tree is Yaml; export declare function isDocuments(yaml: Yaml): yaml is Yaml.Documents; export declare function isDocument(yaml: Yaml): yaml is Yaml.Document; export declare function isDocumentEnd(yaml: Yaml): yaml is Yaml.DocumentEnd; export declare function isDirective(yaml: Yaml): yaml is Yaml.Directive; export declare function isScalar(yaml: Yaml): yaml is Yaml.Scalar; export declare function isMapping(yaml: Yaml): yaml is Yaml.Mapping; export declare function isMappingEntry(yaml: Yaml): yaml is Yaml.MappingEntry; export declare function isSequence(yaml: Yaml): yaml is Yaml.Sequence; export declare function isSequenceEntry(yaml: Yaml): yaml is Yaml.SequenceEntry; export declare function isAlias(yaml: Yaml): yaml is Yaml.Alias; export declare function isAnchor(yaml: Yaml): yaml is Yaml.Anchor; export declare function isTag(yaml: Yaml): yaml is Yaml.Tag; export declare function isBlock(yaml: Yaml): yaml is Yaml.Block; export declare function isYamlKey(yaml: Yaml): yaml is Yaml.YamlKey; /** * Gets the value from a YamlKey (either a Scalar or an Alias) */ export declare function getYamlKeyValue(key: Yaml.YamlKey): string; /** * Prints a tag according to its kind */ export declare function printTag(tag: Yaml.Tag): string; //# sourceMappingURL=tree.d.ts.map