import Parser, { Query, SyntaxNode } from 'web-tree-sitter'; import { ImportWithRefs } from '../../code-search/scope-graph/model/ImportWithRefs'; import { ScopeGraph } from '../../code-search/scope-graph/ScopeGraph'; import { LanguageProfile } from './LanguageProfile'; import { CodeFile, CodeFunction, CodeVariable } from "../../codemodel/CodeElement"; import { ILanguageServiceProvider } from '../../base/common/languages/languageService'; import { PositionElement } from "../../codemodel/PositionElement"; import { LanguageIdentifier } from "../../base/common/languages/languages"; export interface StructurerProvider { /** * For wrapper int test and source code. */ init(langService: ILanguageServiceProvider): Promise; /** * The `langId` property is a string representing the language identifier of the structurer provider. */ isApplicable(lang: LanguageIdentifier): any; /** * Parses the given code and returns a `CodeFile` object. */ parseFile(code: string, path: string): Promise; } export declare abstract class BaseStructurerProvider implements StructurerProvider { protected abstract langId: LanguageIdentifier; protected abstract config: LanguageProfile; protected abstract parser: Parser | undefined; protected abstract language: Parser.Language | undefined; abstract isApplicable(lang: LanguageIdentifier): boolean; abstract parseFile(code: string, path: string): Promise; /** * The `init` method is an asynchronous function that initializes the structurer provider with the given language service. */ init(langService: ILanguageServiceProvider): Promise; insertLocation(node: SyntaxNode, model: PositionElement): void; createFunction(syntaxNode: SyntaxNode, text: string): CodeFunction; createVariable(node: SyntaxNode, text: string, typ: string): CodeVariable; initVariable(): CodeVariable; fetchImportsWithinScope(scope: ScopeGraph, node: SyntaxNode, src: string): Promise; /** * The `retrieveImportReferences` method is a private method that retrieves all import references from a given source * code that are within a specified syntax node. * * @param scope - An instance of `ScopeGraph`. This parameter represents the node graph of the source code. * @param src - A string representing the source code from which to retrieve import references. * @param node - An instance of `SyntaxNode`. This parameter represents the syntax node within which to search for import references. * * @returns An array of `ImportWithRefs` objects. Each object in the array represents an import reference that is * within the specified syntax node. If no import references are found within the syntax node, an empty array is returned. */ retrieveImportReferences(scope: ScopeGraph, src: string, node: SyntaxNode): ImportWithRefs[]; /** * The `combineSimilarClasses` method is used to combine classes with the same name in a given code file. * It merges the methods and fields of classes with the same name into a single class. * * @param codeFile - An object of type `CodeFile` which contains an array of classes. Each class has a name, methods, and fields. * * @returns The updated `codeFile` with combined classes. * * Note: If a class does not have any fields, they will not be added to the combined class. * */ combineSimilarClasses(codeFile: CodeFile): CodeFile; }