nodeServiceMethod returns the name of the service method represented by fn, or "" if fn is not a service method. Name is in the form of "Receiver.Function", for example "IssuesService.Create".
(fn *ast.FuncDecl)
| 512 | // nodeServiceMethod returns the name of the service method represented by fn, or "" if fn is not a service method. |
| 513 | // Name is in the form of "Receiver.Function", for example "IssuesService.Create". |
| 514 | func nodeServiceMethod(fn *ast.FuncDecl) string { |
| 515 | if fn.Recv == nil || len(fn.Recv.List) != 1 { |
| 516 | return "" |
| 517 | } |
| 518 | recv := fn.Recv.List[0] |
| 519 | se, ok := recv.Type.(*ast.StarExpr) |
| 520 | if !ok { |
| 521 | return "" |
| 522 | } |
| 523 | id, ok := se.X.(*ast.Ident) |
| 524 | if !ok { |
| 525 | return "" |
| 526 | } |
| 527 | |
| 528 | // We only want exported methods on exported types where the type name ends in "Service". |
| 529 | if !id.IsExported() || !fn.Name.IsExported() || !strings.HasSuffix(id.Name, "Service") { |
| 530 | return "" |
| 531 | } |
| 532 | |
| 533 | // Skip generated Iterator methods. |
| 534 | if strings.HasSuffix(fn.Name.Name, "Iter") { |
| 535 | return "" |
| 536 | } |
| 537 | |
| 538 | serviceMethod := id.Name + "." + fn.Name.Name |
| 539 | if skipServiceMethod[serviceMethod] { |
| 540 | return "" |
| 541 | } |
| 542 | |
| 543 | return serviceMethod |
| 544 | } |
| 545 | |
| 546 | // See: https://github.com/google/go-github/issues/3894 |
| 547 | var skipServiceMethod = map[string]bool{ |
no outgoing calls
no test coverage detected
searching dependent graphs…