MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / writeObject

Function writeObject

types/object.go:450–546  ·  view source on GitHub ↗
(buf *bytes.Buffer, obj Object, qf Qualifier)

Source from the content-addressed store, hash-verified

448}
449
450func writeObject(buf *bytes.Buffer, obj Object, qf Qualifier) {
451 var tname *TypeName
452 typ := obj.Type()
453
454 switch obj := obj.(type) {
455 case *PkgName:
456 fmt.Fprintf(buf, "package %s", obj.Name())
457 if path := obj.imported.path; path != "" && path != obj.name {
458 fmt.Fprintf(buf, " (%q)", path)
459 }
460 return
461
462 case *Const:
463 buf.WriteString("const")
464
465 case *TypeName:
466 tname = obj
467 buf.WriteString("type")
468 if isTypeParam(typ) {
469 buf.WriteString(" parameter")
470 }
471
472 case *Var:
473 if obj.isField {
474 buf.WriteString("field")
475 } else {
476 buf.WriteString("var")
477 }
478
479 case *Func:
480 buf.WriteString("func ")
481 writeFuncName(buf, obj, qf)
482 if typ != nil {
483 WriteSignature(buf, typ.(*Signature), qf)
484 }
485 return
486
487 case *Label:
488 buf.WriteString("label")
489 typ = nil
490
491 case *Builtin:
492 buf.WriteString("builtin")
493 typ = nil
494
495 case *Nil:
496 buf.WriteString("nil")
497 return
498
499 default:
500 panic(fmt.Sprintf("writeObject(%T)", obj))
501 }
502
503 buf.WriteByte(' ')
504
505 // For package-level objects, qualify the name.
506 if obj.Pkg() != nil && obj.Pkg().scope.Lookup(obj.Name()) == obj {
507 writePackage(buf, obj.Pkg(), qf)

Callers 1

ObjectStringFunction · 0.85

Calls 15

IsAliasMethod · 0.95
isTypeParamFunction · 0.85
writeFuncNameFunction · 0.85
WriteSignatureFunction · 0.85
writePackageFunction · 0.85
newTypeWriterFunction · 0.85
underFunction · 0.85
IdenticalFunction · 0.85
WriteTypeFunction · 0.85
tParamListMethod · 0.80
assertFunction · 0.70
TypeMethod · 0.65

Tested by

no test coverage detected