UNPKG

superaugment

Version:

Enterprise-grade MCP server with world-class C++ analysis, robust error handling, and production-ready architecture for VS Code Augment

328 lines 8.1 kB
/** * Enhanced C++ Analyzer with Tree-sitter AST Support * * Provides comprehensive C++ code analysis using Tree-sitter for accurate * syntax parsing, semantic analysis, and advanced code understanding. */ /** * Enhanced C++ analysis result with AST-based insights */ export interface EnhancedCppAnalysisResult { metrics: { totalLines: number; codeLines: number; commentLines: number; blankLines: number; complexity: ComplexityMetrics; }; structure: { namespaces: CppNamespace[]; classes: CppClass[]; functions: CppFunction[]; variables: CppVariable[]; enums: CppEnum[]; templates: CppTemplate[]; macros: CppMacro[]; }; dependencies: { systemIncludes: string[]; userIncludes: string[]; dependencyGraph: DependencyNode[]; circularDependencies: string[][]; }; modernCpp: { cppStandard: string; featuresUsed: ModernCppFeature[]; recommendations: string[]; score: number; }; performance: { hotspots: PerformanceHotspot[]; optimizations: OptimizationSuggestion[]; score: number; }; memory: { issues: MemoryIssue[]; smartPointerUsage: SmartPointerAnalysis; raii: RaiiAnalysis; score: number; }; security: { vulnerabilities: SecurityVulnerability[]; recommendations: string[]; score: number; }; cuda?: { kernels: CudaKernel[]; memoryTransfers: CudaMemoryTransfer[]; optimizations: CudaOptimization[]; score: number; }; } export interface ComplexityMetrics { cyclomatic: number; cognitive: number; halstead: HalsteadMetrics; maintainabilityIndex: number; } export interface HalsteadMetrics { vocabulary: number; length: number; volume: number; difficulty: number; effort: number; timeToProgram: number; bugsDelivered: number; } export interface CppNamespace { name: string; line: number; column: number; nested: boolean; members: string[]; } export interface CppClass { name: string; line: number; column: number; type: 'class' | 'struct' | 'union'; inheritance: string[]; members: ClassMember[]; isTemplate: boolean; templateParameters?: string[]; accessSpecifiers: AccessSpecifier[]; } export interface ClassMember { name: string; type: string; memberType: 'field' | 'method' | 'constructor' | 'destructor'; visibility: 'public' | 'private' | 'protected'; isStatic: boolean; isVirtual: boolean; isConst: boolean; line: number; } export interface AccessSpecifier { type: 'public' | 'private' | 'protected'; line: number; } export interface CppFunction { name: string; line: number; column: number; returnType: string; parameters: FunctionParameter[]; isStatic: boolean; isVirtual: boolean; isConst: boolean; isNoexcept: boolean; isTemplate: boolean; templateParameters?: string[]; complexity: number; bodyLines: number; } export interface FunctionParameter { name: string; type: string; defaultValue?: string; isConst: boolean; isReference: boolean; isPointer: boolean; } export interface CppVariable { name: string; type: string; line: number; column: number; isGlobal: boolean; isStatic: boolean; isConst: boolean; isConstexpr: boolean; initialValue?: string; } export interface CppEnum { name: string; line: number; column: number; isScoped: boolean; underlyingType?: string; values: EnumValue[]; } export interface EnumValue { name: string; value?: string; line: number; } export interface CppTemplate { name: string; line: number; column: number; type: 'function' | 'class' | 'variable' | 'alias'; parameters: TemplateParameter[]; specializations: string[]; } export interface TemplateParameter { name: string; type: 'typename' | 'class' | 'auto' | 'value'; defaultValue?: string; } export interface CppMacro { name: string; line: number; column: number; parameters?: string[]; body: string; isFunctionLike: boolean; } export interface DependencyNode { file: string; includes: string[]; includedBy: string[]; depth: number; } export interface ModernCppFeature { name: string; standard: string; used: boolean; locations: FeatureLocation[]; recommendation?: string; } export interface FeatureLocation { line: number; column: number; context: string; } export interface PerformanceHotspot { type: 'loop' | 'recursion' | 'allocation' | 'io' | 'string_ops'; line: number; column: number; severity: 'low' | 'medium' | 'high' | 'critical'; description: string; suggestion: string; estimatedImpact: string; } export interface OptimizationSuggestion { type: string; description: string; benefit: string; effort: 'low' | 'medium' | 'high'; locations: number[]; } export interface MemoryIssue { type: 'leak' | 'double_free' | 'use_after_free' | 'buffer_overflow' | 'uninitialized'; line: number; column: number; severity: 'low' | 'medium' | 'high' | 'critical'; description: string; fix: string; } export interface SmartPointerAnalysis { uniquePtr: number; sharedPtr: number; weakPtr: number; rawPointers: number; recommendations: string[]; } export interface RaiiAnalysis { score: number; violations: RaiiViolation[]; recommendations: string[]; } export interface RaiiViolation { line: number; type: string; description: string; fix: string; } export interface SecurityVulnerability { type: string; line: number; column: number; severity: 'low' | 'medium' | 'high' | 'critical'; description: string; cwe?: string; fix: string; } export interface CudaKernel { name: string; line: number; gridDim: string; blockDim: string; sharedMemory?: number; parameters: FunctionParameter[]; optimizations: string[]; } export interface CudaMemoryTransfer { type: 'host_to_device' | 'device_to_host' | 'device_to_device'; line: number; size: string; isAsync: boolean; stream?: string; } export interface CudaOptimization { type: string; description: string; benefit: string; locations: number[]; } /** * Enhanced C++ Analyzer using Tree-sitter */ export declare class EnhancedCppAnalyzer { private parser; private fileSystemManager; constructor(); /** * Perform comprehensive C++ analysis */ analyzeFile(filePath: string, options?: { cppStandard?: string; includeCuda?: boolean; includePerformance?: boolean; includeMemory?: boolean; includeSecurity?: boolean; }): Promise<EnhancedCppAnalysisResult>; /** * Analyze code metrics using AST */ private analyzeMetrics; /** * Calculate complexity metrics from AST */ private calculateComplexity; /** * Calculate cyclomatic complexity from AST */ private calculateCyclomaticComplexity; /** * Calculate cognitive complexity */ private calculateCognitiveComplexity; /** * Calculate Halstead metrics */ private calculateHalsteadMetrics; /** * Calculate maintainability index */ private calculateMaintainabilityIndex; /** * Detect CUDA code in content */ private detectCudaCode; private analyzeStructure; private analyzeDependencies; private analyzeModernCpp; private analyzePerformance; private analyzeMemory; private analyzeSecurity; private analyzeCuda; private extractNamespace; private extractClass; private extractFunction; private extractVariable; private extractEnum; private extractTemplate; private extractMacro; } //# sourceMappingURL=EnhancedCppAnalyzer.d.ts.map