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


Golang CSHARP.Complete方法代碼示例

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


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

示例1: CompleteAt

func (c *Net) CompleteAt(args *content.CompleteAtArgs, cmp *content.CompletionResult) error {
    cache, err := c.cache(&args.Args)
    if err != nil {
        return err
    }
    if err := args.Location.File.Load(); err != nil {
        return err
    }
    contents := args.Location.File.Contents
    var up csharp.CSHARP
    up.SetData(contents)
    if !up.UsingDirectives() {
        return up.Error()
    }
    using := up.RootNode()

    var p csharp.CSHARP
    off := args.Location.Offset()
    line := args.Location.File.Line(off)
    line = line[:args.Location.Column-1]
    p.SetData(line)
    if !p.Complete() {
        return fmt.Errorf("%s, %s, %s", line, p.Error(), p.RootNode())
    }
    r := p.RootNode()
    r.Simplify()
    var td *TypeDef
    var complete func(node *parser.Node) error
    var ns string

    complete = func(node *parser.Node) error {
        switch n := node.Name; n {
        case "CompleteOp":
            n := len(node.Children)
            if n < 2 {
                return fmt.Errorf("Not enough children in Op node: %d < 2: %s", n, node)
            }
            switch op := node.Children[1].Data(); op {
            case ".":
                if td == nil {
                    tn := ns + node.Children[0].Data()
                    if td = findtype(cache, using, tn); td == nil {
                        ns = tn + "."
                    }
                } else if t2, err := typeresolve(td, node.Children[0]); err != nil {
                    return err
                } else if td, err = cache.FindType(t2.Name); err != nil {
                    return err
                } else if td == nil {
                    return fmt.Errorf("Couldn't find type: %s", node.Children[0])
                }
                if td == nil {
                    // Probably a variable completion then?
                    v := c.variable(node.Children[0])
                    loc := content.File{Contents: scopes.Substr(args.Location.File.Contents, scopes.Visibility(args.Location))}
                    if re, err := regexp.Compile(fmt.Sprintf(`[=\(,;}\s](\w+(\s*\[\])*\s+)*%s[;\s=,)\[]`, v)); err != nil {
                        return err
                    } else {
                        idx := re.FindAllStringIndex(loc.Contents, -1)
                        for _, i := range idx {
                            // TODO: It's better at getting the right variable, but still not 100% correct
                            line := loc.Contents[i[0]+1 : i[1]-1]
                            var p csharp.CSHARP
                            p.SetData(line)
                            if p.CompleteVariable() {
                                if t := c.variable(p.RootNode()); t != "" {
                                    if td = findtype(cache, using, t); td != nil {
                                        break
                                    } else {
                                        // Internal class perhaps?
                                        var p csharp.CSHARP
                                        if p.Parse(loc.Contents) {
                                            for _, t2 := range c.classes("", nil, p.RootNode()) {
                                                if !strings.HasSuffix(t2, t) {
                                                    continue
                                                }
                                                if td = findtype(cache, using, t2); td != nil {
                                                    break
                                                }
                                            }
                                        }
                                    }
                                    if td != nil {
                                        break
                                    }
                                }
                            }
                        }
                    }
                }
                if n > 2 {
                    return complete(node.Children[2])
                } else if td == nil {
                    return tdnil
                }
                return c.complete(cache, &content.Type{Name: td.Name()}, cmp)
            default:
                if n < 3 {
                    return fmt.Errorf("Not enough children in Op node: %d < 3: %s", n, node)
                }
//.........這裏部分代碼省略.........
開發者ID:jerchung,項目名稱:completion,代碼行數:101,代碼來源:net.go


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