コード例 #1
0
        public void PresentItems(ITrackingSpan triggerSpan, IList <CompletionItem> items, CompletionItem selectedItem, CompletionItem suggestionModeItem, bool suggestionMode, bool isSoftSelected, ImmutableArray <CompletionItemFilter> completionItemFilters, string filterText)
        {
            var result = new CompletionDataList();

            foreach (var item in items)
            {
                if (string.IsNullOrEmpty(item.DisplayText))
                {
                    continue;
                }
                result.Add(WrapItem(item));
            }

            if (suggestionMode)
            {
                result.AutoSelect = false;
            }
            if (filterText != null)
            {
                result.DefaultCompletionString = filterText;
            }
            if (suggestionModeItem != null)
            {
                result.DefaultCompletionString = suggestionModeItem.DisplayText;
                result.AutoSelect = false;
            }

            if (selectedItem != null)
            {
                result.DefaultCompletionString = selectedItem.DisplayText;
            }

            // TODO: isSoftSelected
            // TODO: completionItemFilters
            var editor = IdeApp.Workbench.ActiveDocument.Editor;
            CompletionTextEditorExtension completionEditorExtension = editor.GetContent <CompletionTextEditorExtension> ();

            completionEditorExtension.ShowCompletion(result);

            if (!_isAdvised)
            {
                CompletionWindowManager.Wnd.SelectionChanged += OnSelectionChanged;
                CompletionWindowManager.WordCompleted        += OnWordCompleted;

                CompletionWindowManager.WindowClosed += OnWindowClosed;

                // TODO: Would be nice it we could better detect whether we've already advised on the completion window
                _isAdvised = true;
            }
        }