• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang content.CompleteAtArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CompleteAt

func (c *Clang) CompleteAt(a *content.CompleteAtArgs, ret *content.CompletionResult) error {
	origargs, _ := a.Settings().Get("compiler_flags").([]string)
	args := make([]string, len(origargs))
	for i := range origargs {
		args[i] = expand_path.ExpandPath(origargs[i])
	}
	fn := a.Location.File.Name

	if cnt := a.Location.File.Contents; cnt != "" {
		if f, err := ioutil.TempFile("", "completion_clang"); err != nil {
			return err
		} else {
			fn = f.Name()
			defer os.Remove(fn)
			fn += filepath.Ext(a.Location.File.Name)
			defer os.Remove(fn)
			if err := ioutil.WriteFile(fn, []byte(cnt), 0644); err != nil {
				return err
			}
		}
		args = append(args, "-I"+filepath.Dir(a.Location.File.Name))
	}

	args = append([]string{"-fsyntax-only", "-Xclang", fmt.Sprintf("-code-completion-at=%s:%d:%d", fn, a.Location.Line, a.Location.Column)}, args...)
	args = append(args, fn)
	if out, err := RunClang(args...); len(out) == 0 {
		return err
	} else if r, err := parseresult(string(out)); err != nil {
		return err
	} else {
		*ret = r
		return nil
	}
}
开发者ID:jerchung,项目名称:completion,代码行数:34,代码来源:clang.go


示例2: TestNet

func TestNet(t *testing.T) {
	paths := DefaultPaths()
	if len(paths) == 0 {
		t.Skip("Neither mono nor Windows .NET Framework paths were possible to get")
	}

	var (
		n    Net
		args content.CompleteAtArgs
		cmp  content.CompletionResult
	)

	tests := []struct {
		InFile       string
		Line, Column uint
	}{
		// TODO: this test is not platform independent as it depends on whatever framework you happen
		//       to have installed
		{"./testdata/CompleteSharp.cs", 40, 27},
		{"./testdata/CompleteSharp.cs", 40, 41},
		{"./testdata/CompleteSharp.cs", 47, 47},
		//{"./testdata/CompleteSharp.cs", 28, 14},
		{"./testdata/CompleteSharp.cs", 211, 46},
		{"./testdata/CompleteSharp.cs", 761, 83},
		{"./testdata/CompleteSharp.cs", 761, 27},
		{"./testdata/CompleteSharp.cs", 857, 29},
		{"./testdata/CompleteSharp.cs", 737, 15},
		{"./testdata/CompleteSharp.cs", 95, 38},
		{"./testdata/CompleteSharp.cs", 95, 45},
		{"./testdata/CompleteSharp.cs", 776, 39},
		{"./testdata/NamespaceTest.cs", 4, 15},
		{"./testdata/NamespaceTest.cs", 6, 15},
	}
	args.SessionId = "a"
	args.Settings().Set("net_paths", []string{"./testdata/"})
	args.Settings().Set("net_assemblies", []string{"CompleteSharp.exe"})
	for _, test := range tests {
		args.Location.File.Name = test.InFile
		args.Location.Line = test.Line
		args.Location.Column = test.Column
		ex := fmt.Sprintf("%s-%d-%d.cmp", test.InFile, test.Line, test.Column)
		if err := n.CompleteAt(&args, &cmp); err != nil {
			t.Errorf("Unable to complete %v: %s", test, err)
		} else if exp, err := ioutil.ReadFile(ex); err != nil {
			t.Logf("Couldn't read the expected output file %s (%s); it'll be created", ex, err)
			if err := ioutil.WriteFile(ex, []byte(cmp.String()), 0644); err != nil {
				t.Error(err)
			}
		} else if d := util.Diff(string(exp), cmp.String()); len(d) != 0 {
			t.Error(d)
		}
	}
}
开发者ID:noname007,项目名称:completion,代码行数:53,代码来源:net_test.go


示例3: prepare

func (c *Clang) prepare(a *content.CompleteAtArgs) (fn string, args []string, err error) {
	origargs, _ := a.Settings().Get("compiler_flags").([]string)
	args = make([]string, len(origargs))
	for i := range origargs {
		args[i] = expand_path.ExpandPath(origargs[i])
	}
	fn = a.Location.File.Name
	if a.Location.File.Contents != "" {
		// File is unsaved, so use stdin as the filename
		fn = "-"
	}

	return fn, args, nil
}
开发者ID:noname007,项目名称:completion,代码行数:14,代码来源:clang.go


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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang content.CompletionResult类代码示例发布时间:2022-05-28
下一篇:
Golang parser.PARSER类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap