Пример #1
0
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            ObjectTree objectTree = new ObjectTree(this.language, this.textBuffer.CurrentSnapshot);

            // In the case of virtual spaces, VS sends SnapshotPoint of the last physical
            // location in the line.  Unfortunately, we really need to know the virtual
            // location!  As far as I know, there's no way to actually get this.  Sadly,
            // that means that we might provide the wrong context.
            SnapshotPoint point = session.GetTriggerPoint(this.textBuffer.CurrentSnapshot).Value;
            Position      pos   = point.ToSwixPosition();

            StatementNode currentNode;
            StatementNode parentNode;

            if (!objectTree.TryFindContextNodes(pos, out currentNode, out parentNode))
            {
                return;
            }

            // Get compilation context for value completions (IDs, file names, etc.)
            IEnumerable <PackageItem> contextItems = SourceFileCompiler.Instance.GetCompilationContext(this.textBuffer);

            List <Completion> completions = this.CreateCompletions(objectTree, currentNode, parentNode, null, pos, contextItems);

            ITrackingSpan applicableSpan = this.FindApplicableSpan(session);

            completionSets.Add(new CompletionSet(
                                   "Swix Terms", // the non-localized title of the tab
                                   "Swix Terms", // the display title of the tab
                                   applicableSpan,
                                   completions,
                                   null));
        }