import Parser, { Language, Tree } from 'web-tree-sitter';
import { ILanguageServiceProvider } from "../base/common/languages/languageService";
import { LanguageProfile } from "../code-context/base/LanguageProfile";
import { LanguageIdentifier } from '../base/common/languages/languages';
import { ScopeGraph } from '../code-search/scope-graph/ScopeGraph';
export declare class TreeSitterFile {
    tree: Tree;
    sourcecode: string;
    readonly languageProfile: LanguageProfile;
    readonly parser: Parser | undefined;
    readonly tsLanguage: Parser.Language;
    readonly filePath: string;
    constructor(src: string, tree: Tree, tsLanguage: LanguageProfile, parser: Parser, language: Language, fsPath?: string);
    private static oneSecond;
    /**
     * The `create` method is a static asynchronous method that creates a new instance of the `TreeSitterFile` class.
     *
     * @param source - A string representing the source code to be parsed.
     * @param langId - A string representing the language identifier.
     * @param languageService - An instance of the `ILanguageServiceProvider` class.
     * @param fsPath - An optional string representing the file system path. Default value is an empty string.
     *
     * @returns A promise that resolves with a new instance of the `TreeSitterFile` class.
     *
     * This method first checks if the size of the source code is larger than 500kb. If it is, the method rejects the
     * promise with a `TreeSitterFileError.fileTooLarge` error.
     *
     * Then, it retrieves the TypeScript configuration using the `TSLanguageUtil.fromId` method. If the configuration
     * is undefined, the method rejects the promise with a `TreeSitterFileError.unsupportedLanguage` error.
     *
     * A new parser is created and the language is set using the `grammar` method of the TypeScript configuration.
     * If an error occurs during this process, or if the language is undefined, the method rejects the promise with a
     * `TreeSitterFileError.languageMismatch` error.
     *
     * The method sets a timeout for the parser to prevent files that take more than 1 second to parse. If the parsing
     * process exceeds this limit, the method rejects the promise with a `TreeSitterFileError.parseTimeout` error.
     *
     * Finally, if all the previous steps are successful, the method creates a new instance of the `TreeSitterFile`
     * class and resolves the promise with it.
     *
     */
    static create(source: string, langId: string, lsp: ILanguageServiceProvider, fsPath?: string): Promise<TreeSitterFile>;
    update(tree: Parser.Tree, sourcecode: string): void;
    static fromParser(parser: Parser, languageService: ILanguageServiceProvider, langId: LanguageIdentifier, code: string): Promise<TreeSitterFile>;
    /**
     * The `scopeGraph` method is an asynchronous function that generates a node graph for the current instance.
     * A node graph is a representation of the scopes and their relationships in a program.
     * This method uses a `ScopeBuilder` to build the node graph.
     *
     * The method first checks if a graph already exists in the cache (`graphCache`) for the current instance (`this`).
     * If it does, it immediately returns a promise that resolves to the cached graph.
     *
     * If a graph does not exist in the cache, the method creates a new query using the language and the node query string
     * from the language configuration (`this.langConfig.scopeQuery.queryStr`).
     * It then creates a new `ScopeBuilder` with the query, the root node of the tree (`this.tree.rootNode`),
     * the source code (`this.sourcecode`), and the language configuration (`this.langConfig`).
     *
     * The method then awaits the building of the node graph by the `ScopeBuilder`.
     * Once the node graph is built, it is added to the cache and returned as a promise.
     *
     * @returns {Promise<ScopeGraph>} A promise that resolves to a `ScopeGraph` object.
     *
     * @throws {Error} If the `ScopeBuilder` fails to build the node graph.
     *
     * @async
     */
    scopeGraph(): Promise<ScopeGraph>;
    isTestFile(): boolean;
}
export declare enum TreeSitterFileError {
    unsupportedLanguage = 0,
    parseTimeout = 1,
    languageMismatch = 2,
    queryError = 3,
    fileTooLarge = 4
}
export declare function convertToErrorMessage(error: TreeSitterFileError): string;
