extractStructName converts a chain of pre-parsed AST nodes representing field selections, such as "a.b.Msg", into a qualified struct type name.
(expr ast.Expr)
| 686 | // extractStructName converts a chain of pre-parsed AST nodes representing field selections, |
| 687 | // such as "a.b.Msg", into a qualified struct type name. |
| 688 | func (p *prattParserWorker) extractStructName(expr ast.Expr) (string, bool) { |
| 689 | var name string |
| 690 | for expr != nil && expr.Kind() == ast.SelectKind { |
| 691 | sel := expr.AsSelect() |
| 692 | if sel.IsTestOnly() { |
| 693 | return "", false |
| 694 | } |
| 695 | p.helper.deleteID(expr.ID()) |
| 696 | name = "." + sel.FieldName() + name |
| 697 | expr = sel.Operand() |
| 698 | } |
| 699 | if expr == nil || expr.Kind() != ast.IdentKind { |
| 700 | return "", false |
| 701 | } |
| 702 | p.helper.deleteID(expr.ID()) |
| 703 | return expr.AsIdent() + name, true |
| 704 | } |
| 705 | |
| 706 | func (p *prattParserWorker) parseStruct(objID int64, structName string) ast.Expr { |
| 707 | p.nextToken() // consumes { |
no test coverage detected