@@ -11,6 +11,7 @@ import {
1111 SymbolType ,
1212} from "@nanoapi.io/shared" ;
1313import { CDependencyFormatter } from "../../../languagePlugins/c/dependencyFormatting/index.js" ;
14+ import { CMetricsAnalyzer } from "../../../languagePlugins/c/metrics/index.js" ;
1415import Parser from "tree-sitter" ;
1516import { cLanguage , cParser } from "../../../helpers/treeSitter/parsers.js" ;
1617
@@ -36,6 +37,7 @@ export function generateCDependencyManifest(
3637 }
3738
3839 const formatter = new CDependencyFormatter ( parsedFiles ) ;
40+ const metricsAnalyzer = new CMetricsAnalyzer ( ) ;
3941 const manifest : DependencyManifest = { } ;
4042 const filecount = parsedFiles . size ;
4143 let i = 0 ;
@@ -46,39 +48,37 @@ export function generateCDependencyManifest(
4648 const symbols : Record < string , SymbolDependencyManifest > = { } ;
4749 for ( const [ symName , symbol ] of Object . entries ( cSyms ) ) {
4850 const symType = symbol . type ;
49- const lineCount = symbol . lineCount ;
50- const characterCount = symbol . characterCount ;
5151 const dependencies = symbol . dependencies ;
52- // TODO : metrics
52+ const metrics = metricsAnalyzer . analyzeNode ( symbol . node ) ;
5353 symbols [ symName ] = {
5454 id : symName ,
5555 type : symType as SymbolType ,
5656 metrics : {
57- [ metricCharacterCount ] : characterCount ,
58- [ metricCodeCharacterCount ] : 0 , // TODO: fix this
59- [ metricLinesCount ] : lineCount ,
60- [ metricCodeLineCount ] : 0 , // TODO: fix this
57+ [ metricCharacterCount ] : metrics . characterCount ,
58+ [ metricCodeCharacterCount ] : metrics . codeCharacterCount ,
59+ [ metricLinesCount ] : metrics . linesCount ,
60+ [ metricCodeLineCount ] : metrics . codeLinesCount ,
6161 [ metricDependencyCount ] : Object . keys ( dependencies ) . length ,
6262 [ metricDependentCount ] : 0 ,
63- [ metricCyclomaticComplexity ] : 0 , // TODO: fix this
63+ [ metricCyclomaticComplexity ] : metrics . cyclomaticComplexity ,
6464 } ,
6565 dependencies : dependencies ,
6666 dependents : { } ,
6767 } ;
6868 }
69- // TODO : metrics
69+ const metrics = metricsAnalyzer . analyzeNode ( fm . rootNode ) ;
7070 manifest [ path ] = {
7171 id : fm . id ,
7272 filePath : fm . filePath ,
7373 language : cLanguage ,
7474 metrics : {
75- [ metricCharacterCount ] : fm . characterCount ,
76- [ metricCodeCharacterCount ] : 0 , // TODO: fix this
77- [ metricLinesCount ] : fm . lineCount ,
78- [ metricCodeLineCount ] : 0 , // TODO: fix this
75+ [ metricCharacterCount ] : metrics . characterCount ,
76+ [ metricCodeCharacterCount ] : metrics . codeCharacterCount ,
77+ [ metricLinesCount ] : metrics . linesCount ,
78+ [ metricCodeLineCount ] : metrics . codeLinesCount ,
7979 [ metricDependencyCount ] : Object . keys ( fm . dependencies ) . length ,
8080 [ metricDependentCount ] : 0 ,
81- [ metricCyclomaticComplexity ] : 0 , // TODO: fix this
81+ [ metricCyclomaticComplexity ] : metrics . cyclomaticComplexity ,
8282 } ,
8383 dependencies : fm . dependencies ,
8484 symbols : symbols ,
0 commit comments