Ejemplo n.º 1
0
        async Task <string> Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return)
        {
            var s = await Setup(input);

            var             ext     = s.Item1;
            TestViewContent content = s.Item2;

            var listWindow = new CompletionListWindow();
            var widget     = new TestCompletionWidget(ext.Editor, ext.DocumentContext);

            listWindow.CompletionWidget      = widget;
            listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;
            var sm = ext.DocumentContext.ParsedDocument.GetAst <SemanticModel> ();

            var t           = sm.Compilation.GetTypeByMetadataName(type);
            var foundMember = t.GetMembers().First(m => m.Name == member);
            var data        = new CompletionData(foundMember.Name);

            data.DisplayFlags |= DisplayFlags.NamedArgument;
            KeyActions ka = KeyActions.Process;

            data.InsertCompletionText(listWindow, ref ka, KeyDescriptor.FromGtk(key, (char)key, Gdk.ModifierType.None));

            return(widget.CompletedWord);
        }
Ejemplo n.º 2
0
        async Task <string> Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return)
        {
            string result = null;

            await Setup(input, async testCase => {
                var ext        = testCase.Content.GetContent <CSharpCompletionTextEditorExtension> ();
                var listWindow = new CompletionListWindow();
                var widget     = new TestCompletionWidget(ext.Editor, ext.DocumentContext);
                listWindow.CompletionWidget      = widget;
                listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;
                var sm = await ext.DocumentContext.AnalysisDocument.GetSemanticModelAsync();

                var t              = sm.Compilation.GetTypeByMetadataName(type);
                var foundMember    = t.GetMembers().First(m => m.Name == member);
                var data           = new CompletionData(foundMember.Name);
                data.DisplayFlags |= DisplayFlags.NamedArgument;
                KeyActions ka      = KeyActions.Process;
                data.InsertCompletionText(listWindow, ref ka, KeyDescriptor.FromGtk(key, (char)key, Gdk.ModifierType.None));
                result = widget.CompletedWord;
            });

            return(result);
        }