import { NervusDB } from '@nervusdb/core'; import type { IndexMetadata } from '../types/indexMetadata.js'; interface FingerprintValidator { validate(projectPath: string): Promise; } export interface GraphFact { subject: string; predicate: string; object: string; properties?: Record; } /** * 代码实体定义 */ export interface CodeEntityInfo { nodeId: string; name: string; type: string; filePath: string; signature?: string; language?: string; startLine?: number; endLine?: number; } /** * 调用层次节点 */ export interface CallHierarchyNode { entity: CodeEntityInfo; callers: CallHierarchyNode[]; callees: CallHierarchyNode[]; depth: number; } /** * 依赖树节点 */ export interface DependencyNode { filePath: string; dependencies: DependencyNode[]; depth: number; } /** * 影响范围分析结果 */ export interface ImpactAnalysis { targetEntity: string; directCallers: CodeEntityInfo[]; indirectCallers: CodeEntityInfo[]; affectedFiles: string[]; depth: number; } interface FactFilter { subject?: string; predicate?: string; object?: string; } interface QueryOptions { limit?: number; depth?: number; } interface QueryDependencies { fingerprint: FingerprintValidator; openDatabase?: typeof NervusDB.open; } export declare class QueryService { private readonly fingerprint; private readonly openDatabase; constructor(deps: QueryDependencies); findFacts(projectPath: string, filter: FactFilter, options?: QueryOptions): Promise; /** * 查找函数的所有调用者 * @param projectPath 项目路径 * @param functionName 函数名称或节点ID * @param options 查询选项 */ findCallers(projectPath: string, functionName: string, options?: QueryOptions): Promise; /** * 查找函数调用的所有函数(被调用者) * @param projectPath 项目路径 * @param functionName 函数名称或节点ID * @param options 查询选项 */ findCallees(projectPath: string, functionName: string, options?: QueryOptions): Promise; /** * 查找接口的所有实现类 * @param projectPath 项目路径 * @param interfaceName 接口名称或节点ID * @param options 查询选项 */ findImplementations(projectPath: string, interfaceName: string, options?: QueryOptions): Promise; /** * 查找类的继承关系(子类) * @param projectPath 项目路径 * @param className 类名称或节点ID * @param options 查询选项 */ findSubclasses(projectPath: string, className: string, options?: QueryOptions): Promise; /** * 查找类的父类 * @param projectPath 项目路径 * @param className 类名称或节点ID * @param options 查询选项 */ findSuperclass(projectPath: string, className: string, options?: QueryOptions): Promise; /** * 查找文件的所有导入 * @param projectPath 项目路径 * @param filePath 文件路径 * @param options 查询选项 */ findImports(projectPath: string, filePath: string, options?: QueryOptions): Promise; /** * 查找导入了指定文件的所有文件 * @param projectPath 项目路径 * @param filePath 文件路径 * @param options 查询选项 */ findImporters(projectPath: string, filePath: string, options?: QueryOptions): Promise; /** * 查找文件定义的所有实体(函数、类、接口等) * @param projectPath 项目路径 * @param filePath 文件路径 * @param options 查询选项 */ findDefinitions(projectPath: string, filePath: string, options?: QueryOptions): Promise; /** * 查找符号的定义位置 * @param projectPath 项目路径 * @param symbolName 符号名称 */ findSymbolDefinition(projectPath: string, symbolName: string): Promise; /** * 递归查找文件依赖树 * @param projectPath 项目路径 * @param filePath 文件路径 * @param maxDepth 最大递归深度(默认3) */ findDependencies(projectPath: string, filePath: string, maxDepth?: number): Promise; /** * 分析符号变更的影响范围 * @param projectPath 项目路径 * @param symbolName 符号名称(函数、类等) * @param maxDepth 最大递归深度(默认3) */ analyzeImpact(projectPath: string, symbolName: string, maxDepth?: number): Promise; /** * 获取调用层次结构(调用者和被调用者) * @param projectPath 项目路径 * @param functionName 函数名称 * @param maxDepth 最大深度(默认2) */ getCallHierarchy(projectPath: string, functionName: string, maxDepth?: number): Promise; /** * 将GraphFact转换为CodeEntityInfo */ private factToEntityInfo; /** * 获取实体的详细信息 */ private getEntityInfo; /** * 从节点ID提取名称 */ private extractName; /** * 从节点ID提取类型 */ private extractType; /** * 从节点ID提取文件路径 */ private extractFilePath; findFileMembership(projectPath: string, filePath: string, options?: QueryOptions): Promise; } export {};