当前位置: 首页>>代码示例>>Golang>>正文


Golang csharp.CSHARP类代码示例

本文整理汇总了Golang中github.com/quarnster/completion/net/csharp.CSHARP的典型用法代码示例。如果您正苦于以下问题:Golang CSHARP类的具体用法?Golang CSHARP怎么用?Golang CSHARP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CSHARP类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: BenchmarkFindtype

func BenchmarkFindtype(b *testing.B) {
	var (
		n    Net
		args content.CompleteAtArgs
	)
	args.Location.File.Name = "./testdata/CompleteSharp.cs"
	args.Location.File.Load()
	args.Location.Line = 95
	args.Location.Column = 45
	cache, _ := n.cache(&args.Args)

	var up csharp.CSHARP
	up.SetData(args.Location.File.Contents)
	if !up.UsingDirectives() {
		b.Fatal(up.Error())
	}
	using := up.RootNode()

	for i := 0; i < b.N; i++ {
		findtype(cache, using, "string")
	}
}
开发者ID:ksurdy,项目名称:completion,代码行数:22,代码来源:net_test.go

示例2: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。