本文整理汇总了Golang中github.com/quarnster/completion/content.Field.Type方法的典型用法代码示例。如果您正苦于以下问题:Golang Field.Type方法的具体用法?Golang Field.Type怎么用?Golang Field.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quarnster/completion/content.Field
的用法示例。
在下文中一共展示了Field.Type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: complete_pkg
func (g *Go) complete_pkg(pkg string, cmp *content.CompletionResult) error {
if g.imports == nil {
g.imports = make(map[string]*types.Package)
}
if p, err := types.GcImport(g.imports, pkg); err != nil {
return err
} else {
nn := p.Scope()
for i := 0; i < nn.NumEntries(); i++ {
t := nn.At(i)
var flags content.Flags
if n := t.Name(); n[0] != strings.ToUpper(n)[0] {
flags = content.FLAG_ACC_PROTECTED
} else {
flags = content.FLAG_ACC_PUBLIC
}
switch t.(type) {
case *types.Func:
var m content.Method
m.Flags |= flags
m.Name.Relative = t.Name()
sig := t.Type().Underlying().(*types.Signature)
if sig.Recv() != nil {
continue
}
par := sig.Params()
for j := 0; j < par.Len(); j++ {
m.Parameters = append(m.Parameters, g.pkg_var(par.At(j)))
}
ret := sig.Results()
for j := 0; j < ret.Len(); j++ {
m.Returns = append(m.Returns, g.pkg_var(ret.At(j)))
}
cmp.Methods = append(cmp.Methods, m)
case *types.TypeName:
var t2 content.Type
t2.Flags |= flags
t2.Name.Relative = t.Name()
switch t.Type().Underlying().(type) {
case *types.Interface:
t2.Flags |= content.FLAG_TYPE_INTERFACE
case *types.Struct:
t2.Flags |= content.FLAG_TYPE_STRUCT
}
cmp.Types = append(cmp.Types, t2)
case *types.Const, *types.Var:
var f content.Field
f.Name.Relative = t.Name()
f.Type = g.pkg_type(t.Type())
cmp.Fields = append(cmp.Fields, f)
default:
log4go.Warn("Unimplemented type in package completion: at: %+v, %v, %v", t, reflect.TypeOf(t), reflect.TypeOf(t.Type().Underlying()))
}
}
}
return nil
}
示例2: Fields
func (td *TypeDef) Fields() (fields []content.Field, err error) {
if td.ct.Name.Relative != "" {
return td.ct.Fields, nil
}
var (
mu = td.index.(*ConcreteTableIndex).metadataUtil
startRow, endRow = td.ListRange(td.index.Index(), id_TypeDef, id_Field, func(i interface{}) uint32 { return i.(*TypeDefRow).FieldList.Index() })
idx = ConcreteTableIndex{mu, startRow, id_Field}
)
cn := stripProto(td.Name().Absolute)
for i := startRow; i < endRow; i++ {
idx.index = i
if rawfield, err := idx.Data(); err != nil {
return nil, err
} else {
var (
field = rawfield.(*FieldRow)
f content.Field
dec *SignatureDecoder
sig FieldSig
)
f.Name.Relative = string(field.Name)
f.Name.Absolute = fmt.Sprintf("net://field/%s;%d", cn, i-startRow)
if dec, err = NewSignatureDecoder(field.Signature); err != nil {
return nil, err
} else if err = dec.Decode(&sig); err != nil {
return nil, err
} else {
f.Type = td.initContentType(td.index, &sig.Type)
}
if field.Flags&FieldAttributes_Static != 0 {
f.Flags |= content.FLAG_STATIC
}
if field.Flags&FieldAttributes_Public != 0 {
f.Flags |= content.FLAG_ACC_PUBLIC
} else if field.Flags&FieldAttributes_Private != 0 {
f.Flags |= content.FLAG_ACC_PRIVATE
} else if field.Flags&FieldAttributes_Family != 0 {
f.Flags |= content.FLAG_ACC_PROTECTED
}
if err := check(&f, f.Name); err != nil {
log4go.Fine("Skipping field: %s, %+v, %+v", err, f, field)
continue
}
fields = append(fields, f)
}
}
return fields, nil
}
示例3: toContentField
func (d *DWARFHelper) toContentField(e *dwarf.Entry) (content.Field, error) {
var f content.Field
if v, ok := e.Val(dwarf.AttrName).(string); ok {
f.Name.Relative = v
}
if v, ok := e.Val(dwarf.AttrType).(dwarf.Offset); ok {
if t, err := d.GetType(v); err != nil {
return f, err
} else {
f.Type = t
}
}
f.Flags = d.Flags(e)
return f, nil
}