Ejemplo n.º 1
0
        private static CompletionModel CreateCompletionModel(SemanticModel semanticModel, int position)
        {
            var provider  = new KeywordCompletionProvider();
            var providers = new[] { provider };

            return(semanticModel.GetCompletionModel(position, providers));
        }
Ejemplo n.º 2
0
        private async void UpdateModel()
        {
            // UpdateModel is always called on the UI thread.
            _cancellationTokenSource?.Cancel();

            _cancellationTokenSource = new CancellationTokenSource();

            var token = _cancellationTokenSource.Token;

            var snapshot        = _textView.TextSnapshot;
            var triggerPosition = _textView.GetPosition(snapshot);

            CompletionModel model = null;

            try
            {
                SemanticModel semanticModel = null;
                if (!await Task.Run(() => snapshot.TryGetSemanticModel(token, out semanticModel), token))
                {
                    return;
                }

                await Task.Run(() => model = semanticModel.GetCompletionModel(triggerPosition, snapshot, _completionProviderService.Providers, token), token);
            }
            catch (OperationCanceledException)
            {
                return;
            }

            // Let observers know that we've a new model.
            Model = model;
        }
Ejemplo n.º 3
0
        public static CompletionModel GetCompletionModel(this SemanticModel semanticModel, int position)
        {
            var providers = GetStandardCompletionProviders();

            return(semanticModel.GetCompletionModel(position, providers));
        }