Exemplo n.º 1
0
        async void PopupCompletion(Entry entry)
        {
            try {
                char c = (char)Gdk.Keyval.ToUnicode(keyValue);
                if (currentCompletionData == null && IsCompletionChar(c))
                {
                    string expr = entry.Text.Substring(0, entry.CursorPosition);
                    cts.Cancel();
                    cts = new CancellationTokenSource();
                    if (valueTree.Frame == null)
                    {
                        return;
                    }
                    currentCompletionData = await DebuggingService.GetCompletionDataAsync(valueTree.Frame, expr, cts.Token);

                    if (currentCompletionData != null)
                    {
                        DebugCompletionDataList dataList = new DebugCompletionDataList(currentCompletionData);
                        ctx = ((ICompletionWidget)this).CreateCodeCompletionContext(expr.Length - currentCompletionData.ExpressionLength);
                        CompletionWindowManager.ShowWindow(null, c, dataList, this, ctx);
                    }
                }
            } catch (OperationCanceledException) {
            }
        }
Exemplo n.º 2
0
        public async Task <CompletionContext> GetCompletionContextAsync(IAsyncCompletionSession session, CompletionTrigger trigger, SnapshotPoint triggerLocation, SnapshotSpan applicableToSpan, CancellationToken token)
        {
            var text = triggerLocation.Snapshot.GetText(0, triggerLocation.Position);
            var data = await DebuggingService.GetCompletionDataAsync(DebuggingService.CurrentFrame, text, token);

            if (data == null)
            {
                return(new CompletionContext(ImmutableArray <CompletionItem> .Empty));
            }

            var builder = ImmutableArray.CreateBuilder <CompletionItem> (data.Items.Count);

            foreach (var item in data.Items)
            {
                var image = new ImageElement(ObjectValueTreeViewController.GetImageId(item.Flags));

                builder.Add(new CompletionItem(item.Name, this, image));
            }

            return(new CompletionContext(builder.MoveToImmutable()));
        }