Exemple #1
0
        public override async Task <TextChange?> GetTextChangeAsync(Document document, CompletionItem selectedItem, char?ch, CancellationToken cancellationToken)
        {
            string insertionText;

            if (ch == null)
            {
                insertionText = SymbolCompletionItem.GetInsertionText(selectedItem);
            }
            else
            {
                var position = SymbolCompletionItem.GetContextPosition(selectedItem);
                var context  = await this.CreateContext(document, position, cancellationToken).ConfigureAwait(false);

                var symbols = await SymbolCompletionItem.GetSymbolsAsync(selectedItem, document, cancellationToken).ConfigureAwait(false);

                if (symbols.Length > 0)
                {
                    insertionText = GetInsertionText(symbols[0], context, ch.Value);
                }
                else
                {
                    insertionText = selectedItem.DisplayText;
                }
            }

            return(new TextChange(selectedItem.Span, insertionText));
        }
        public override Task <TextChange?> GetTextChangeAsync(
            Document document,
            CompletionItem selectedItem,
            char?ch,
            CancellationToken cancellationToken
            )
        {
            var insertionText = SymbolCompletionItem.GetInsertionText(selectedItem);

            return(Task.FromResult <TextChange?>(new TextChange(selectedItem.Span, insertionText)));
        }
 protected virtual string GetInsertionText(CompletionItem item, char ch)
 {
     return(SymbolCompletionItem.GetInsertionText(item));
 }
 /// <summary>
 /// Override this if you want to provide customized insertion based on the character typed.
 /// </summary>
 private string GetInsertionText(CompletionItem item, char?ch)
 {
     return(ch == null
         ? SymbolCompletionItem.GetInsertionText(item)
         : GetInsertionText(item, ch.Value));
 }