@@ -478,18 +478,21 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
478478 }
479479 }
480480
481- // cpp get method name without class name
481+ // cpp get method name without class name and namespace
482482 if c .Language == uniast .Cpp && rid != nil {
483- rec := strings .TrimSpace (rid .Name )
484- if rec != "" {
485- searchStr := rec + "::"
486- if idx := strings .Index (name , searchStr ); idx >= 0 {
487- name = name [idx + len (searchStr ):]
488- }
483+ p := strings .IndexByte (name , '(' )
484+ head , tail := name , ""
485+ if p >= 0 {
486+ head , tail = name [:p ], name [p :]
489487 }
488+
489+ if idx := strings .LastIndex (head , "::" ); idx >= 0 {
490+ head = head [idx + 2 :]
491+ }
492+ name = head + tail
490493 }
491494
492- if k == SKFunction {
495+ if k == SKFunction || c . Language == uniast . Cpp {
493496 // NOTICE: class static method name is: type::method
494497 id .Name += "::" + name
495498 } else {
@@ -583,7 +586,17 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
583586 continue
584587 }
585588 // NOTICE: use method name as key here
586- obj .Methods [method .Name ] = * mid
589+ if c .Language == uniast .Cpp {
590+ methodName := c .cppBaseName (method .Name )
591+ _ , methodExist := obj .Methods [methodName ]
592+ isHeaderMethod := strings .HasSuffix (method .Location .URI .File (), ".h" )
593+ if methodExist && isHeaderMethod {
594+ continue
595+ }
596+ obj .Methods [methodName ] = * mid
597+ } else {
598+ obj .Methods [method .Name ] = * mid
599+ }
587600 }
588601 }
589602 obj .Identity = * id
0 commit comments