import Parser from 'web-tree-sitter'; import { CodeElementType } from '../codemodel/CodeElementType'; import { NamedElement } from './NamedElement'; import { LanguageProfile, MemoizedQuery } from "../code-context/base/LanguageProfile"; import { TreeSitterFile } from './TreeSitterFile'; /** * The `NamedElementBuilder` class is used to build named elements (such as variables, methods, and classes) from a * TreeSitter file. It uses the Tree-sitter parsing library to parse the source code and extract the named elements, like * - Class * - Method * - Variable * * @property {LanguageProfile} langConfig - The language configuration for the TypeScript file. * @property {Parser.Tree} tree - The syntax tree of the TypeScript file. * @property {Parser.Language} language - The language of the TypeScript file. * @property {Parser | undefined} parser - The parser used to parse the TypeScript file. * */ export declare class NamedElementBuilder { langConfig: LanguageProfile; tree: Parser.Tree; language: Parser.Language; parser: Parser | undefined; private file; /** * Creates a new `NamedElementBuilder` object. * * @param {TreeSitterFile} file - The TreeSitter file to build named elements from. */ constructor(file: TreeSitterFile); buildVariable(): NamedElement[]; buildMethod(): NamedElement[]; buildClass(): NamedElement[]; /** * The `getElementForAction` method is used to get the named elements (either method or class) that are present at a specific line number in the TypeScript code. * * @param lineNo - The line number in the TypeScript code. * * @returns An array of `NamedElement` objects. Each `NamedElement` object represents a method or class that is present at the specified line number. If no such elements are found, an empty array is returned. * * The method first builds a list of method nodes using the `buildMethod` function. It then filters this list to find the methods that are present at the specified line number. If any such methods are found, they are returned. * * If no methods are found at the specified line number, the method then builds a list of class nodes using the `buildClass` function. It filters this list to find the classes that are present at the specified line number. If any such classes are found, they are returned. * * If no methods or classes are found at the specified line number, the method returns an empty array. * * Note: This method currently does not handle TypeScript imports. */ getElementForAction(lineNo: number): NamedElement[]; getElementForSelection(startLine: number, endLine: number): NamedElement[]; private static isIntersect; private static contains; private static isIntersectRange; private static containsRange; /** * Searches the syntax tree for matches to the given query string and returns a list of identifier-block ranges. * * @param memoizedQuery The memoized query object to use for the search. * @param elementType The type of code element that the query string represents. * @returns An array of `IdentifierBlockRange` objects representing the matches, or a `TreeSitterFileError` if an error occurs. */ buildBlock(memoizedQuery: MemoizedQuery, elementType: CodeElementType): NamedElement[]; }