UNPKG

opencoder

Version:
1,043 lines (1,042 loc) 43.5 kB
declare namespace _default { export { CaptureQuantifier }; export { LANGUAGE_VERSION }; export { Language }; export { LookaheadIterator }; export { MIN_COMPATIBLE_VERSION }; export { Node }; export { Parser }; export { Query }; export { Tree }; export { TreeCursor }; } export default _default; declare namespace CaptureQuantifier { let Zero: number; let ZeroOrOne: number; let ZeroOrMore: number; let One: number; let OneOrMore: number; } declare var LANGUAGE_VERSION: any; declare var Language: { new (internal: any, address: any): { /** @internal */ 0: number; /** * A list of all node types in the language. The index of each type in this * array is its node type id. */ types: any[]; /** * A list of all field names in the language. The index of each field name in * this array is its field id. */ fields: any[]; /** * Gets the name of the language. */ readonly name: any; /** * @deprecated since version 0.25.0, use {@link Language#abiVersion} instead * Gets the version of the language. */ readonly version: any; /** * Gets the ABI version of the language. */ readonly abiVersion: any; /** * Get the metadata for this language. This information is generated by the * CLI, and relies on the language author providing the correct metadata in * the language's `tree-sitter.json` file. */ readonly metadata: { major_version: any; minor_version: any; field_count: any; } | null; /** * Gets the number of fields in the language. */ readonly fieldCount: number; /** * Gets the number of states in the language. */ readonly stateCount: any; /** * Get the field id for a field name. */ fieldIdForName(fieldName: any): number | null; /** * Get the field name for a field id. */ fieldNameForId(fieldId: any): any; /** * Get the node type id for a node type name. */ idForNodeType(type: any, named: any): any; /** * Gets the number of node types in the language. */ readonly nodeTypeCount: any; /** * Get the node type name for a node type id. */ nodeTypeForId(typeId: any): any; /** * Check if a node type is named. * * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html#named-vs-anonymous-nodes} */ nodeTypeIsNamed(typeId: any): boolean; /** * Check if a node type is visible. */ nodeTypeIsVisible(typeId: any): boolean; /** * Get the supertypes ids of this language. * * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types.html?highlight=supertype#supertype-nodes} */ readonly supertypes: any[]; /** * Get the subtype ids for a given supertype node id. */ subtypes(supertype: any): any[]; /** * Get the next state id for a given state id and node type id. */ nextState(stateId: any, typeId: any): any; /** * Create a new lookahead iterator for this language and parse state. * * This returns `null` if state is invalid for this language. * * Iterating {@link LookaheadIterator} will yield valid symbols in the given * parse state. Newly created lookahead iterators will return the `ERROR` * symbol from {@link LookaheadIterator#currentType}. * * Lookahead iterators can be useful for generating suggestions and improving * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the * lookahead iterator on its first leaf node state. For `MISSING` nodes, a * lookahead iterator created on the previous non-extra leaf node may be * appropriate. */ lookaheadIterator(stateId: any): { /** @internal */ 0: number; /** @internal */ language: any; /** Get the current symbol of the lookahead iterator. */ readonly currentTypeId: any; /** Get the current symbol name of the lookahead iterator. */ readonly currentType: any; /** Delete the lookahead iterator, freeing its resources. */ delete(): void; /** * Reset the lookahead iterator. * * This returns `true` if the language was set successfully and `false` * otherwise. */ reset(language: any, stateId: any): boolean; /** * Reset the lookahead iterator to another state. * * This returns `true` if the iterator was reset to the given state and * `false` otherwise. */ resetState(stateId: any): boolean; /** * Returns an iterator that iterates over the symbols of the lookahead iterator. * * The iterator will yield the current symbol name as a string for each step * until there are no more symbols to iterate over. */ [Symbol.iterator](): { next: any; }; } | null; /** * @deprecated since version 0.25.0, call `new` on a {@link Query} instead * * Create a new query from a string containing one or more S-expression * patterns. * * The query is associated with a particular language, and can only be run * on syntax nodes parsed with that language. References to Queries can be * shared between multiple threads. * * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries} */ query(source: any): { /** @internal */ 0: number; /** @internal */ exceededMatchLimit: boolean; /** @internal */ textPredicates: any[]; /** The names of the captures used in the query. */ captureNames: any[]; /** The quantifiers of the captures used in the query. */ captureQuantifiers: any[]; /** * The other user-defined predicates associated with the given index. * * This includes predicates with operators other than: * - `match?` * - `eq?` and `not-eq?` * - `any-of?` and `not-any-of?` * - `is?` and `is-not?` * - `set!` */ predicates: any[]; /** The properties for predicates with the operator `set!`. */ setProperties: any[]; /** The properties for predicates with the operator `is?`. */ assertedProperties: any[]; /** The properties for predicates with the operator `is-not?`. */ refutedProperties: any[]; /** The maximum number of in-progress matches for this cursor. */ matchLimit: any; /** Delete the query, freeing its resources. */ delete(): void; /** * Iterate over all of the matches in the order that they were found. * * Each match contains the index of the pattern that matched, and a list of * captures. Because multiple patterns can match the same set of nodes, * one match may contain captures that appear *before* some of the * captures from a previous match. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ matches(node: Node, options?: QueryOptions): any[]; /** * Iterate over all of the individual captures in the order that they * appear. * * This is useful if you don't care about which pattern matched, and just * want a single, ordered sequence of captures. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ captures(node: Node, options?: QueryOptions): any[]; /** Get the predicates for a given pattern. */ predicatesForPattern(patternIndex: any): any; /** * Disable a certain capture within a query. * * This prevents the capture from being returned in matches, and also * avoids any resource usage associated with recording the capture. */ disableCapture(captureName: any): void; /** * Disable a certain pattern within a query. * * This prevents the pattern from matching, and also avoids any resource * usage associated with the pattern. This throws an error if the pattern * index is out of bounds. */ disablePattern(patternIndex: any): void; /** * Check if, on its last execution, this cursor exceeded its maximum number * of in-progress matches. */ didExceedMatchLimit(): boolean; /** Get the byte offset where the given pattern starts in the query's source. */ startIndexForPattern(patternIndex: any): any; /** Get the byte offset where the given pattern ends in the query's source. */ endIndexForPattern(patternIndex: any): any; /** Get the number of patterns in the query. */ patternCount(): any; /** Get the index for a given capture name. */ captureIndexForName(captureName: any): number; /** Check if a given pattern within a query has a single root node. */ isPatternRooted(patternIndex: any): boolean; /** Check if a given pattern within a query has a single root node. */ isPatternNonLocal(patternIndex: any): boolean; /** * Check if a given step in a query is 'definite'. * * A query step is 'definite' if its parent pattern will be guaranteed to * match successfully once it reaches the step. */ isPatternGuaranteedAtStep(byteIndex: any): boolean; }; }; /** * Load a language from a WebAssembly module. * The module can be provided as a path to a file or as a buffer. */ load(input: any): Promise<{ /** @internal */ 0: number; /** * A list of all node types in the language. The index of each type in this * array is its node type id. */ types: any[]; /** * A list of all field names in the language. The index of each field name in * this array is its field id. */ fields: any[]; /** * Gets the name of the language. */ readonly name: any; /** * @deprecated since version 0.25.0, use {@link Language#abiVersion} instead * Gets the version of the language. */ readonly version: any; /** * Gets the ABI version of the language. */ readonly abiVersion: any; /** * Get the metadata for this language. This information is generated by the * CLI, and relies on the language author providing the correct metadata in * the language's `tree-sitter.json` file. */ readonly metadata: { major_version: any; minor_version: any; field_count: any; } | null; /** * Gets the number of fields in the language. */ readonly fieldCount: number; /** * Gets the number of states in the language. */ readonly stateCount: any; /** * Get the field id for a field name. */ fieldIdForName(fieldName: any): number | null; /** * Get the field name for a field id. */ fieldNameForId(fieldId: any): any; /** * Get the node type id for a node type name. */ idForNodeType(type: any, named: any): any; /** * Gets the number of node types in the language. */ readonly nodeTypeCount: any; /** * Get the node type name for a node type id. */ nodeTypeForId(typeId: any): any; /** * Check if a node type is named. * * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html#named-vs-anonymous-nodes} */ nodeTypeIsNamed(typeId: any): boolean; /** * Check if a node type is visible. */ nodeTypeIsVisible(typeId: any): boolean; /** * Get the supertypes ids of this language. * * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types.html?highlight=supertype#supertype-nodes} */ readonly supertypes: any[]; /** * Get the subtype ids for a given supertype node id. */ subtypes(supertype: any): any[]; /** * Get the next state id for a given state id and node type id. */ nextState(stateId: any, typeId: any): any; /** * Create a new lookahead iterator for this language and parse state. * * This returns `null` if state is invalid for this language. * * Iterating {@link LookaheadIterator} will yield valid symbols in the given * parse state. Newly created lookahead iterators will return the `ERROR` * symbol from {@link LookaheadIterator#currentType}. * * Lookahead iterators can be useful for generating suggestions and improving * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the * lookahead iterator on its first leaf node state. For `MISSING` nodes, a * lookahead iterator created on the previous non-extra leaf node may be * appropriate. */ lookaheadIterator(stateId: any): { /** @internal */ 0: number; /** @internal */ language: any; /** Get the current symbol of the lookahead iterator. */ readonly currentTypeId: any; /** Get the current symbol name of the lookahead iterator. */ readonly currentType: any; /** Delete the lookahead iterator, freeing its resources. */ delete(): void; /** * Reset the lookahead iterator. * * This returns `true` if the language was set successfully and `false` * otherwise. */ reset(language: any, stateId: any): boolean; /** * Reset the lookahead iterator to another state. * * This returns `true` if the iterator was reset to the given state and * `false` otherwise. */ resetState(stateId: any): boolean; /** * Returns an iterator that iterates over the symbols of the lookahead iterator. * * The iterator will yield the current symbol name as a string for each step * until there are no more symbols to iterate over. */ [Symbol.iterator](): { next: any; }; } | null; /** * @deprecated since version 0.25.0, call `new` on a {@link Query} instead * * Create a new query from a string containing one or more S-expression * patterns. * * The query is associated with a particular language, and can only be run * on syntax nodes parsed with that language. References to Queries can be * shared between multiple threads. * * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries} */ query(source: any): { /** @internal */ 0: number; /** @internal */ exceededMatchLimit: boolean; /** @internal */ textPredicates: any[]; /** The names of the captures used in the query. */ captureNames: any[]; /** The quantifiers of the captures used in the query. */ captureQuantifiers: any[]; /** * The other user-defined predicates associated with the given index. * * This includes predicates with operators other than: * - `match?` * - `eq?` and `not-eq?` * - `any-of?` and `not-any-of?` * - `is?` and `is-not?` * - `set!` */ predicates: any[]; /** The properties for predicates with the operator `set!`. */ setProperties: any[]; /** The properties for predicates with the operator `is?`. */ assertedProperties: any[]; /** The properties for predicates with the operator `is-not?`. */ refutedProperties: any[]; /** The maximum number of in-progress matches for this cursor. */ matchLimit: any; /** Delete the query, freeing its resources. */ delete(): void; /** * Iterate over all of the matches in the order that they were found. * * Each match contains the index of the pattern that matched, and a list of * captures. Because multiple patterns can match the same set of nodes, * one match may contain captures that appear *before* some of the * captures from a previous match. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ matches(node: Node, options?: QueryOptions): any[]; /** * Iterate over all of the individual captures in the order that they * appear. * * This is useful if you don't care about which pattern matched, and just * want a single, ordered sequence of captures. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ captures(node: Node, options?: QueryOptions): any[]; /** Get the predicates for a given pattern. */ predicatesForPattern(patternIndex: any): any; /** * Disable a certain capture within a query. * * This prevents the capture from being returned in matches, and also * avoids any resource usage associated with recording the capture. */ disableCapture(captureName: any): void; /** * Disable a certain pattern within a query. * * This prevents the pattern from matching, and also avoids any resource * usage associated with the pattern. This throws an error if the pattern * index is out of bounds. */ disablePattern(patternIndex: any): void; /** * Check if, on its last execution, this cursor exceeded its maximum number * of in-progress matches. */ didExceedMatchLimit(): boolean; /** Get the byte offset where the given pattern starts in the query's source. */ startIndexForPattern(patternIndex: any): any; /** Get the byte offset where the given pattern ends in the query's source. */ endIndexForPattern(patternIndex: any): any; /** Get the number of patterns in the query. */ patternCount(): any; /** Get the index for a given capture name. */ captureIndexForName(captureName: any): number; /** Check if a given pattern within a query has a single root node. */ isPatternRooted(patternIndex: any): boolean; /** Check if a given pattern within a query has a single root node. */ isPatternNonLocal(patternIndex: any): boolean; /** * Check if a given step in a query is 'definite'. * * A query step is 'definite' if its parent pattern will be guaranteed to * match successfully once it reaches the step. */ isPatternGuaranteedAtStep(byteIndex: any): boolean; }; }>; }; declare var LookaheadIterator: { new (internal: any, address: any, language: any): { /** @internal */ 0: number; /** @internal */ language: any; /** Get the current symbol of the lookahead iterator. */ readonly currentTypeId: any; /** Get the current symbol name of the lookahead iterator. */ readonly currentType: any; /** Delete the lookahead iterator, freeing its resources. */ delete(): void; /** * Reset the lookahead iterator. * * This returns `true` if the language was set successfully and `false` * otherwise. */ reset(language: any, stateId: any): boolean; /** * Reset the lookahead iterator to another state. * * This returns `true` if the iterator was reset to the given state and * `false` otherwise. */ resetState(stateId: any): boolean; /** * Returns an iterator that iterates over the symbols of the lookahead iterator. * * The iterator will yield the current symbol name as a string for each step * until there are no more symbols to iterate over. */ [Symbol.iterator](): { next: any; }; }; }; declare var MIN_COMPATIBLE_VERSION: any; declare var Parser: { new (): { /** @internal */ 0: number; /** @internal */ 1: number; /** @internal */ logCallback: null; /** The parser's current language. */ language: null; /** @internal */ initialize(): void; /** Delete the parser, freeing its resources. */ delete(): void; /** * Set the language that the parser should use for parsing. * * If the language was not successfully assigned, an error will be thrown. * This happens if the language was generated with an incompatible * version of the Tree-sitter CLI. Check the language's version using * {@link Language#version} and compare it to this library's * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants. */ setLanguage(language: any): /*elided*/ any; /** * Parse a slice of UTF8 text. * * @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function. * * @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the * document has changed since `oldTree` was created, then you must edit `oldTree` to match * the new text using {@link Tree#edit}. * * @param {ParseOptions} [options] - Options for parsing the text. * This can be used to set the included ranges, or a progress callback. * * @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if: * - The parser has not yet had a language assigned with {@link Parser#setLanguage}. * - The progress callback returned true. */ parse(callback: string | ParseCallback, oldTree?: { /** @internal */ 0: number; /** @internal */ textCallback: any; /** The language that was used to parse the syntax tree. */ language: any; /** Create a shallow copy of the syntax tree. This is very fast. */ copy(): /*elided*/ any; /** Delete the syntax tree, freeing its resources. */ delete(): void; /** Get the root node of the syntax tree. */ readonly rootNode: any; /** * Get the root node of the syntax tree, but with its position shifted * forward by the given offset. */ rootNodeWithOffset(offsetBytes: any, offsetExtent: any): any; /** * Edit the syntax tree to keep it in sync with source code that has been * edited. * * You must describe the edit both in terms of byte offsets and in terms of * row/column coordinates. */ edit(edit: any): void; /** Create a new {@link TreeCursor} starting from the root of the tree. */ walk(): any; /** * Compare this old edited syntax tree to a new syntax tree representing * the same document, returning a sequence of ranges whose syntactic * structure has changed. * * For this to work correctly, this syntax tree must have been edited such * that its ranges match up to the new tree. Generally, you'll want to * call this method right after calling one of the [`Parser::parse`] * functions. Call it on the old tree that was passed to parse, and * pass the new tree that was returned from `parse`. */ getChangedRanges(other: any): any[]; /** Get the included ranges that were used to parse the syntax tree. */ getIncludedRanges(): any[]; } | null, options?: ParseOptions): { /** @internal */ 0: number; /** @internal */ textCallback: any; /** The language that was used to parse the syntax tree. */ language: any; /** Create a shallow copy of the syntax tree. This is very fast. */ copy(): /*elided*/ any; /** Delete the syntax tree, freeing its resources. */ delete(): void; /** Get the root node of the syntax tree. */ readonly rootNode: any; /** * Get the root node of the syntax tree, but with its position shifted * forward by the given offset. */ rootNodeWithOffset(offsetBytes: any, offsetExtent: any): any; /** * Edit the syntax tree to keep it in sync with source code that has been * edited. * * You must describe the edit both in terms of byte offsets and in terms of * row/column coordinates. */ edit(edit: any): void; /** Create a new {@link TreeCursor} starting from the root of the tree. */ walk(): any; /** * Compare this old edited syntax tree to a new syntax tree representing * the same document, returning a sequence of ranges whose syntactic * structure has changed. * * For this to work correctly, this syntax tree must have been edited such * that its ranges match up to the new tree. Generally, you'll want to * call this method right after calling one of the [`Parser::parse`] * functions. Call it on the old tree that was passed to parse, and * pass the new tree that was returned from `parse`. */ getChangedRanges(other: any): any[]; /** Get the included ranges that were used to parse the syntax tree. */ getIncludedRanges(): any[]; } | null; /** * Instruct the parser to start the next parse from the beginning. * * If the parser previously failed because of a timeout, cancellation, * or callback, then by default, it will resume where it left off on the * next call to {@link Parser#parse} or other parsing functions. * If you don't want to resume, and instead intend to use this parser to * parse some other document, you must call `reset` first. */ reset(): void; /** Get the ranges of text that the parser will include when parsing. */ getIncludedRanges(): any[]; /** * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse} * * Get the duration in microseconds that parsing is allowed to take. * * This is set via {@link Parser#setTimeoutMicros}. */ getTimeoutMicros(): any; /** * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse} * * Set the maximum duration in microseconds that parsing should be allowed * to take before halting. * * If parsing takes longer than this, it will halt early, returning `null`. * See {@link Parser#parse} for more information. */ setTimeoutMicros(timeout: any): void; /** Set the logging callback that a parser should use during parsing. */ setLogger(callback: any): /*elided*/ any; /** Get the parser's current logger. */ getLogger(): null; }; /** * This must always be called before creating a Parser. * * You can optionally pass in options to configure the WASM module, the most common * one being `locateFile` to help the module find the `.wasm` file. */ init(moduleOptions: any): Promise<void>; }; declare var Query: { new (language: any, source: any): { /** @internal */ 0: number; /** @internal */ exceededMatchLimit: boolean; /** @internal */ textPredicates: any[]; /** The names of the captures used in the query. */ captureNames: any[]; /** The quantifiers of the captures used in the query. */ captureQuantifiers: any[]; /** * The other user-defined predicates associated with the given index. * * This includes predicates with operators other than: * - `match?` * - `eq?` and `not-eq?` * - `any-of?` and `not-any-of?` * - `is?` and `is-not?` * - `set!` */ predicates: any[]; /** The properties for predicates with the operator `set!`. */ setProperties: any[]; /** The properties for predicates with the operator `is?`. */ assertedProperties: any[]; /** The properties for predicates with the operator `is-not?`. */ refutedProperties: any[]; /** The maximum number of in-progress matches for this cursor. */ matchLimit: any; /** Delete the query, freeing its resources. */ delete(): void; /** * Iterate over all of the matches in the order that they were found. * * Each match contains the index of the pattern that matched, and a list of * captures. Because multiple patterns can match the same set of nodes, * one match may contain captures that appear *before* some of the * captures from a previous match. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ matches(node: Node, options?: QueryOptions): any[]; /** * Iterate over all of the individual captures in the order that they * appear. * * This is useful if you don't care about which pattern matched, and just * want a single, ordered sequence of captures. * * @param {Node} node - The node to execute the query on. * * @param {QueryOptions} options - Options for query execution. */ captures(node: Node, options?: QueryOptions): any[]; /** Get the predicates for a given pattern. */ predicatesForPattern(patternIndex: any): any; /** * Disable a certain capture within a query. * * This prevents the capture from being returned in matches, and also * avoids any resource usage associated with recording the capture. */ disableCapture(captureName: any): void; /** * Disable a certain pattern within a query. * * This prevents the pattern from matching, and also avoids any resource * usage associated with the pattern. This throws an error if the pattern * index is out of bounds. */ disablePattern(patternIndex: any): void; /** * Check if, on its last execution, this cursor exceeded its maximum number * of in-progress matches. */ didExceedMatchLimit(): boolean; /** Get the byte offset where the given pattern starts in the query's source. */ startIndexForPattern(patternIndex: any): any; /** Get the byte offset where the given pattern ends in the query's source. */ endIndexForPattern(patternIndex: any): any; /** Get the number of patterns in the query. */ patternCount(): any; /** Get the index for a given capture name. */ captureIndexForName(captureName: any): number; /** Check if a given pattern within a query has a single root node. */ isPatternRooted(patternIndex: any): boolean; /** Check if a given pattern within a query has a single root node. */ isPatternNonLocal(patternIndex: any): boolean; /** * Check if a given step in a query is 'definite'. * * A query step is 'definite' if its parent pattern will be guaranteed to * match successfully once it reaches the step. */ isPatternGuaranteedAtStep(byteIndex: any): boolean; }; }; declare var Tree: { new (internal: any, address: any, language: any, textCallback: any): { /** @internal */ 0: number; /** @internal */ textCallback: any; /** The language that was used to parse the syntax tree. */ language: any; /** Create a shallow copy of the syntax tree. This is very fast. */ copy(): /*elided*/ any; /** Delete the syntax tree, freeing its resources. */ delete(): void; /** Get the root node of the syntax tree. */ readonly rootNode: any; /** * Get the root node of the syntax tree, but with its position shifted * forward by the given offset. */ rootNodeWithOffset(offsetBytes: any, offsetExtent: any): any; /** * Edit the syntax tree to keep it in sync with source code that has been * edited. * * You must describe the edit both in terms of byte offsets and in terms of * row/column coordinates. */ edit(edit: any): void; /** Create a new {@link TreeCursor} starting from the root of the tree. */ walk(): any; /** * Compare this old edited syntax tree to a new syntax tree representing * the same document, returning a sequence of ranges whose syntactic * structure has changed. * * For this to work correctly, this syntax tree must have been edited such * that its ranges match up to the new tree. Generally, you'll want to * call this method right after calling one of the [`Parser::parse`] * functions. Call it on the old tree that was passed to parse, and * pass the new tree that was returned from `parse`. */ getChangedRanges(other: any): any[]; /** Get the included ranges that were used to parse the syntax tree. */ getIncludedRanges(): any[]; }; }; declare var TreeCursor: { new (internal: any, tree: any): { /** @internal */ 0: number; /** @internal */ 1: number; /** @internal */ 2: number; /** @internal */ 3: number; /** @internal */ tree: any; /** Creates a deep copy of the tree cursor. This allocates new memory. */ copy(): /*elided*/ any; /** Delete the tree cursor, freeing its resources. */ delete(): void; /** Get the tree cursor's current {@link Node}. */ readonly currentNode: any; /** * Get the numerical field id of this tree cursor's current node. * * See also {@link TreeCursor#currentFieldName}. */ readonly currentFieldId: any; /** Get the field name of this tree cursor's current node. */ readonly currentFieldName: any; /** * Get the depth of the cursor's current node relative to the original * node that the cursor was constructed with. */ readonly currentDepth: any; /** * Get the index of the cursor's current node out of all of the * descendants of the original node that the cursor was constructed with. */ readonly currentDescendantIndex: any; /** Get the type of the cursor's current node. */ readonly nodeType: any; /** Get the type id of the cursor's current node. */ readonly nodeTypeId: any; /** Get the state id of the cursor's current node. */ readonly nodeStateId: any; /** Get the id of the cursor's current node. */ readonly nodeId: any; /** * Check if the cursor's current node is *named*. * * Named nodes correspond to named rules in the grammar, whereas * *anonymous* nodes correspond to string literals in the grammar. */ readonly nodeIsNamed: boolean; /** * Check if the cursor's current node is *missing*. * * Missing nodes are inserted by the parser in order to recover from * certain kinds of syntax errors. */ readonly nodeIsMissing: boolean; /** Get the string content of the cursor's current node. */ readonly nodeText: any; /** Get the start position of the cursor's current node. */ readonly startPosition: { row: number; column: number; }; /** Get the end position of the cursor's current node. */ readonly endPosition: { row: number; column: number; }; /** Get the start index of the cursor's current node. */ readonly startIndex: any; /** Get the end index of the cursor's current node. */ readonly endIndex: any; /** * Move this cursor to the first child of its current node. * * This returns `true` if the cursor successfully moved, and returns * `false` if there were no children. */ gotoFirstChild(): boolean; /** * Move this cursor to the last child of its current node. * * This returns `true` if the cursor successfully moved, and returns * `false` if there were no children. * * Note that this function may be slower than * {@link TreeCursor#gotoFirstChild} because it needs to * iterate through all the children to compute the child's position. */ gotoLastChild(): boolean; /** * Move this cursor to the parent of its current node. * * This returns `true` if the cursor successfully moved, and returns * `false` if there was no parent node (the cursor was already on the * root node). * * Note that the node the cursor was constructed with is considered the root * of the cursor, and the cursor cannot walk outside this node. */ gotoParent(): boolean; /** * Move this cursor to the next sibling of its current node. * * This returns `true` if the cursor successfully moved, and returns * `false` if there was no next sibling node. * * Note that the node the cursor was constructed with is considered the root * of the cursor, and the cursor cannot walk outside this node. */ gotoNextSibling(): boolean; /** * Move this cursor to the previous sibling of its current node. * * This returns `true` if the cursor successfully moved, and returns * `false` if there was no previous sibling node. * * Note that this function may be slower than * {@link TreeCursor#gotoNextSibling} due to how node * positions are stored. In the worst case, this will need to iterate * through all the children up to the previous sibling node to recalculate * its position. Also note that the node the cursor was constructed with is * considered the root of the cursor, and the cursor cannot walk outside this node. */ gotoPreviousSibling(): boolean; /** * Move the cursor to the node that is the nth descendant of * the original node that the cursor was constructed with, where * zero represents the original node itself. */ gotoDescendant(goalDescendantIndex: any): void; /** * Move this cursor to the first child of its current node that contains or * starts after the given byte offset. * * This returns `true` if the cursor successfully moved to a child node, and returns * `false` if no such child was found. */ gotoFirstChildForIndex(goalIndex: any): boolean; /** * Move this cursor to the first child of its current node that contains or * starts after the given byte offset. * * This returns the index of the child node if one was found, and returns * `null` if no such child was found. */ gotoFirstChildForPosition(goalPosition: any): boolean; /** * Re-initialize this tree cursor to start at the original node that the * cursor was constructed with. */ reset(node: any): void; /** * Re-initialize a tree cursor to the same position as another cursor. * * Unlike {@link TreeCursor#reset}, this will not lose parent * information and allows reusing already created cursors. */ resetTo(cursor: any): void; }; };