import { TextDocument } from 'vscode-languageserver-textdocument'; import { CompletionItem, Diagnostic, Position, TextEdit } from 'vscode-languageserver/node'; import { EntityNode } from '../nodes/EntityNode'; import { ParserSuggestion } from '../types'; import { LintConfig } from '../types/Config'; import { IndexMapping } from '../types/IndexMapping'; import { ParsingError } from '../types/ParsingError'; import { QuoteTypeConfig } from '../types/QuoteTypeConfig'; import { DiagnosticConfig } from '../types/StylisticConfig'; import { TextRange } from '../types/TextRange'; /** * Convert an array to human-readable message. * @param arr An array. * @param quoted Whether or not to quote the result. Defaults to `true` * @param conjunction The conjunction to use. Defaults to `and`. * @returns Human-readable message. * @example // Using English * arrayToMessage([]) // "nothing" * arrayToMessage('foo') // "“foo”" * arrayToMessage(['foo']) // "“foo”" * arrayToMessage(['bar', 'foo']) // "“bar” and “foo”" * arrayToMessage(['bar', 'baz', 'foo']) // "“bar”, “baz”, and “foo”" * @example // Using Locale * arrayToMessage([], false) // "nothing" * arrayToMessage(['A'], false) // "A" * arrayToMessage(['A', 'B'], false) // "A{conjunction.and_2}B" * arrayToMessage(['A', 'B', 'C'], false) // "A{conjunction.and_3+_1}B{conjunction.and_3+_2}C" */ export declare function arrayToMessage(arr: string | string[], quoted?: boolean, conjunction?: 'and' | 'or'): string; /** * Escape characters in a string with `\`. * @param str A string. * @param quote A string indicating which type of quote should be escaped. */ export declare function escapeString(str: string, quote?: '"' | "'" | null): string; /** * Quote a string. * @param inner The inner string. * @param quoteType Which quote to use. * @param forced Whether to quote regardless. */ export declare function quoteString(inner: string, quoteType: QuoteTypeConfig, forced: boolean): string; export declare function validateStringQuote(raw: string, value: string, range: TextRange, quoteConfig: DiagnosticConfig, quoteTypeConfig: DiagnosticConfig, quoteConfigRule?: keyof LintConfig, quoteTypeConfigRule?: keyof LintConfig): ParsingError[]; /** * Convert an array of any to an array of `ParserSuggestion`. * @param array An array */ export declare function arrayToCompletions(array: any[], start: number, end: number, cb?: (c: ParserSuggestion) => ParserSuggestion): ParserSuggestion[]; /** * Convert specific value to a linted string. * @param value Any value. */ export declare function toFormattedString(value: unknown, lint: LintConfig): string; export declare function escapeRegex(value: string): string; export declare function escapeIdentityPattern(value: string): string; export declare function requestText(uri: string): Promise; /** * Get EOL from specific lint config. * @param param0 The lint config. */ export declare function getEol({ eol }: LintConfig): string; /** * @param titleLocaleKey The locale key of the code action title (without the `code-action.` part). */ export declare function getCodeAction(titleLocaleKey: string, diagnostics: Diagnostic[], content: TextDocument, range: TextRange, newText: string, kind?: string, isPreferred?: boolean): { title: string; kind: string; diagnostics: Diagnostic[]; isPreferred: boolean; edit: { documentChanges: { textDocument: { uri: string; version: number; }; edits: { range: { start: import("vscode-languageserver-textdocument").Position; end: import("vscode-languageserver-textdocument").Position; }; newText: string; }[]; }[]; }; }; /** * Remap all the indices in the specific ParserSuggestion object by the specific mapping. * @param completion The specific ParserSuggestion object. Won't be changed. * @param param1 The mapping used to offset. * @returns A new cloned CompletionItem. */ export declare function remapParserSuggestion(completion: ParserSuggestion, mapping: IndexMapping): ParserSuggestion; export declare function remapParserSuggestion(completion: CompletionItem, getPosition: (offset: number) => Position): ParserSuggestion; /** * @param origin Won't be changed. * @returns A new CompletionItem. */ export declare function handleCompletionText(origin: T, cb: (str: string) => string): (T & { textEdit?: TextEdit; label: string; }) | (T & { textEdit?: TextEdit; insertText: string; label: string; }); export declare function removeDupliateCompletions(completions: ParserSuggestion[]): ParserSuggestion[]; export declare function getNbtdocRegistryId(entity: EntityNode): null | string; export declare function pathAccessible(path: string): Promise; export declare function readFile(path: string): Promise; export declare function round(number: number, decimalPlace: number): number;