@@ -346,6 +346,29 @@ func (a *Analyzer) buildSignature(fn *ast.FuncDecl) string {
346346 }
347347 parts = append (parts , fmt .Sprintf ("(%s)" , strings .Join (params , ", " )))
348348
349+ // Return values
350+ if fn .Type .Results != nil && len (fn .Type .Results .List ) > 0 {
351+ var results []string
352+ for _ , field := range fn .Type .Results .List {
353+ resultType := a .formatType (field .Type )
354+ if len (field .Names ) > 0 {
355+ for _ , name := range field .Names {
356+ results = append (results , fmt .Sprintf ("%s %s" , name .Name , resultType ))
357+ }
358+ } else {
359+ results = append (results , resultType )
360+ }
361+ }
362+
363+ if len (results ) == 1 && ! strings .Contains (results [0 ], " " ) {
364+ // Single unnamed return value
365+ parts = append (parts , results [0 ])
366+ } else {
367+ // Multiple return values or named return values
368+ parts = append (parts , fmt .Sprintf ("(%s)" , strings .Join (results , ", " )))
369+ }
370+ }
371+
349372 return strings .Join (parts , " " )
350373}
351374
@@ -392,13 +415,27 @@ func (a *Analyzer) processCallExpr(call *ast.CallExpr, caller *Function, localFu
392415 targetName := fun .Name
393416
394417 // First check local functions in same file
418+ found := false
395419 for _ , fn := range localFuncs {
396420 if fn .Name == targetName && fn .Receiver == "" {
397421 a .addCallSite (caller , fn )
422+ found = true
398423 break
399424 }
400425 }
401426
427+ // If not found locally, search globally
428+ if ! found {
429+ a .functions .Range (func (key , value interface {}) bool {
430+ fn := value .(* Function )
431+ if fn .Name == targetName && fn .Receiver == "" {
432+ a .addCallSite (caller , fn )
433+ return false // Stop searching after first match
434+ }
435+ return true
436+ })
437+ }
438+
402439 case * ast.SelectorExpr :
403440 // Method call: receiver.method()
404441 methodName := fun .Sel .Name
0 commit comments