async Task<string> Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return, bool isDelegateExpected = false) { 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 model = ext.DocumentContext.ParsedDocument.GetAst<SemanticModel> (); Ide.IdeApp.Preferences.AddParenthesesAfterCompletion.Set (true); Ide.IdeApp.Preferences.AddOpeningOnly.Set (false); var t = model.Compilation.GetTypeByMetadataName (type); var method = member != null ? t.GetMembers().First (m => m.Name == member) : t.GetMembers ().OfType<IMethodSymbol> ().First (m => m.MethodKind == MethodKind.Constructor); var factory = new RoslynCodeCompletionFactory (ext, model); var data = new RoslynSymbolCompletionData (null, factory, method); data.IsDelegateExpected = isDelegateExpected; KeyActions ka = KeyActions.Process; data.InsertCompletionText (listWindow, ref ka, KeyDescriptor.FromGtk (key, (char)key, Gdk.ModifierType.None)); return widget.CompletedWord; }
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 factory = new RoslynCodeCompletionFactory (ext, sm); var data = new RoslynSymbolCompletionData (null, factory, foundMember); data.DisplayFlags |= DisplayFlags.NamedArgument; KeyActions ka = KeyActions.Process; data.InsertCompletionText (listWindow, ref ka, KeyDescriptor.FromGtk (key, (char)key, Gdk.ModifierType.None)); return widget.CompletedWord; }