// Annotations . func Annotations(node ast.Node) (anns []*ast.Annotation) { val, ok := node.GetExtra(ExtraAnnotation) if ok { anns = val.([]*ast.Annotation) } return }
// Pos . func Pos(node ast.Node) (start lexer.Position, end lexer.Position) { val, ok := node.GetExtra(ExtraStartPos) if ok { start = val.(lexer.Position) } val, ok = node.GetExtra(ExtraEndPos) if ok { end = val.(lexer.Position) } return }
// FindAnnotations . func FindAnnotations(node ast.Node, name string) (retval []*ast.Annotation) { val, ok := node.GetExtra(ExtraAnnotation) if ok { anns := val.([]*ast.Annotation) for _, ann := range anns { if ann.Type.Ref == nil { continue } if ann.Type.Ref.FullName() == name { retval = append(retval, ann) } } } return }
// FindAnnotation . func FindAnnotation(node ast.Node, name string) (*ast.Annotation, bool) { val, ok := node.GetExtra(ExtraAnnotation) if ok { anns := val.([]*ast.Annotation) for _, ann := range anns { if ann.Type.Ref == nil { continue } if ann.Type.Ref.FullName() == name { return ann, true } } } return nil, false }