static dynamic ToMonacoCompletionItems(XCB.ScriptContext context, CompletionModel model) { dynamic arr = context.CreateArray(); var filteredCompletions = model?.FilteredItems; if (filteredCompletions == null || filteredCompletions.Count == 0) { return(arr); } foreach (var completion in filteredCompletions) { if (completion.Span.End > model.Text.Length) { continue; } var displayText = completion.ToString(); // Check for the property added by the internal SymbolCompletionItem helper string insertionText; completion.Properties.TryGetValue("InsertionText", out insertionText); // Check for the property added by us during filtering string itemDetail; completion.Properties.TryGetValue(itemDetailPropertyName, out itemDetail); arr.push(context.CreateObject(o => { o.label = displayText; if (itemDetail != null) { o.detail = itemDetail; } if (insertionText != null) { o.insertText = insertionText; } o.kind = MonacoExtensions.ToMonacoCompletionItemKind(completion.Tags); })); } return(arr); }
static dynamic ToMonacoCompletionItems(XCB.ScriptContext context, IEnumerable <CompletionItemViewModel> items) { dynamic arr = context.CreateArray(); foreach (var item in items) { arr.push(context.CreateObject(o => { o.label = item.DisplayText; if (item.ItemDetail != null) { o.detail = item.ItemDetail; } if (item.InsertionText != null) { o.insertText = item.InsertionText; } o.kind = Client.Monaco.MonacoExtensions.ToMonacoCompletionItemKind(item.CompletionItem.Tags); })); } return(arr); }