public void SetCompletionItems(
            IList <CompletionItem> completionItems,
            CompletionItem selectedItem,
            CompletionItem suggestionModeItem,
            bool suggestionMode,
            bool isSoftSelected,
            ImmutableArray <CompletionItemFilter> completionItemFilters,
            string filterText)
        {
            _foregroundThread.AssertIsForeground();

            // Initialize the completion map to a reasonable default initial size (+1 for the builder)
            CompletionItemMap  = CompletionItemMap ?? new Dictionary <CompletionItem, VSCompletion>(completionItems.Count + 1);
            FilterText         = filterText;
            SuggestionModeItem = suggestionModeItem;

            // If more than one filter was provided, then present it to the user.
            if (_showFilters && _filters == null && completionItemFilters.Length > 1)
            {
                _filters = completionItemFilters.Select(f => new IntellisenseFilter2(this, f))
                           .ToArray();
            }

            CreateCompletionListBuilder(selectedItem, suggestionModeItem, suggestionMode);
            CreateNormalCompletionListItems(completionItems);

            var selectedCompletionItem = selectedItem != null?GetVSCompletion(selectedItem) : null;

            SelectionStatus = new CompletionSelectionStatus(
                selectedCompletionItem,
                isSelected: !isSoftSelected, isUnique: selectedCompletionItem != null);
        }
Beispiel #2
0
        protected void LoadComponentsInUIContextOnceSolutionFullyLoaded(CancellationToken cancellationToken)
        {
            ForegroundObject.AssertIsForeground();

            if (KnownUIContexts.SolutionExistsAndFullyLoadedContext.IsActive)
            {
                // if we are already in the right UI context, load it right away
                LoadComponentsInUIContext(cancellationToken);
            }
            else
            {
                // load them when it is a right context.
                KnownUIContexts.SolutionExistsAndFullyLoadedContext.UIContextChanged += OnSolutionExistsAndFullyLoadedContext;
            }
        }
Beispiel #3
0
 private void OnClassificationFormatMappingChanged(object sender, EventArgs e)
 {
     _threadAffinitizedObject.AssertIsForeground();
     if (_format != null)
     {
         _format = null;
         _cache.Clear();
     }
 }
Beispiel #4
0
            private LazyToolTip(
                TextBlock textBlock,
                Func <DisposableToolTip> createToolTip)
            {
                _foregroundObject.AssertIsForeground();

                _textBlock     = textBlock;
                _createToolTip = createToolTip;

                // Set ourselves as the tooltip of this text block.  This will let WPF know that
                // it should attempt to show tooltips here.  When WPF wants to show the tooltip
                // though we'll hear about it "ToolTipOpening".  When that happens, we'll swap
                // out ourselves with a real tooltip that is lazily created.  When that tooltip
                // is the dismissed, we'll release the resources associated with it and we'll
                // reattach ourselves.
                _textBlock.ToolTip = this;

                textBlock.ToolTipOpening += this.OnToolTipOpening;
                textBlock.ToolTipClosing += this.OnToolTipClosing;
            }
Beispiel #5
0
        private CompletionHelper GetCompletionHelper()
        {
            _foregroundObject.AssertIsForeground();
            if (_completionHelper == null)
            {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                if (document != null)
                {
                    _completionHelper = CompletionHelper.GetHelper(document);
                }
            }

            return(_completionHelper);
        }
Beispiel #6
0
        public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining)
        {
            if (dwReadLocksRemaining + dwEditLocksRemaining == 0)
            {
                _foregroundAffinitization.AssertIsForeground();
                if (_runningDocumentTable.IsDocumentInitialized(docCookie))
                {
                    _listener.OnCloseDocument(_runningDocumentTable.GetDocumentMoniker(docCookie));
                }
            }

            return(VSConstants.S_OK);
        }
Beispiel #7
0
        private CompletionRules GetCompletionRules()
        {
            _foregroundObject.AssertIsForeground();
            if (_completionRules == null)
            {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                if (document != null)
                {
                    var service = document.Project.LanguageServices.GetService <ICompletionService>();
                    if (service != null)
                    {
                        _completionRules = service.GetCompletionRules();
                    }
                }
            }

            return(_completionRules);
        }
 public void Connect()
 {
     _foregroundObject.AssertIsForeground();
     _textView.LayoutChanged += OnLayoutChanged;
 }