import { JsonToken } from '../classes/jsontoken'; import { EditorPosition } from '../classes/editorposition'; /** * Uses ANTLR parser generated from the grammar file Json.g4 to parse the JSON string to tokens. The tokens are then converted to JsonTokens. * @param input JSON content as string * @param inputIsEscaped getEscaped has been run on the JSON string, so that the resulting JsonTokens have their line numbers computed correctly * @returns */ export declare function tokenizeJson(input: string, inputIsEscaped?: boolean): JsonToken[]; /** * Computes a continuous map of positions to path in the JSON object from a stringified JSON document. * This is useful for autocomplete and other features, which require to know what is the path below the cursor position. * Because this is a rather expensive operation, try to store the tokens of the pass. * @param input the input JSON as string * @param startPath optionally the path to start with * @returns */ export declare function getJsonTokensWithPaths(input: string, startPath?: string[]): JsonToken[]; /** * Computes a path at the given position in a JSON object which is provided as a string. * @param input the input JSON as string, or array of JsonTokens. String will get tokenized, which is expensive. If you have already tokenized, it is recommended to store the tokens. * @param position the position of the cursor in the editor (first character is 1:1) * @returns the path or undefined if fails */ export declare function getComponentPathAtEditorPosition(input: string | JsonToken[], position: EditorPosition): string[] | undefined; /** * Return the token that is under the cursor position. * @param tokens List of tokens received from the tokenizer. * @param position * @returns */ export declare function findTokenAtPosition(tokens: JsonToken[], position: EditorPosition): JsonToken | undefined; /** * Recursive function to sets the paths of the JsonTokens. * This function is expected to run at the opening { of a JSON object. * @param {JsonToken} tokens tokens from the JSON parser * @param currentIndex current index where the functions is in the tokens array. Position must lead to the token following the { object opening bracket. * @param path path of the current object at currentIndex * @returns the value of currentIndex */ export declare function fillPathsInJsonObject(tokens: JsonToken[], currentIndex: number, path: string[]): number; /** * Computes position of a token that is given by the path **in the format that is given out by the ScriptAnalyzer**. * @param jsonTokens * @param path the path to the token in the format that is given out by the ScriptAnalyzer, e.g. "catalog:extId.parameters[1](width).visible" * @returns undefined if it was not possible to get the path */ export declare function getPositionFromPath(jsonTokens: JsonToken[], path: string): EditorPosition | undefined; /** * @see fillPathsInJsonObject. * This is a counterpart for JSON arrays. */ export declare function fillPathsInJsonArray(tokens: JsonToken[], currentIndex: number, path: string[]): number;