/// <summary> /// Populate context with proposals from provider added with the /// gtk_source_completion_context_add_proposals() function. /// </summary> /// <param name="context"></param> public void Populate(CompletionContext context) { try { string code = context.Iter.Buffer.Text; int offset = context.Iter.Buffer.CursorPosition; Task <IEnumerable <NeedContextItemsArgs.ContextItem> > task = service.GetCompletionItemsAsync(code, offset); task.Wait(); if (task.Result == null) { return; } IEnumerable <NeedContextItemsArgs.ContextItem> contextItems = task.Result.OrderBy(c => c.Name); // Iff owned is true, the list will be freed by calls to Dispose(). bool owned = true; // Iff elementsOwned is true, the list elements will be freed // when the list is freed, which will result in double disposal // of the list elements. bool elementsOwned = false; List proposals = new List(contextItems.Select(c => new CompletionProposalAdapter(new CustomScriptCompletionProposal(c))).ToArray(), typeof(CompletionProposalAdapter), owned, elementsOwned); context.AddProposals(this, proposals, true); } catch (Exception err) { ShowError(err); } }
/// <summary> /// Populate context with proposals from provider added with the /// gtk_source_completion_context_add_proposals() function. /// </summary> /// <param name="context"></param> public void Populate(CompletionContext context) { try { string code = context.Iter.Buffer.Text; int offset = context.Iter.Buffer.CursorPosition; Task <IEnumerable <NeedContextItemsArgs.ContextItem> > task = service.GetCompletionItemsAsync(code, offset); task.Wait(); if (task.Result == null) { return; } IEnumerable <NeedContextItemsArgs.ContextItem> contextItems = task.Result.OrderBy(c => c.Name); List proposals = new List(contextItems.Select(c => new CompletionProposalAdapter(new CustomScriptCompletionProposal(c))).ToArray(), typeof(CompletionProposalAdapter), true, true); context.AddProposals(this, proposals, true); } catch (Exception err) { ShowError(err); } }