當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CompletionResult.Types方法代碼示例

本文整理匯總了Golang中github.com/quarnster/completion/content.CompletionResult.Types方法的典型用法代碼示例。如果您正苦於以下問題:Golang CompletionResult.Types方法的具體用法?Golang CompletionResult.Types怎麽用?Golang CompletionResult.Types使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/quarnster/completion/content.CompletionResult的用法示例。


在下文中一共展示了CompletionResult.Types方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Load

func (d *DWARFHelper) Load() (content.CompletionResult, error) {
    var cmp content.CompletionResult
    r := d.df.Reader()
    for {
        if e, err := r.Next(); err != nil {
            return cmp, err
            break
        } else if e == nil {
            break
        } else {
            switch e.Tag {
            case dwarf.TagMember:
                if f, err := d.toContentField(e); err != nil {
                    return cmp, err
                } else {
                    cmp.Fields = append(cmp.Fields, f)
                }
            case dwarf.TagSubprogram:
                if m, err := d.toContentMethod(e); err != nil {
                    return cmp, err
                } else {
                    cmp.Methods = append(cmp.Methods, m)
                }
            case dwarf.TagClassType, dwarf.TagTypedef, dwarf.TagStructType:
                if t, err := d.GetType(e.Offset); err != nil {
                    return cmp, err
                } else {
                    cmp.Types = append(cmp.Types, t)
                }
            }
        }
    }
    return cmp, nil
}
開發者ID:berkus,項目名稱:completion,代碼行數:34,代碼來源:dwarf.go

示例2: 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
}
開發者ID:NeoTse,項目名稱:completion,代碼行數:60,代碼來源:complete.go

示例3: Complete

func (c *Java) Complete(args *content.CompleteArgs, cmp *content.CompletionResult) error {
    log4go.Fine("%+v", args)
    var archive Archive
    session := args.Session()
    if session != nil {
        if a, ok := session.Get("java_archive").(Archive); ok {
            archive = a
        }
    }
    if archive == nil {
        cp, err := DefaultClasspath()
        if err != nil {
            // We don't really care about not being able to get the default classpath as it could be provided manually by the user
            log4go.Warn("Couldn't get the default classpath: %s", err)
        }
        settings := args.Settings()
        if cp2, ok := settings.Get("java_classpath").([]string); ok {
            // TODO: do we ever want to override rather than append to the classpath?
            cp = append(cp, cp2...)
        }
        log4go.Fine("classpath: %+v", cp)
        if archive, err = NewCompositeArchive(cp); err != nil {
            return err
        } else if session != nil {
            session.Set("java_archive", archive)
        }
    }

    className, err := fqnToClassname(args.Location)
    if err != nil {
        return err
    }

    data, err := archive.LoadClass(className)
    if err != nil {
        return err
    }

    class, err := NewClass(bytes.NewReader(data))
    if err != nil {
        return err
    }

    ct, err := class.ToContentType()
    if err != nil {
        return err
    }

    // TODO(q): Inherited fields and methods?
    // 			I see value in being able to "just" get the smaller set,
    //			but getting the full set should definitely be possible "server side"
    cmp.Fields = ct.Fields
    cmp.Types = ct.Types
    cmp.Methods = ct.Methods

    return nil
}
開發者ID:NeoTse,項目名稱:completion,代碼行數:57,代碼來源:java.go

示例4: complete

func (c *Net) complete(cache *Cache, t *content.Type, cmp *content.CompletionResult) error {
    if ct, err := cache.Complete(t); err != nil {
        return err
    } else {
        cmp.Fields = ct.Fields
        cmp.Types = ct.Types
        cmp.Methods = ct.Methods
    }
    return nil
}
開發者ID:jerchung,項目名稱:completion,代碼行數:10,代碼來源:net.go

示例5: CompleteAt

func (t *Clang) CompleteAt(args *content.CompleteAtArgs, res *content.CompletionResult) error {
    origargs, _ := args.Settings().Get("compiler_flags").([]string)
    var unsaved map[string]string
    if args.Location.File.Contents != "" {
        unsaved = map[string]string{args.Location.File.Name: args.Location.File.Contents}
    }

    if tu := t.GetTranslationUnit(args.Location.File.Name, origargs, "", unsaved); tu == nil {
        return nil
    }
    cres := tu.CompleteAt(args.Location.File.Name, int(args.Location.Line), int(args.Location.Column), unsaved, 0)
    if !cres.IsValid() {
        return fmt.Errorf("CompleteResults is not valid")
    }
    defer cres.Dispose()
    for _, r := range cres.Results() {
        var (
            buf bytes.Buffer
        )
        switch r.CursorKind {
        case clang.CK_StructDecl, clang.CK_TypedefDecl:
            for _, c := range r.CompletionString.Chunks() {
                buf.WriteString(c.Text())
            }
            var tt content.Type
            tt.Flags = content.FLAG_TYPE_CLASS
            tt.Name.Absolute = buf.String()
            res.Types = append(res.Types, tt)
        case clang.CK_FunctionDecl:
            var (
                m            content.Method
                paramstarted bool
                argCount     int
            )
            for _, c := range r.CompletionString.Chunks() {
                switch k := c.Kind(); k {
                case clang.CompletionChunk_ResultType:
                    var v content.Variable
                    v.Name.Relative = c.Text()
                    m.Returns = append(m.Returns, v)
                case clang.CompletionChunk_Placeholder:
                    var v content.Variable
                    v.Type.Name.Relative = c.Text()
                    v.Name.Relative = fmt.Sprintf("arg%d", argCount)
                    argCount++
                    m.Parameters = append(m.Parameters, v)
                case clang.CompletionChunk_LeftParen:
                    paramstarted = true
                case clang.CompletionChunk_RightParen, clang.CompletionChunk_Comma:
                case clang.CompletionChunk_TypedText:
                    if !paramstarted {
                        buf.WriteString(c.Text())
                    }
                default:
                    log4go.Warn("Unimplemented CompletionChunkKind: %s", k)
                }
            }
            m.Name.Relative = buf.String()
            res.Methods = append(res.Methods, m)
        default:
            log4go.Warn("Unimplemented CursorKind: %s", r.CursorKind)
        }
    }
    return nil
}
開發者ID:NeoTse,項目名稱:completion,代碼行數:65,代碼來源:complete.go


注:本文中的github.com/quarnster/completion/content.CompletionResult.Types方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。