func (r *describeStmtResult) toSerial(res *serial.Result, fset *token.FileSet) { res.Describe = &serial.Describe{ Desc: r.description, Pos: fset.Position(r.node.Pos()).String(), Detail: "unknown", } }
func (r *describePackageResult) toSerial(res *serial.Result, fset *token.FileSet) { var members []*serial.DescribeMember for _, mem := range r.members { typ := mem.obj.Type() var val string switch mem := mem.obj.(type) { case *types.Const: val = mem.Val().String() case *types.TypeName: typ = typ.Underlying() } members = append(members, &serial.DescribeMember{ Name: mem.obj.Name(), Type: typ.String(), Value: val, Pos: fset.Position(mem.obj.Pos()).String(), Kind: tokenOf(mem.obj), Methods: methodsToSerial(r.pkg, mem.methods, fset), }) } res.Describe = &serial.Describe{ Desc: r.description, Pos: fset.Position(r.node.Pos()).String(), Detail: "package", Package: &serial.DescribePackage{ Path: r.pkg.Path(), Members: members, }, } }
func (r *describeValueResult) toSerial(res *serial.Result, fset *token.FileSet) { var value, objpos, ptaerr string if r.constVal != nil { value = r.constVal.String() } if r.obj != nil { objpos = fset.Position(r.obj.Pos()).String() } if r.ptaErr != nil { ptaerr = r.ptaErr.Error() } var pts []*serial.DescribePointer for _, ptr := range r.ptrs { var namePos string if nt, ok := deref(ptr.typ).(*types.Named); ok { namePos = fset.Position(nt.Obj().Pos()).String() } var labels []serial.DescribePTALabel for _, l := range ptr.labels { labels = append(labels, serial.DescribePTALabel{ Pos: fset.Position(l.Pos()).String(), Desc: l.String(), }) } pts = append(pts, &serial.DescribePointer{ Type: ptr.typ.String(), NamePos: namePos, Labels: labels, }) } res.Describe = &serial.Describe{ Desc: importer.NodeDescription(r.expr), Pos: fset.Position(r.expr.Pos()).String(), Detail: "value", Value: &serial.DescribeValue{ Type: r.typ.String(), Value: value, ObjPos: objpos, PTAErr: ptaerr, PTS: pts, }, } }
func (r *describeTypeResult) toSerial(res *serial.Result, fset *token.FileSet) { var namePos, nameDef string if nt, ok := r.typ.(*types.Named); ok { namePos = fset.Position(nt.Obj().Pos()).String() nameDef = nt.Underlying().String() } res.Describe = &serial.Describe{ Desc: r.description, Pos: fset.Position(r.node.Pos()).String(), Detail: "type", Type: &serial.DescribeType{ Type: r.qpos.TypeString(r.typ), NamePos: namePos, NameDef: nameDef, Methods: methodsToSerial(r.qpos.info.Pkg, r.methods, fset), }, } }
func (r *describeValueResult) toSerial(res *serial.Result, fset *token.FileSet) { var value, objpos string if r.constVal != nil { value = r.constVal.String() } if r.obj != nil { objpos = fset.Position(r.obj.Pos()).String() } res.Describe = &serial.Describe{ Desc: astutil.NodeDescription(r.expr), Pos: fset.Position(r.expr.Pos()).String(), Detail: "value", Value: &serial.DescribeValue{ Type: r.qpos.TypeString(r.typ), Value: value, ObjPos: objpos, }, } }
func (r *describeUnknownResult) toSerial(res *serial.Result, fset *token.FileSet) { res.Describe = &serial.Describe{ Desc: astutil.NodeDescription(r.node), Pos: fset.Position(r.node.Pos()).String(), } }