|
| 1 | +# NanoAPI C Plugin |
| 2 | + |
| 3 | +This plugin manages parsing and mapping of dependencies in C projects. |
| 4 | + |
| 5 | +**Warning :** This plugin relies on tree-sitter, which has an unreliable parser |
| 6 | +for C. Not every C project is entirely compatible. Warnings may be issued where |
| 7 | +tree-sitter finds errors. |
| 8 | + |
| 9 | +## Class diagram |
| 10 | + |
| 11 | +```mermaid |
| 12 | +classDiagram |
| 13 | + class CMetricsAnalyzer { |
| 14 | + +analyzeNode(node: Parser.SyntaxNode): CComplexityMetrics |
| 15 | + } |
| 16 | +
|
| 17 | + class CExtractor { |
| 18 | + -manifest: DependencyManifest |
| 19 | + -registry: Map<string, CFile> |
| 20 | + -includeResolver: CIncludeResolver |
| 21 | + +extractSymbols(symbolsMap: Map<string, SymbolsToExtract>): Map<string, File> |
| 22 | + } |
| 23 | +
|
| 24 | + class CSymbolRegistry { |
| 25 | + -headerResolver: CHeaderResolver |
| 26 | + -files: Map<string, File> |
| 27 | + +getRegistry(): Map<string, CFile> |
| 28 | + } |
| 29 | +
|
| 30 | + class CHeaderResolver { |
| 31 | + +resolveSymbols(file: File): ExportedSymbol[] |
| 32 | + } |
| 33 | +
|
| 34 | + class CIncludeResolver { |
| 35 | + -symbolRegistry: Map<string, CFile> |
| 36 | + -files: Map<string, File> |
| 37 | + +getInclusions(): Map<string, Inclusions> |
| 38 | + } |
| 39 | +
|
| 40 | + class CInvocationResolver { |
| 41 | + -includeResolver: CIncludeResolver |
| 42 | + +getInvocationsForSymbol(symbol: Symbol): Invocations |
| 43 | + +getInvocationsForFile(filepath: string): Invocations |
| 44 | + } |
| 45 | +
|
| 46 | + class CDependencyFormatter { |
| 47 | + -symbolRegistry: CSymbolRegistry |
| 48 | + -includeResolver: CIncludeResolver |
| 49 | + -invocationResolver: CInvocationResolver |
| 50 | + +formatFile(filepath: string): CDepFile |
| 51 | + } |
| 52 | +
|
| 53 | + class Symbol { |
| 54 | + <<abstract>> |
| 55 | + -name: string |
| 56 | + -declaration: ExportedSymbol |
| 57 | + } |
| 58 | +
|
| 59 | + class FunctionSignature { |
| 60 | + -definition: FunctionDefinition |
| 61 | + -isMacro: boolean |
| 62 | + } |
| 63 | +
|
| 64 | + class FunctionDefinition { |
| 65 | + -signature: FunctionSignature |
| 66 | + -isMacro: boolean |
| 67 | + } |
| 68 | +
|
| 69 | + class DataType { |
| 70 | + -typedefs: Map<string, Typedef> |
| 71 | + } |
| 72 | +
|
| 73 | + class Typedef { |
| 74 | + -datatype: DataType |
| 75 | + } |
| 76 | +
|
| 77 | + class Variable { |
| 78 | + -isMacro: boolean |
| 79 | + } |
| 80 | +
|
| 81 | + class CFile { |
| 82 | + -file: File |
| 83 | + -symbols: Map<string, Symbol> |
| 84 | + -type: CFileType |
| 85 | + } |
| 86 | +
|
| 87 | + class ExportedSymbol { |
| 88 | + -name: string |
| 89 | + -type: SymbolType |
| 90 | + -specifiers: StorageClassSpecifier[] |
| 91 | + -qualifiers: TypeQualifier[] |
| 92 | + -node: Parser.SyntaxNode |
| 93 | + -identifierNode: Parser.SyntaxNode |
| 94 | + -filepath: string |
| 95 | + } |
| 96 | +
|
| 97 | + class Inclusions { |
| 98 | + -filepath: string |
| 99 | + -symbols: Map<string, Symbol> |
| 100 | + -internal: string[] |
| 101 | + -standard: Map<string, Parser.SyntaxNode> |
| 102 | + } |
| 103 | +
|
| 104 | + class Invocations { |
| 105 | + -resolved: Map<string, Symbol> |
| 106 | + -unresolved: Set<string> |
| 107 | + } |
| 108 | +
|
| 109 | + class CDependency { |
| 110 | + -id: string |
| 111 | + -isExternal: boolean |
| 112 | + -symbols: Record<string, string> |
| 113 | + } |
| 114 | +
|
| 115 | + class CDepFile { |
| 116 | + -id: string |
| 117 | + -filePath: string |
| 118 | + -rootNode: Parser.SyntaxNode |
| 119 | + -lineCount: number |
| 120 | + -characterCount: number |
| 121 | + -dependencies: Record<string, CDependency> |
| 122 | + -symbols: Record<string, CDepSymbol> |
| 123 | + } |
| 124 | +
|
| 125 | + class CDepSymbol { |
| 126 | + -id: string |
| 127 | + -type: CDepSymbolType |
| 128 | + -lineCount: number |
| 129 | + -characterCount: number |
| 130 | + -node: Parser.SyntaxNode |
| 131 | + -dependents: Record<string, CDependent> |
| 132 | + -dependencies: Record<string, CDependency> |
| 133 | + } |
| 134 | +
|
| 135 | + class CComplexityMetrics { |
| 136 | + -cyclomaticComplexity: number |
| 137 | + -codeLinesCount: number |
| 138 | + -linesCount: number |
| 139 | + -codeCharacterCount: number |
| 140 | + -characterCount: number |
| 141 | + } |
| 142 | +
|
| 143 | + class CodeCounts { |
| 144 | + -lines: number |
| 145 | + -characters: number |
| 146 | + } |
| 147 | +
|
| 148 | + class CommentSpan { |
| 149 | + -start: Point |
| 150 | + -end: Point |
| 151 | + } |
| 152 | +
|
| 153 | + %% Relationships |
| 154 | + Symbol <|-- FunctionSignature |
| 155 | + Symbol <|-- FunctionDefinition |
| 156 | + Symbol <|-- DataType |
| 157 | + Symbol <|-- Typedef |
| 158 | + Symbol <|-- Variable |
| 159 | + CSymbolRegistry --> CFile |
| 160 | + CSymbolRegistry --> CHeaderResolver |
| 161 | + CIncludeResolver --> CSymbolRegistry |
| 162 | + CInvocationResolver --> CIncludeResolver |
| 163 | + CDependencyFormatter --> CSymbolRegistry |
| 164 | + CDependencyFormatter --> CIncludeResolver |
| 165 | + CDependencyFormatter --> CInvocationResolver |
| 166 | + CExtractor --> CSymbolRegistry |
| 167 | + CExtractor --> CIncludeResolver |
| 168 | + CExtractor --> CFile |
| 169 | + CFile --> Symbol |
| 170 | + Typedef --> DataType |
| 171 | + DataType --> Typedef |
| 172 | + Invocations --> Symbol |
| 173 | + Inclusions --> Symbol |
| 174 | + CDepFile --> CDependency |
| 175 | + CDepFile --> CDepSymbol |
| 176 | + CDepSymbol --> CDependent |
| 177 | + CDepSymbol --> CDependency |
| 178 | + CMetricsAnalyzer --> CComplexityMetrics |
| 179 | + CMetricsAnalyzer --> CodeCounts |
| 180 | + CMetricsAnalyzer --> CommentSpan |
| 181 | +``` |
0 commit comments