yaml-language-server
Version:
74 lines (73 loc) • 2.8 kB
TypeScript
import type { TextDocument } from 'vscode-languageserver-textdocument';
import { JSONDocument } from './jsonDocument';
import type { CST, Document, LineCounter } from 'yaml';
import type { ASTNode, YamlNode } from '../jsonLanguageTypes';
import type { ParserOptions } from './yamlParser07';
import type { YAMLDocDiagnostic } from '../utils/parseUtils';
import type { TextBuffer } from '../utils/textBuffer';
/**
* These documents are collected into a final YAMLDocument
* and passed to the `parseYAML` caller.
*/
export declare class SingleYAMLDocument extends JSONDocument {
private lineCounter;
private _internalDocument;
root: ASTNode;
currentDocIndex: number;
private _lineComments;
private _documentHeaderComments;
constructor(lineCounter?: LineCounter);
/**
* Create a deep copy of this document
*/
clone(): SingleYAMLDocument;
private collectLineComments;
/**
* Updates the internal AST tree of the object
* from the internal node. This is call whenever the
* internalDocument is set but also can be called to
* reflect any changes on the underlying document
* without setting the internalDocument explicitly.
*/
updateFromInternalDocument(): void;
set internalDocument(document: Document);
get internalDocument(): Document;
get lineComments(): string[];
set lineComments(val: string[]);
get documentHeaderComments(): string[];
set documentHeaderComments(val: string[]);
get errors(): YAMLDocDiagnostic[];
get warnings(): YAMLDocDiagnostic[];
getNodeFromPosition(positionOffset: number, textBuffer: TextBuffer, configuredIndentation?: number): [YamlNode | undefined, boolean];
findClosestNode(offset: number, textBuffer: TextBuffer, configuredIndentation?: number): YamlNode;
private getProperParentByIndentation;
getParent(node: YamlNode): YamlNode | undefined;
}
/**
* Contains the SingleYAMLDocuments, to be passed
* to the `parseYAML` caller.
*/
export declare class YAMLDocument {
documents: SingleYAMLDocument[];
tokens: CST.Token[];
private errors;
private warnings;
constructor(documents: SingleYAMLDocument[], tokens: CST.Token[]);
}
export declare class YamlDocuments {
private cache;
/**
* Get cached YAMLDocument
* @param document TextDocument to parse
* @param parserOptions YAML parserOptions
* @param addRootObject if true and document is empty add empty object {} to force schema usage
* @returns the YAMLDocument
*/
getYamlDocument(document: TextDocument, parserOptions?: ParserOptions, addRootObject?: boolean): YAMLDocument;
/**
* For test purpose only!
*/
clear(): void;
private ensureCache;
}
export declare const yamlDocumentsCache: YamlDocuments;