本文整理匯總了Golang中kythe/io/kythe/proto/serving_proto.FileDecorations.File方法的典型用法代碼示例。如果您正苦於以下問題:Golang FileDecorations.File方法的具體用法?Golang FileDecorations.File怎麽用?Golang FileDecorations.File使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kythe/io/kythe/proto/serving_proto.FileDecorations
的用法示例。
在下文中一共展示了FileDecorations.File方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: writeDecorAndRefs
func writeDecorAndRefs(ctx context.Context, opts *Options, edges <-chan *srvpb.Edge, out *servingOutput) error {
fragments, err := opts.diskSorter(fragmentLesser{}, fragmentMarshaler{})
if err != nil {
return err
}
log.Println("Writing decoration fragments")
if err := createDecorationFragments(ctx, edges, fragments); err != nil {
return err
}
log.Println("Writing completed FileDecorations")
// refSorter stores a *srvpb.CrossReference for each Decoration from fragments
refSorter, err := opts.diskSorter(refLesser{}, refMarshaler{})
if err != nil {
return fmt.Errorf("error creating sorter: %v", err)
}
buffer := out.xs.Buffered()
var (
curFile string
file *srvpb.File
norm *xrefs.Normalizer
decor *srvpb.FileDecorations
)
if err := fragments.Read(func(x interface{}) error {
df := x.(*decorationFragment)
fileTicket := df.fileTicket
fragment := df.decoration
if decor != nil && curFile != fileTicket {
if decor.File != nil {
if err := writeDecor(ctx, buffer, decor); err != nil {
return err
}
file = nil
}
decor = nil
}
curFile = fileTicket
if decor == nil {
decor = &srvpb.FileDecorations{}
}
if fragment.File == nil {
decor.Decoration = append(decor.Decoration, fragment.Decoration...)
if file == nil {
return errors.New("missing file for anchors")
}
// Reverse each fragment.Decoration to create a *srvpb.CrossReference
for _, d := range fragment.Decoration {
cr, err := assemble.CrossReference(file, norm, d)
if err != nil {
return fmt.Errorf("error assembling cross-reference: %v", err)
}
if err := refSorter.Add(cr); err != nil {
return fmt.Errorf("error adding CrossReference to sorter: %v", err)
}
}
} else {
decor.File = fragment.File
file = fragment.File
norm = xrefs.NewNormalizer(file.Text)
}
return nil
}); err != nil {
return fmt.Errorf("error reading decoration fragments: %v", err)
}
if decor != nil && decor.File != nil {
if err := writeDecor(ctx, buffer, decor); err != nil {
return err
}
}
log.Println("Writing CrossReferences")
xb := &assemble.CrossReferencesBuilder{
MaxPageSize: opts.MaxPageSize,
Output: func(ctx context.Context, s *srvpb.PagedCrossReferences) error {
return buffer.Put(ctx, xsrv.CrossReferencesKey(s.SourceTicket), s)
},
OutputPage: func(ctx context.Context, p *srvpb.PagedCrossReferences_Page) error {
return buffer.Put(ctx, xsrv.CrossReferencesPageKey(p.PageKey), p)
},
}
var curTicket string
if err := refSorter.Read(func(i interface{}) error {
cr := i.(*srvpb.CrossReference)
if curTicket != cr.Referent.Ticket {
curTicket = cr.Referent.Ticket
if err := xb.StartSet(ctx, curTicket); err != nil {
return fmt.Errorf("error starting cross-references set: %v", err)
}
}
//.........這裏部分代碼省略.........