@@ -84,7 +84,12 @@ func RunWithCache(ctx context.Context, root string, cfg config.Config, progress
8484 }
8585 progress (Progress {Stage : stage , Path : unit .files [0 ].Path , Completed : completed , Total : len (scanResult .Files )})
8686 }
87- analysis , err := analyzeWithCache (ctx , cache , analyzerIdentity (language , cfg ), unit .name , analyzer , scanResult .Root , unit .files , status )
87+ fileProgress := func (path string , unitCompleted int ) {
88+ if progress != nil {
89+ progress (Progress {Stage : "Analyzing " + language , Path : path , Completed : completed + unitCompleted , Total : len (scanResult .Files )})
90+ }
91+ }
92+ analysis , err := analyzeWithCache (ctx , cache , analyzerIdentity (language , cfg ), unit .name , analyzer , scanResult .Root , unit .files , status , fileProgress )
8893 if err != nil {
8994 return Result {}, err
9095 }
@@ -141,7 +146,7 @@ func boolString(value bool) string {
141146 return "false"
142147}
143148
144- func analyzeWithCache (ctx context.Context , cache * analysisCache , identity , unit string , analyzer lang.Analyzer , root string , files []scan.File , status func (cached bool )) (* lang.AnalysisResult , error ) {
149+ func analyzeWithCache (ctx context.Context , cache * analysisCache , identity , unit string , analyzer lang.Analyzer , root string , files []scan.File , status func (cached bool ), fileProgress func ( path string , completed int ) ) (* lang.AnalysisResult , error ) {
145150 if err := ctx .Err (); err != nil {
146151 return nil , err
147152 }
@@ -155,7 +160,7 @@ func analyzeWithCache(ctx context.Context, cache *analysisCache, identity, unit
155160 return result , nil
156161 }
157162 status (false )
158- result , err := analyzer . Analyze (ctx , root , files )
163+ result , err := analyze (ctx , analyzer , root , files , fileProgress )
159164 if err != nil {
160165 return nil , err
161166 }
@@ -165,10 +170,17 @@ func analyzeWithCache(ctx context.Context, cache *analysisCache, identity, unit
165170 return result , nil
166171 }
167172 status (false )
168- result , err := analyzer . Analyze (ctx , root , files )
173+ result , err := analyze (ctx , analyzer , root , files , fileProgress )
169174 return result , err
170175}
171176
177+ func analyze (ctx context.Context , analyzer lang.Analyzer , root string , files []scan.File , progress func (path string , completed int )) (* lang.AnalysisResult , error ) {
178+ if progressive , ok := analyzer .(lang.ProgressAnalyzer ); ok {
179+ return progressive .AnalyzeWithProgress (ctx , root , files , progress )
180+ }
181+ return analyzer .Analyze (ctx , root , files )
182+ }
183+
172184func addFileTopology (builder * graph.Builder , scanResult scan.Result ) {
173185 builder .AddNode (graph.Node {ID : graph .DirID ("." ), Kind : graph .NodeDir , Name : "." , Path : "." , Meta : topologyMeta ("." )})
174186 builder .AddEdge (graph.Edge {Kind : graph .EdgeContains , From : graph .RepoID (), To : graph .DirID ("." ), Meta : topologyMeta ("." )})
0 commit comments