本文整理汇总了Golang中github.com/quarnster/completion/net/csharp.CSHARP.Code方法的典型用法代码示例。如果您正苦于以下问题:Golang CSHARP.Code方法的具体用法?Golang CSHARP.Code怎么用?Golang CSHARP.Code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quarnster/completion/net/csharp.CSHARP
的用法示例。
在下文中一共展示了CSHARP.Code方法的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
}
off := args.Location.Offset()
off_ := int(off)
contents := args.Location.File.Contents
var up csharp.CSHARP
up.SetData(contents)
if !up.UsingDirectives() {
return up.Error()
}
using := up.RootNode()
var code csharp.CSHARP
code.SetData(contents)
code.Code()
code.Namespace()
namespace := ""
for _, ns := range code.RootNode().Children {
if ns.Name == "Namespace" && ns.Range.A <= off_ && off_ < ns.Range.B {
namespace = ns.Children[0].Data()
break
}
}
if len(namespace) == 0 {
log4go.Debug("Couldn't find namespace")
}
var p csharp.CSHARP
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 {
if node.Name != "CompleteOp" {
return fmt.Errorf("Don't know how to complete %s", node)
}
n := len(node.Children)
if n < 2 {
return fmt.Errorf("Not enough children in Op node: %d < 2: %s", n, node)
}
if op := node.Children[1].Data(); op != "." {
if n < 3 {
return fmt.Errorf("Not enough children in Op node: %d < 3: %s", n, node)
}
td = nil
return complete(node.Children[2])
}
if td == nil {
tn := ns + node.Children[0].Data()
if td = findtype(cache, namespace, 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])
data := scopes.Substr(args.Location.File.Contents, scopes.Visibility(args.Location))
loc := content.File{Contents: data}
re, err := regexp.Compile(fmt.Sprintf(`[=\(,;}\s](\w+(\s*\[\])*\s+)*%s[;\s=,)\[]`, v))
if err != nil {
return err
}
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() {
continue
}
t := c.variable(p.RootNode())
if t == "" {
continue
}
if td = findtype(cache, namespace, using, t); td != nil {
//.........这里部分代码省略.........