本文整理汇总了Golang中github.com/quarnster/completion/net/csharp.CSHARP.CompleteVariable方法的典型用法代码示例。如果您正苦于以下问题:Golang CSHARP.CompleteVariable方法的具体用法?Golang CSHARP.CompleteVariable怎么用?Golang CSHARP.CompleteVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quarnster/completion/net/csharp.CSHARP
的用法示例。
在下文中一共展示了CSHARP.CompleteVariable方法的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)
}
//.........这里部分代码省略.........