Exemplo n.º 1
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            //ITrackingPoint point = session.GetTriggerPoint(_textBuffer);
            SnapshotPoint?triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot);

            if (!triggerPoint.HasValue)
            {
                return;
            }
            List <Declaration> strList = _analysisEntry.GetCompletionSource(triggerPoint.Value.Position).ToList();

            strList = strList.OrderBy(i => i.Name).ToList();

            _compList = new List <Completion>();
            foreach (var str in strList)
            {
                _compList.Add(new Completion(str.Name, str.Name, str.Name, _provider.GetImageSource(str.Type), null));
            }

            completionSets.Add(new CompletionSet(
                                   "Tokens",
                                   "Tokens",
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer),
                                                           session),
                                   _compList,
                                   null));
        }
Exemplo n.º 2
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            var buffer       = _textBuffer;
            var snapshot     = buffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(buffer).GetPoint(snapshot);

            // Disable completions if user is editing a special command (e.g. ".cls") in the REPL.
            if (snapshot.TextBuffer.Properties.ContainsProperty(typeof(IReplEvaluator)) && snapshot.Length != 0 && snapshot[0] == '.')
            {
                return;
            }

            if (ShouldTriggerRequireIntellisense(triggerPoint, _classifier, true, true))
            {
                AugmentCompletionSessionForRequire(triggerPoint, session, completionSets);
                return;
            }

            var textBuffer = _textBuffer;
            var span       = GetApplicableSpan(session, textBuffer);
            var provider   = VsProjectAnalyzer.GetCompletions(
                _textBuffer.CurrentSnapshot,
                span,
                session.GetTriggerPoint(buffer));

            var completions = provider.GetCompletions(_glyphService);

            if (completions != null && completions.Completions.Count > 0)
            {
                completionSets.Add(completions);
            }
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
            var buffer = _textBuffer;
            var snapshot = buffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(buffer).GetPoint(snapshot);

            // Disable completions if user is editing a special command (e.g. ".cls") in the REPL.
            if (snapshot.TextBuffer.Properties.ContainsProperty(typeof(IReplEvaluator)) && snapshot.Length != 0 && snapshot[0] == '.') {
                return;
            }

            if (ShouldTriggerRequireIntellisense(triggerPoint, _classifier, true, true)) {
                AugmentCompletionSessionForRequire(triggerPoint, session, completionSets);
                return;
            }

            var textBuffer = _textBuffer;
            var span = GetApplicableSpan(session, textBuffer);
            var provider = VsProjectAnalyzer.GetCompletions(
                _textBuffer.CurrentSnapshot,
                span,
                session.GetTriggerPoint(buffer));

            var completions = provider.GetCompletions(_glyphService);
            if (completions != null && completions.Completions.Count > 0) {
                completionSets.Add(completions);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Augments a completion session.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="completionSets"></param>
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            try
            {
                if (m_disposed)
                {
                    return;
                }

                SnapshotPoint?snapshotPoint = session.GetTriggerPoint(m_textBuffer.CurrentSnapshot);
                if (!snapshotPoint.HasValue)
                {
                    return;
                }

                string text = snapshotPoint.Value.GetContainingLine().GetText();
                if (m_textBuffer.ContentType.TypeName != DoxygenCompletionCommandHandler.CppTypeName)
                {
                    return;
                }

                if (!text.TrimStart().StartsWith("*"))
                {
                    return;
                }

                ITrackingSpan trackingSpan = FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session);

                // Check what kind of completion set we need to create.
                List <Completion> compList = null;
                var prevChar = snapshotPoint.Value.Subtract(1).GetChar();

                // Type direction tags.
                if (prevChar == '[')
                {
                    compList = m_compListDir;
                }
                // Generic doxygen tags.
                else if (prevChar == m_configService.Config.TagChar)
                {
                    compList = m_compListTag;
                }

                if (compList != null)
                {
                    var newCompletionSet = new CompletionSet(
                        "TripleSlashCompletionSet",
                        "TripleSlashCompletionSet",
                        trackingSpan,
                        compList,
                        Enumerable.Empty <Completion>());
                    completionSets.Add(newCompletionSet);
                }
            }
            catch
            {
            }
        }
        private char GetLastTypedCharter()
        {
            // m_textView.Caret.Position.Point.GetPoint().Value.GetChar();
            SnapshotPoint?snapshotPoint = m_session.GetTriggerPoint(m_textView.TextBuffer.CurrentSnapshot);

            if (!snapshotPoint.HasValue)
            {
                return('\0');
            }

            return((m_session.GetTriggerPoint(m_textView.TextBuffer.CurrentSnapshot).Value - 1).GetChar());
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            try
            {
                // Only complete in active sessions
                if (m_isDisposed)
                {
                    return;
                }

                SnapshotPoint?snapshotPoint = session.GetTriggerPoint(m_textBuffer.CurrentSnapshot);
                if (!snapshotPoint.HasValue)
                {
                    return;
                }

                // Only complete in c/c++
                if (m_textBuffer.ContentType.TypeName != DoxygenCompletionHandler.CppTypeName)
                {
                    return;
                }

                // Only complete in comment lines
                string text = snapshotPoint.Value.GetContainingLine().GetText();
                if (!text.TrimStart().StartsWith("* ") && !text.TrimStart().StartsWith("/// "))
                {
                    return;
                }

                ITrackingSpan trackingSpan = FindTokenSpanAtPosition(text, session.GetTriggerPoint(m_textBuffer), session);

                if (trackingSpan == null)
                {
                    return;
                }

                var startText = trackingSpan.GetText(m_textBuffer.CurrentSnapshot);

                bool isAt = startText.StartsWith("@");

                var newCompletionSet = new CompletionSet(
                    "DoxygenCompletionSet",
                    "DoxygenCompletionSet",
                    trackingSpan,
                    isAt ? m_compList_at : m_compList,
                    Enumerable.Empty <Completion>());
                completionSets.Add(newCompletionSet);
            }
            catch
            {
            }
        }
Exemplo n.º 7
0
        public async System.Threading.Tasks.Task CollectCompletionSets(ICompletionSession newSession)
        {
            JavaEditor javaEditor = null;

            if (TextBuffer.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader          = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var autocompleteRequest = ProtocolHandlers.CreateAutocompleteRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot));
                var autocompleteResponse = await javaEditor.JavaPkgServer.Send(javaEditor, autocompleteRequest);

                if (autocompleteResponse.responseType == Protocol.Response.ResponseType.Autocomplete &&
                    autocompleteResponse.autocompleteResponse != null)
                {
                    if (autocompleteResponse.autocompleteResponse.status && autocompleteResponse.autocompleteResponse.proposals.Count != 0)
                    {
                        CompletionSetList = new List <CompletionSet>();
                        var list = TransformCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals);
                        CompletionSetList.Add(new CompletionSet("Autocomplete", "Autocomplete", GetReplacementSpanFromCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals.First()), list, null)); // FindTokenSpanAtPosition(newSession.GetTriggerPoint(TextBuffer), newSession), list, null));
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("GherkinStepCompletionSource");
            }

            ITextSnapshot snapshot     = textBuffer.CurrentSnapshot;
            var           triggerPoint = session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            if (IsKeywordCompletion(triggerPoint.Value))
            {
                IEnumerable <Completion> completions  = GetKeywordCompletions();
                ITrackingSpan            applicableTo = GetApplicableToForKeyword(snapshot, triggerPoint.Value);

                completionSets.Add(
                    new CustomCompletionSet(
                        "Keywords",
                        "Keywords",
                        applicableTo,
                        completions,
                        null));
            }
            else
            {
                string parsedKeyword;
                var    bindingType = GetCurrentBindingType(triggerPoint.Value, out parsedKeyword);
                if (bindingType == null)
                {
                    return;
                }

                IEnumerable <Completion> completions;
                string statusText;
                GetCompletionsForBindingType(bindingType.Value, out completions, out statusText);

                ITrackingSpan applicableTo = GetApplicableToForStep(snapshot, triggerPoint.Value, parsedKeyword);

                string displayName   = string.Format("All {0} Steps", bindingType.Value);
                var    completionSet = new HierarchicalCompletionSet(
                    displayName,
                    displayName,
                    applicableTo,
                    completions,
                    null,
                    limitStepInstancesSuggestions,
                    maxStepInstancesSuggestions);

                if (!string.IsNullOrEmpty(statusText))
                {
                    completionSet.StatusText = statusText;
                }
                completionSets.Add(completionSet);
            }
        }
Exemplo n.º 9
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (disposed)
                throw new ObjectDisposedException("GherkinStepCompletionSource");

            ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(snapshot);
            if (triggerPoint == null)
                return;

            ScenarioBlock? scenarioBlock = GetCurrentScenarioBlock(triggerPoint.Value);
            if (scenarioBlock == null)
                return;

            IEnumerable<Completion> completions = GetCompletionsForBlock(scenarioBlock.Value);
            ITrackingSpan applicableTo = GetApplicableToSpan(snapshot, triggerPoint.Value);

            string displayName = string.Format("All {0} Steps", scenarioBlock);
            completionSets.Add(
                new CompletionSet(
                    displayName,
                    displayName,
                    applicableTo,
                    completions,
                    null));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
            var line     = position.GetContainingLine();


            if (line == null)
            {
                return;
            }


            string text         = line.GetText();
            var    linePosition = position - line.Start;


            foreach (var source in completionSources)
            {
                var span = source.GetInvocationSpan(text, linePosition, position);
                if (span == null)
                {
                    continue;
                }

                var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(span.Value.Start + line.Start, span.Value.Length, SpanTrackingMode.EdgeInclusive);
                completionSets.Add(new StringCompletionSet(
                                       source.GetType().Name,
                                       trackingSpan,
                                       source.GetEntries(quote: text[span.Value.Start], caret: session.TextView.Caret.Position.BufferPosition)
                                       ));
            }
            // TODO: Merge & resort all sets?  Will StringCompletionSource handle other entries?
            //completionSets.SelectMany(s => s.Completions).OrderBy(c=>c.DisplayText.TrimStart('"','\''))
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            var snapshotTriggerPoint = session.GetTriggerPoint(_buffer.CurrentSnapshot);

            if (snapshotTriggerPoint == null)
            {
                return;
            }

            var completionResult = CollectCompletions(snapshotTriggerPoint.Value);

            if (completionResult.Value.Count == 0)
            {
                return;
            }

            var applicableTo = GetApplicableTo(completionResult);

            if (applicableTo == null)
            {
                return;
            }

            completionSets.Add(new ContainsFilteredCompletionSet(
                                   _name,
                                   _name,
                                   applicableTo,
                                   completionResult.Value,
                                   null));
        }
Exemplo n.º 12
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            //var completions = new CompletionSet();
            //completions.Completions.Add(new Completion("Test"));
            //completionSets.Add(completions);
            List <string> strList = new List <string>();

            strList.Add("addition");
            strList.Add("adaptation");
            strList.Add("subtraction");
            strList.Add("summation");
            _compList = new List <Completion>();
            foreach (string str in strList)
            {
                _compList.Add(new Completion(str, str, str, null, null));
            }

            completionSets.Add(new CompletionSet(
                                   "Tokens", //the non-localized title of the tab
                                   "Tokens", //the display title of the tab
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer),
                                                           session),
                                   _compList,
                                   null));
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var allKnown = new List<string>
                               {
                                   "var",
                                   "def",
                                   "default",
                                   "global",
                                   "viewdata",
                                   "model",
                                   "set",
                                   "for",
                                   "test",
                                   "if",
                                   "else",
                                   "elseif",
                                   "content",
                                   "use",
                                   "macro",
                                   "render",
                                   "section",
                                   "cache",
                               };
            allKnown.Sort();

            _compList = new List<Completion>();
            foreach (var known in allKnown)
                _compList.Add(new Completion(known, known, known, null, null));

            completionSets.Add(new CompletionSet(
                                   "Spark", //the non-localized title of the tab
                                   "Spark", //the display title of the tab
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer), session), _compList,
                                   null));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds the Markdown header sections to the list of completion sets in an autocomplete session.
        /// </summary>
        /// <param name="Session">The autocomplete session being created</param>
        /// <param name="CompletionSets">The list of completion sets to add to</param>
        public void AugmentCompletionSession(ICompletionSession Session, IList <CompletionSet> CompletionSets)
        {
            try
            {
                Logger.Debug("Adding markdown headers to an autocomplete session.");

                // Get the line that the cursor is currently on
                SnapshotPoint?triggerPoint = Session.GetTriggerPoint(TextBuffer.CurrentSnapshot);
                string        line         = triggerPoint.Value.GetContainingLine().GetText();

                // Check if it looks like the user is starting to write a Markdown header
                if (line.Trim().StartsWith("/// #"))
                {
                    SnapshotPoint currentPoint  = Session.TextView.Caret.Position.BufferPosition - 1;
                    ITrackingSpan trackingSpan  = currentPoint.Snapshot.CreateTrackingSpan(currentPoint, 1, SpanTrackingMode.EdgeInclusive);
                    CompletionSet completionSet = new CompletionSet(
                        "QSharpMarkdownCompletionSet",
                        "Q# Markdown Completion Set",
                        trackingSpan,
                        MarkdownCompletionList,
                        new Completion[0]
                        );
                    CompletionSets.Add(completionSet);
                }
            }
            catch (Exception ex)
            {
                Logger.Warn($"A problem occurred during Markdown header autocompletion: {ex.GetType().Name} - {ex.Message}");
                Logger.Trace(ex.StackTrace);
            }
        }
Exemplo n.º 15
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("AntlrCompletionSource");
            }

            List <Completion> completions = new List <Completion>()
            {
                new Completion(Constants.ClassificationNameTerminal),
                new Completion(Constants.ClassificationNameNonterminal),
                new Completion(Constants.ClassificationNameComment),
                new Completion(Constants.ClassificationNameKeyword)
            };

            ITextSnapshot snapshot       = _buffer.CurrentSnapshot;
            SnapshotPoint snapshot_point = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (snapshot_point == null)
            {
                return;
            }

            var           line  = snapshot_point.GetContainingLine();
            SnapshotPoint start = snapshot_point;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            ITrackingSpan tracking_span = snapshot.CreateTrackingSpan(new SnapshotSpan(start, snapshot_point), SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("All", "All", tracking_span, completions, Enumerable.Empty <Completion>()));
        }
Exemplo n.º 16
0
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            List <string> strList = new List <string>();

            _compList = new List <Completion>();

            foreach (string builtin in Constants.MplBuiltins)
            {
                if (builtin.Length > 1)
                {
                    strList.Add(builtin);
                    _compList.Add(new Completion(builtin, builtin, "builtin function", null, null));
                }
            }

            foreach (string name in ParseTree.Tree.nameList)
            {
                if (!strList.Contains(name))
                {
                    _compList.Add(new Completion(name, name, null, null, null));
                }
            }

            completionSets.Add(new CompletionSet(
                                   "Tokens", //the non-localized title of the tab
                                   "Tokens", //the display title of the tab
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer), session),
                                   _compList,
                                   null));
        }
Exemplo n.º 17
0
        public static bool HasMovedOutOfIntelliSenseRange(this uint key, ITextView textView, ICompletionSession session)
        {
            if (textView == null)
            {
                return(true);
            }

            var           textBuffer           = textView.TextBuffer;
            var           caretPosition        = textView.Caret.Position.BufferPosition.Position;
            var           triggerPoint         = session.GetTriggerPoint(textBuffer).GetPoint(textBuffer.CurrentSnapshot);
            ITrackingSpan completionSpan       = triggerPoint.Snapshot.CreateTrackingSpan(new Span(triggerPoint, 0), SpanTrackingMode.EdgeInclusive);
            int           completionSpanLength = completionSpan.GetSpan(textView.TextSnapshot).Length;

            switch (key)
            {
            case (uint)VSConstants.VSStd2KCmdID.LEFT:
                return(caretPosition < triggerPoint);

            case (uint)VSConstants.VSStd2KCmdID.RIGHT:
                return(caretPosition > triggerPoint + completionSpanLength);

            default:
                return(false);
            }
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if ( !settings.TextCompletionEnabled ) {
            return;
              }
              if ( session.TextView.TextBuffer != this.theBuffer ) {
            return;
              }
              if ( !PlainTextCompletionContext.IsSet(session) ) {
            return;
              }
              var snapshot = theBuffer.CurrentSnapshot;
              var triggerPoint = session.GetTriggerPoint(snapshot);
              if ( !triggerPoint.HasValue ) {
            return;
              }

              var applicableToSpan = GetApplicableToSpan(triggerPoint.Value);

              var then = this.bufferStatsOnCompletion;
              var now = new BufferStats(snapshot);
              if ( currentCompletions == null || now.SignificantThan(then) ) {
            this.currentCompletions = BuildCompletionsList();
            this.bufferStatsOnCompletion = now;
              }
              var set = new CompletionSet(
            moniker: "plainText",
            displayName: "Text",
            applicableTo: applicableToSpan,
            completions: currentCompletions,
            completionBuilders: null
            );
              completionSets.Add(set);
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                return;

            List<Completion> completions = new List<Completion>();
            foreach (string item in RobotsTxtClassifier._valid)
            {
                completions.Add(new Completion(item, item, null, _glyph, item));
            }

            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            string text = line.GetText();
            int index = text.IndexOf(':');
            int hash = text.IndexOf('#');
            SnapshotPoint start = triggerPoint;

            if (hash > -1 && hash < triggerPoint.Position || (index > -1 && (start - line.Start.Position) > index))
                return;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty<Completion>()));
        }
Exemplo n.º 20
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));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var position = session.GetTriggerPoint(this.textBuffer).GetPoint(this.textBuffer.CurrentSnapshot);
            var line = position.GetContainingLine();

            if (line == null)
            {
                return;
            }

            int linePos = position - line.Start.Position;

            var info = UIRouterStateCompletionUtils.FindCompletionInfo(line.GetText(), linePos);
            if (info == null)
            {
                return;
            }

            var callingFilename = this.textBuffer.GetFileName();
            var appHierarchy = this.ngHierarchyProvider.Get(callingFilename);

            IEnumerable<Completion> results = null;
            results = this.GetCompletions(appHierarchy);

            var trackingSpan = this.textBuffer.CurrentSnapshot.CreateTrackingSpan(info.Item2.Start + line.Start, info.Item2.Length, SpanTrackingMode.EdgeInclusive);
            completionSets.Add(new CompletionSet(
                "Angular views",
                "Angular views",
                trackingSpan,
                results,
                null
            ));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Primary entry point for intellisense. This is where intellisense list is getting created.
        /// </summary>
        /// <param name="session">Completion session</param>
        /// <param name="completionSets">Completion sets to populate</param>
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            Debug.Assert(EditorShell.IsUIThread);

            IREditorDocument doc = REditorDocument.TryFromTextBuffer(_textBuffer);

            if (doc == null)
            {
                return;
            }

            int position = session.GetTriggerPoint(_textBuffer).GetPosition(_textBuffer.CurrentSnapshot);

            if (!doc.EditorTree.IsReady)
            {
                doc.EditorTree.InvokeWhenReady((o) => {
                    RCompletionController controller = ServiceManager.GetService <RCompletionController>(session.TextView);
                    if (controller != null)
                    {
                        controller.ShowCompletion(autoShownCompletion: true);
                        controller.FilterCompletionSession();
                    }
                }, null, this.GetType(), processNow: true);
            }
            else
            {
                PopulateCompletionList(position, session, completionSets, doc.EditorTree.AstRoot);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Primary entry point for intellisense. This is where intellisense list is getting created.
        /// </summary>
        /// <param name="session">Completion session</param>
        /// <param name="completionSets">Completion sets to populate</param>
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            Debug.Assert(EditorShell.IsUIThread);

            if (_asyncSession != null)
            {
                return;
            }

            IREditorDocument doc = REditorDocument.TryFromTextBuffer(_textBuffer);

            if (doc == null)
            {
                return;
            }

            int position = session.GetTriggerPoint(_textBuffer).GetPosition(_textBuffer.CurrentSnapshot);

            if (!doc.EditorTree.IsReady)
            {
                // Parsing is pending. Make completion async.
                CreateAsyncSession(doc, position, session, completionSets);
            }
            else
            {
                PopulateCompletionList(position, session, completionSets, doc.EditorTree.AstRoot);
            }
        }
        /// <summary>
        /// Gets the declarations and snippet entries for the completion
        /// </summary>
        private CompletionSet GetCompletions(List <Declaration> attributes, ICompletionSession session)
        {
            // Add IPy completion
            var completions = new List <Completion>();

            completions.AddRange(attributes.Select(declaration => new PyCompletion(declaration, glyphService)));

            if (completions.Count > 0)
            {
                // Add Snippets entries
                var expansionManager   = (IVsTextManager2)this.serviceProvider.GetService(typeof(SVsTextManager));
                var snippetsEnumerator = new SnippetsEnumerator(expansionManager, Constants.IronPythonLanguageServiceGuid);
                completions.AddRange(snippetsEnumerator.Select(expansion => new PyCompletion(expansion, glyphService)));
            }

            // we want the user to get a sorted list
            completions.Sort();

            return
                (new CompletionSet("IPyCompletion",
                                   "IronPython Completion",
                                   CreateTrackingSpan(session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(textBuffer.CurrentSnapshot)),
                                   completions,
                                   null)
                );
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            int position = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(textBuffer.CurrentSnapshot);
            int line     = textBuffer.CurrentSnapshot.GetLineNumberFromPosition(position);
            int column   = position - textBuffer.CurrentSnapshot.GetLineFromPosition(position).Start.Position;

            Microsoft.VisualStudio.IronPythonInference.Modules modules = new Microsoft.VisualStudio.IronPythonInference.Modules();

            IList <Declaration> attributes;

            if (textBuffer.GetReadOnlyExtents(new Span(0, textBuffer.CurrentSnapshot.Length)).Count > 0)
            {
                int start;
                var readWriteText = TextOfLine(textBuffer, line, column, out start, true);
                var module        = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), readWriteText);

                attributes = module.GetAttributesAt(1, column - 1);

                foreach (var attribute in GetEngineAttributes(readWriteText, column - start - 1))
                {
                    attributes.Add(attribute);
                }
            }
            else
            {
                var module = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), textBuffer.CurrentSnapshot.GetText());

                attributes = module.GetAttributesAt(line + 1, column);
            }

            completionSets.Add(GetCompletions((List <Declaration>)attributes, session));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            int triggerPointPosition = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(session.TextView.TextSnapshot);
            ITrackingSpan trackingSpan = session.TextView.TextSnapshot.CreateTrackingSpan(triggerPointPosition, 0, SpanTrackingMode.EdgeInclusive);

            var rewriteDirectives = new[] {
                new ApacheCompletion("RewriteBase", "RewriteBase", "The RewriteBase directive explicitly sets the base URL for per-directory rewrites."),
                new ApacheCompletion("RewriteCond", "RewriteCond", "The RewriteCond directive defines a rule condition. One or more RewriteCond can precede a RewriteRule directive."),
                new ApacheCompletion("RewriteEngine", "RewriteEngine", "The RewriteEngine directive enables or disables the runtime rewriting engine."),
                new ApacheCompletion("RewriteLock", "RewriteLock", "This directive sets the filename for a synchronization lockfile which mod_rewrite needs to communicate with RewriteMap programs."),
                new ApacheCompletion("RewriteLog", "RewriteLog", "The RewriteLog directive sets the name of the file to which the server logs any rewriting actions it performs."),
                new ApacheCompletion("RewriteLogLevel", "RewriteLogLevel", "The RewriteLogLevel directive sets the verbosity level of the rewriting logfile."),
                new ApacheCompletion("RewriteMap", "RewriteMap", "The RewriteMap directive defines a Rewriting Map which can be used inside rule substitution strings by the mapping-functions to insert/substitute fields through a key lookup."),
                new ApacheCompletion("RewriteOptions", "RewriteOptions", "The RewriteOptions directive sets some special options for the current per-server or per-directory configuration."),
                new ApacheCompletion("RewriteRule", "RewriteRule", "The RewriteRule directive is the real rewriting workhorse. The directive can occur more than once, with each instance defining a single rewrite rule. The order in which these rules are defined is important - this is the order in which they will be applied at run-time.")
            };

            var completionSet = new CompletionSet(
                ApacheContentType.Name,
                "Apache Rewrite Directives",
                trackingSpan,
                rewriteDirectives,
                null
            );

            completionSets.Add(completionSet);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Provide a list of completion items that contains the valid string-substitution tokens
        /// </summary>
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            // create a list of completions from the dictionary of valid tokens
            List <Completion> completions = new List <Completion>();

            foreach (KeyValuePair <string, string> token in PkgDefTokenTagger.ValidTokens)
            {
                completions.Add(new Completion(token.Key, token.Key, token.Value, null, null));
            }
            ;

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint - 1;  // start selection to left of '$'

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("PkgDefTokens", "All", applicableTo, completions, Enumerable.Empty <Completion>()));
        }
Exemplo n.º 28
0
        public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
            var doc = HtmlEditorDocument.FromTextBuffer(_buffer);
            if (doc == null) {
                return;
            }
            doc.HtmlEditorTree.EnsureTreeReady();

            var primarySnapshot = doc.PrimaryView.TextSnapshot;
            var nullableTriggerPoint = session.GetTriggerPoint(primarySnapshot);
            if (!nullableTriggerPoint.HasValue) {
                return;
            }
            var triggerPoint = nullableTriggerPoint.Value;

            var artifacts = doc.HtmlEditorTree.ArtifactCollection;
            var index = artifacts.GetItemContaining(triggerPoint.Position);
            if (index < 0) {
                return;
            }

            var artifact = artifacts[index] as TemplateArtifact;
            if (artifact == null) {
                return;
            }

            var artifactText = doc.HtmlEditorTree.ParseTree.Text.GetText(artifact.InnerRange);
            artifact.Parse(artifactText);

            ITrackingSpan applicableSpan;
            var completionSet = GetCompletionSet(session.GetOptions(_analyzer._serviceProvider), _analyzer, artifact.TokenKind, artifactText, artifact.InnerRange.Start, triggerPoint, out applicableSpan);
            completionSets.Add(completionSet);
        }
Exemplo n.º 29
0
        public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
            var nullableTriggerPoint = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!nullableTriggerPoint.HasValue) {
                return;
            }

            var triggerPoint = nullableTriggerPoint.Value;
            TemplateProjectionBuffer projBuffer;
            if (!_buffer.Properties.TryGetProperty<TemplateProjectionBuffer>(typeof(TemplateProjectionBuffer), out projBuffer)) {
                return;
            }

            int templateStart;
            TemplateTokenKind kind;
            var templateText = projBuffer.GetTemplateText(triggerPoint, out kind, out templateStart);
            if (templateText == null) {
                return;
            }

            if (kind == TemplateTokenKind.Block || kind == TemplateTokenKind.Variable) {
                ITrackingSpan applicableSpan;
                var completionSet = GetCompletionSet(
                    session.GetOptions(),
                    _analyzer,
                    kind,
                    templateText,
                    templateStart,
                    triggerPoint,
                    out applicableSpan);
                completionSets.Add(completionSet);
            }
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            int position = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(textBuffer.CurrentSnapshot);
            int line = textBuffer.CurrentSnapshot.GetLineNumberFromPosition(position);
            int column = position - textBuffer.CurrentSnapshot.GetLineFromPosition(position).Start.Position;

            Microsoft.VisualStudio.IronPythonInference.Modules modules = new Microsoft.VisualStudio.IronPythonInference.Modules();

            IList<Declaration> attributes;
            if (textBuffer.GetReadOnlyExtents(new Span(0, textBuffer.CurrentSnapshot.Length)).Count > 0)
            {
                int start;
                var readWriteText = TextOfLine(textBuffer, line, column, out start, true);
                var module = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), readWriteText);

                attributes = module.GetAttributesAt(1, column - 1);

                foreach (var attribute in GetEngineAttributes(readWriteText, column - start - 1))
                {
                    attributes.Add(attribute);
                }
            }
            else
            {
                var module = modules.AnalyzeModule(new QuietCompilerSink(), textBuffer.GetFileName(), textBuffer.CurrentSnapshot.GetText());

                attributes = module.GetAttributesAt(line + 1, column);
            }

            completionSets.Add(GetCompletions((List<Declaration>)attributes, session));
        }
Exemplo n.º 31
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                throw new ObjectDisposedException("XSharpCompletionSource");

            List<Completion> completions = new List<Completion>()
            {
                new Completion("SELF"),
                new Completion("FUNCTION"),
                new Completion("CLASS")
            };
            
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            // XSHARP : Disable Intellisense 
            //completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty<Completion>()));
        }
Exemplo n.º 32
0
        /// <summary>
        /// Primary entry point for intellisense. This is where intellisense list is getting created.
        /// </summary>
        /// <param name="session">Completion session</param>
        /// <param name="completionSets">Completion sets to populate</param>
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            _services.MainThread().Assert();

            var doc = _textBuffer.GetEditorDocument <IREditorDocument>();

            if (doc == null)
            {
                return;
            }

            var position = session.GetTriggerPoint(_textBuffer).GetPosition(_textBuffer.CurrentSnapshot);

            if (!doc.EditorTree.IsReady)
            {
                var textView = session.TextView;
                doc.EditorTree.InvokeWhenReady((o) => {
                    var controller = CompletionController.FromTextView <RCompletionController>(textView);
                    if (controller != null)
                    {
                        controller.ShowCompletion(autoShownCompletion: true);
                        controller.FilterCompletionSession();
                    }
                }, null, GetType(), processNow: true);
            }
            else
            {
                PopulateCompletionList(position, session, completionSets, doc.EditorTree.AstRoot);
            }
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            TemplateProjectionBuffer projBuffer;

            if (_textBuffer.Properties.TryGetProperty <TemplateProjectionBuffer>(typeof(TemplateProjectionBuffer), out projBuffer))
            {
                var completions = new List <DynamicallyVisibleCompletion>();
                foreach (var tag in _htmlTags)
                {
                    completions.Add(new DynamicallyVisibleCompletion(
                                        tag,
                                        tag,
                                        "",
                                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                                        "")
                                    );
                }
                foreach (var tag in _htmlTags)
                {
                    completions.Add(new DynamicallyVisibleCompletion(
                                        "/" + tag,
                                        "/" + tag,
                                        "",
                                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                                        "")
                                    );
                }

                //
                var triggerPoint = session.GetTriggerPoint(_textBuffer);
                var point        = triggerPoint.GetPoint(_textBuffer.CurrentSnapshot);

                var match = projBuffer.BufferGraph.MapUpToFirstMatch(
                    point,
                    PointTrackingMode.Positive,
                    x => x.TextBuffer != _textBuffer,
                    PositionAffinity.Predecessor
                    );

                if (match == null ||
                    !match.Value.Snapshot.TextBuffer.ContentType.IsOfType(TemplateContentType.ContentTypeName))
                {
                    var line     = point.GetContainingLine();
                    var text     = line.GetText();
                    int position = point.Position;
                    for (int i = position - line.Start.Position - 1; i >= 0 && i < text.Length; --i, --position)
                    {
                        char c = text[i];
                        if (!char.IsLetterOrDigit(c) && c != '!')
                        {
                            break;
                        }
                    }

                    var span = _textBuffer.CurrentSnapshot.CreateTrackingSpan(position, point.Position - position, SpanTrackingMode.EdgeInclusive);

                    completionSets.Add(new FuzzyCompletionSet("PythonDjangoTemplateHtml", "HTML", span, completions, session.GetOptions(), CompletionComparer.UnderscoresLast));
                }
            }
        }
Exemplo n.º 34
0
		public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
			var snapshot = session.TextView.TextSnapshot;
			var triggerPoint = session.GetTriggerPoint(snapshot);
			if (triggerPoint == null)
				return;
			var info = CompletionInfo.Create(snapshot);
			if (info == null)
				return;

			// This helps a little to speed up the code
			ProfileOptimizationHelper.StartProfile("roslyn-completion-" + info.Value.CompletionService.Language);

			CompletionTrigger completionTrigger;
			session.Properties.TryGetProperty(typeof(CompletionTrigger), out completionTrigger);

			var completionList = info.Value.CompletionService.GetCompletionsAsync(info.Value.Document, triggerPoint.Value.Position, completionTrigger).GetAwaiter().GetResult();
			if (completionList == null)
				return;
			Debug.Assert(completionList.Span.End <= snapshot.Length);
			if (completionList.Span.End > snapshot.Length)
				return;
			var trackingSpan = snapshot.CreateTrackingSpan(completionList.Span.Start, completionList.Span.Length, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);
			var completionSet = RoslynCompletionSet.Create(imageMonikerService, mruCompletionService, completionList, info.Value.CompletionService, session.TextView, DefaultCompletionSetMoniker, dnSpy_Roslyn_Shared_Resources.CompletionSet_All, trackingSpan);
			completionSets.Add(completionSet);
		}
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                return;

            ITextSnapshot snapshot = session.TextView.TextBuffer.CurrentSnapshot;
            SnapshotPoint? triggerPoint = session.GetTriggerPoint(snapshot);
            ClassificationSpan clsSpan;

            if (triggerPoint == null || !triggerPoint.HasValue || triggerPoint.Value.Position == 0 || !IsAllowed(triggerPoint.Value, out clsSpan))
                return;

            ITrackingSpan tracking = FindTokenSpanAtPosition(session);

            if (tracking == null)
                return;

            List<Completion> completions = new List<Completion>();

            if (clsSpan != null && clsSpan.ClassificationType.IsOfType(PredefinedClassificationTypeNames.SymbolDefinition))
            {
                AddVariableCompletions(snapshot, tracking, completions);
            }
            //else if (!tracking.GetText(snapshot).Any(c => !char.IsLetter(c) && !char.IsWhiteSpace(c)))
            //{
            //    AddKeywordCompletions(completions);
            //}

            if (completions.Count > 0)
            {
                var ordered = completions.OrderBy(c => c.DisplayText);
                completionSets.Add(new CompletionSet("Cmd", "Cmd", tracking, ordered, Enumerable.Empty<Completion>()));
            }
        }
Exemplo n.º 36
0
        /// <summary>
        /// Create a tracking span that is used in a completesion set in the given session.
        /// </summary>
        private ITrackingSpan CreateTrackingSpan(ICompletionSession session, ITokenInfo tokenInfo)
        {
            var triggerPoint    = session.GetTriggerPoint(session.TextView.TextBuffer);
            var currentSnapshot = textBuffer.CurrentSnapshot;

            if (tokenInfo != null)
            {
                var textViewLine = session.TextView.GetTextViewLineContainingBufferPosition(triggerPoint.GetPoint(currentSnapshot));
                var start        = textViewLine.Start.Position;
                var first        = start + tokenInfo.StartIndex;
                int length;
                if (tokenInfo.IsStartStringLiteral)
                {
                    length = 0;
                    first++;
                }
                else
                {
                    length = tokenInfo.EndIndex - tokenInfo.StartIndex + 1;
                }
                return(currentSnapshot.CreateTrackingSpan(first, length, SpanTrackingMode.EdgeInclusive));
            }
            else
            {
                var position   = triggerPoint.GetPosition(currentSnapshot);
                var separators = new[] { '"', '\'', '.', '>', '<', ' ' };
                var text       = currentSnapshot.GetText();
                var first      = (text[position - 1] == ' ')
                                ? position
                                : text.Substring(0, position).LastIndexOfAny(separators);

                return(currentSnapshot.CreateTrackingSpan(first, position - first, SpanTrackingMode.EdgeInclusive));
            }
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
            var line = position.GetContainingLine();

            if (line == null)
                return;

            string text = line.GetText();
            var linePosition = position - line.Start;

            foreach (var source in completionSources)
            {
                var span = source.GetInvocationSpan(text, linePosition, position);
                if (span == null) continue;

                var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(span.Value.Start + line.Start, span.Value.Length, SpanTrackingMode.EdgeInclusive);
                completionSets.Add(new StringCompletionSet(
                    source.GetType().Name,
                    trackingSpan,
                    source.GetEntries(quoteChar: text[span.Value.Start], caret: session.TextView.Caret.Position.BufferPosition)
                ));
            }
            // TODO: Merge & resort all sets?  Will StringCompletionSource handle other entries?
            //completionSets.SelectMany(s => s.Completions).OrderBy(c=>c.DisplayText.TrimStart('"','\''))
        }
Exemplo n.º 38
0
        protected virtual void UpdateDefaultCompletionSet(ICompletionSession session,
                                                          IList <CompletionSet> completionSets,
                                                          IEnumerable <
                                                              Microsoft.VisualStudio.Language.Intellisense.
                                                              Completion> completions)
        {
            const string DefaultCompletionSetName = "Default";

            if (completionSets.Count == 0 ||
                !completionSets.Any(item => item.DisplayName == DefaultCompletionSetName))
            {
                var completionSet = new CompletionSet(
                    DefaultCompletionSetName,
                    //the non-localized title of the tab
                    DefaultCompletionSetName,
                    //the display title of the tab
                    FindTokenSpanAtPosition(session.GetTriggerPoint(Buffer), session),
                    completions,
                    null);
                completionSets.Add(completionSet);
            }
            else
            {
                CompletionSet completionSet =
                    completionSets.Where(item => item.DisplayName == DefaultCompletionSetName).First();
                completionSets.Remove(completionSet);
                List <Microsoft.VisualStudio.Language.Intellisense.Completion> allCompletions =
                    completions.Union(completionSet.Completions).ToList();
                UpdateDefaultCompletionSet(session, completionSets, allCompletions);
            }
        }
Exemplo n.º 39
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(nameof(GlslCompletionSource));
            }

            var snapshot     = currentBuffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            var completions     = new List <Completion>();
            var startToPosition = new Span(0, triggerPoint.Position);

            foreach (var identifier in queryIdentifiers.Invoke(new SnapshotSpan(snapshot, startToPosition)))
            {
                completions.Add(NewCompletion(identifier, imgIdentifier));
            }
            completions.AddRange(staticCompletions);

            var start        = NonIdentifierPositionBefore(triggerPoint);
            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty <Completion>()));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (disposed)
                return;

            ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
            SnapshotPoint? triggerPoint = session.GetTriggerPoint(snapshot);
            if (triggerPoint == null)
                return;

            int position = triggerPoint.Value.Position;

            CompletionContext context;
            var completionProviders = CompletionEngine.GetCompletionProviders(session, textBuffer, triggerPoint.Value, navigator, out context).ToList();
            if (completionProviders.Count == 0 || context == null)
                return;

            var completions = new List<Completion>();

            foreach (ICompletionListProvider completionListProvider in completionProviders)
                completions.AddRange(completionListProvider.GetCompletionEntries(context));

            if (completions.Count == 0)
                return;

            ITrackingSpan trackingSpan =
                textBuffer.CurrentSnapshot.CreateTrackingSpan(
                    position <= context.SpanStart || position > context.SpanStart + context.SpanLength
                        ? new Span(position, 0)
                        : new Span(context.SpanStart, context.SpanLength), SpanTrackingMode.EdgeInclusive);

            CompletionSet completionSet = new CompletionSet("PaketCompletion", "Paket", trackingSpan, completions, Enumerable.Empty<Completion>());

            completionSets.Add(completionSet);
        }
Exemplo n.º 41
0
    void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
    {
      var fileModel = VsUtils.TryGetFileModel(_textBuffer);

      if (fileModel == null)
        return;

      var client  = fileModel.Server.Client;
      var triggerPoint = session.GetTriggerPoint(_textBuffer);
      var snapshot = _textBuffer.CurrentSnapshot;
      var version = snapshot.Version.Convert();

      client.Send(new ClientMessage.CompleteWord(fileModel.Id, version, triggerPoint.GetPoint(snapshot).Position));
      var result = client.Receive<ServerMessage.CompleteWord>();
      var span = result.replacementSpan;
      var applicableTo = snapshot.CreateTrackingSpan(new Span(span.StartPos, span.Length), SpanTrackingMode.EdgeInclusive);

      var completions = new List<Completion>();

      CompletionElem.Literal literal;
      CompletionElem.Symbol  symbol;

      foreach (var elem in result.completionList)
      {
        if ((literal = elem as CompletionElem.Literal) != null)
          completions.Add(new Completion(literal.text, literal.text, "literal", null, null));
        else if ((symbol = elem as CompletionElem.Symbol) != null)
          completions.Add(new Completion(symbol.name, symbol.name, symbol.description, null, null));
      }

      completionSets.Add(new CompletionSet("NitraWordCompletion", "Nitra word completion", applicableTo, completions, null));
    }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
            var line = position.GetContainingLine();
            if (line == null) return;

            int linePos = position - line.Start.Position;

            var info = NodeModuleCompletionUtils.FindCompletionInfo(line.GetText(), linePos);
            if (info == null) return;

            var callingFilename = _buffer.GetFileName();
            var baseFolder = Path.GetDirectoryName(callingFilename);

            IEnumerable<Intel.Completion> results;
            if (String.IsNullOrWhiteSpace(info.Item1))
                results = GetRootCompletions(baseFolder);
            else
                results = GetRelativeCompletions(NodeModuleService.ResolvePath(baseFolder, info.Item1));

            var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(info.Item2.Start + line.Start, info.Item2.Length, SpanTrackingMode.EdgeInclusive);
            completionSets.Add(new CompletionSet(
                "Node.js Modules",
                "Node.js Modules",
                trackingSpan,
                results,
                null
            ));
        }
Exemplo n.º 43
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            _completionSession = session;
            var textBuffer = _textBuffer;

            if (_provider._PublicFunctionProvider != null)
            {
                _provider._PublicFunctionProvider.SetFilename(textBuffer.GetFilePath());
            }
            if (_provider._DatabaseInfoProvider != null)
            {
                _provider._DatabaseInfoProvider.SetFilename(textBuffer.GetFilePath());
            }

            var span         = session.GetApplicableSpan(textBuffer);
            var triggerPoint = session.GetTriggerPoint(textBuffer);
            var options      = session.GetOptions();
            var provider     = textBuffer.CurrentSnapshot.GetCompletions(span, triggerPoint, options, _provider._PublicFunctionProvider, _provider._DatabaseInfoProvider, _provider._ProgramFileProvider);

            provider.GlyphService = _provider._glyphService;
            var completions = provider.GetCompletions(_provider._glyphService);

            if (completions == null || completions.Completions.Count == 0)
            {
                return;
            }
            completionSets.Add(completions);
        }
Exemplo n.º 44
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("GherkinStepCompletionSource");
            }

            ITextSnapshot snapshot     = textBuffer.CurrentSnapshot;
            var           triggerPoint = session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            ScenarioBlock?scenarioBlock = GetCurrentScenarioBlock(triggerPoint.Value);

            if (scenarioBlock == null)
            {
                return;
            }

            IEnumerable <Completion> completions  = GetCompletionsForBlock(scenarioBlock.Value);
            ITrackingSpan            applicableTo = GetApplicableToSpan(snapshot, triggerPoint.Value);

            string displayName = string.Format("All {0} Steps", scenarioBlock);

            completionSets.Add(
                new CompletionSet(
                    displayName,
                    displayName,
                    applicableTo,
                    completions,
                    null));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("DaxCompletionSource");
            }

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            var completion = _completionDataProvider.GetCompletionDataSnapshot().GetCompletionData(_completionIconSource);

            completionSets.Add(new CompletionSet("All", "All", applicableTo, completion, Enumerable.Empty <Completion>()));
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("OokCompletionSource");
            }

            List <Completion> completions = new List <Completion>()
            {
                new Completion("Ook!"),
                new Completion("Ook."),
                new Completion("Ook?")
            };

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty <Completion>()));
        }
Exemplo n.º 47
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            Guid guid = Guid.NewGuid();

            var compList = new List <Completion>();

            if (this.vb)
            {
                compList.Add(new Completion("GuidA", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.GuidAttributeWithAngleBrackets), "A GUID formatted as a VB GuidAttribute.", null, null));
                compList.Add(new Completion("GuidB", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.RegistryFormat), "A GUID formatted in the human-readable (registry) format.", null, null));
                compList.Add(new Completion("GuidF", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.VBFieldFieldDefinition), "A VB definition of a field containing a GUID.", null, null));
            }
            else
            {
                compList.Add(new Completion("GuidA", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.GuidAttributeWithBrackets), "A GUID formatted as a C# GuidAttribute.", null, null));
                compList.Add(new Completion("GuidB", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.RegistryFormat), "A GUID formatted in the human-readable (registry) format.", null, null));
                compList.Add(new Completion("GuidF", GuidCodeSnippetFormatter.GetCodeSnippet(guid, CodeSnippetFormat.CSharpFieldDefinition), "A C# definition of a field containing a GUID.", null, null));
            }

            completionSets.Add(new CompletionSet(
                                   "Guids", //the non-localized title of the tab
                                   "Guids", //the display title of the tab
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session),
                                   compList,
                                   null));
        }
Exemplo n.º 48
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                throw new ObjectDisposedException("LuaCompletionSource");
         
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            var word = start;
            word -= 1;
            var ch = word.GetChar();

            List<Completion> completions = new List<Completion>();

            while (word > line.Start && (word - 1).GetChar().IsWordOrDot())
            {
                word -= 1;
            }

            if (ch == '.' || ch == ':')
            {
                String w = snapshot.GetText(word.Position, start - 1 - word);
                if (!FillTable(w, ch, completions)) return;
            }
            else
            {
                char front = word > line.Start ? (word - 1).GetChar() : char.MinValue;
                if (front == '.' || front == ':')
                {
                    int loc = (word - 1).Position;
                    while (loc > 0 && snapshot[loc - 1].IsWordOrDot()) loc--;
                    int len = word - 1 - loc;
                    if (len <= 0) return;
                    string w = snapshot.GetText(loc, len);
                    if (!FillTable(w, front, completions)) return;
                }
                else
                {
                    String w = snapshot.GetText(word.Position, start - word);
                    if (!FillWord(w, completions)) return;
                }
            }

            if (ch != '.' && ch != ':')
            {
                start = word;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
            var cs = new LuaCompletionSet("All", "All", applicableTo, completions, null);
            completionSets.Add(cs);
        }
Exemplo n.º 49
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                throw new ObjectDisposedException("OokCompletionSource");

            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            while (start > line.Start && !char.IsWhiteSpace((start - 1).GetChar()))
            {
                start -= 1;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
            var text = applicableTo.GetText(snapshot);

            //IntPtr retVal = GetFunction("vector.jet", line.LineNumber + 1);
            //string retValStr = Marshal.PtrToStringAnsi(retVal);

            List<Completion> completions = new List<Completion>()
            {
                //new Completion(retValStr),
                //new Completion("Ook!"),
                //new Completion("Ook."),
                //new Completion("Ook?", "Ook?", "", glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupEnum, StandardGlyphItem.GlyphItemPublic), "Ook?")
            };
            //need to somehow pass the filename
            var path = GetFilePath(this._buffer);
            var name = Path.GetFileName(path);
            // var name = path.GetFileName();
            IntPtr retVal2 = GetAutoCompletes(path, name, line.LineNumber + 1);
            string retValStr2 = Marshal.PtrToStringAnsi(retVal2);

            //append a char that identifies the type info
            string[] suggestions = retValStr2.Split('/');
            for (int i = 0; i < suggestions.Length; i++)
            {
                var str = suggestions[i];
                if (str != "/" && str.Length > 0)
                {
                    string sname = str.Substring(0, str.Length - 1);
                    string desc = suggestions[++i];
                    completions.Add(new Completion(sname, sname, desc, GetGlyphForCode(str[str.Length - 1]), sname));
                }
            }

            //refine here
            completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty<Completion>()));
        }
Exemplo n.º 50
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
            TemplateProjectionBuffer projBuffer;
            if (_textBuffer.Properties.TryGetProperty<TemplateProjectionBuffer>(typeof(TemplateProjectionBuffer), out projBuffer)) {
                var completions = new List<DynamicallyVisibleCompletion>();
                foreach (var tag in _htmlTags) {
                    completions.Add(new DynamicallyVisibleCompletion(
                        tag,
                        tag,
                        "",
                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                        "")
                    );
                }
                foreach (var tag in _htmlTags) {
                    completions.Add(new DynamicallyVisibleCompletion(
                        "/" + tag,
                        "/" + tag,
                        "",
                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                        "")
                    );
                }

                //
                var triggerPoint = session.GetTriggerPoint(_textBuffer);
                var point = triggerPoint.GetPoint(_textBuffer.CurrentSnapshot);

                var match = projBuffer.BufferGraph.MapUpToFirstMatch(
                    point,
                    PointTrackingMode.Positive,
                    x => x.TextBuffer != _textBuffer,
                    PositionAffinity.Predecessor
                );
                
                if (match == null ||
                    !match.Value.Snapshot.TextBuffer.ContentType.IsOfType(TemplateContentType.ContentTypeName)) {

                    var line = point.GetContainingLine();
                    var text = line.GetText();
                    int position = point.Position;
                    for (int i = position - line.Start.Position - 1; i >= 0 && i < text.Length; --i, --position) {
                        char c = text[i];
                        if (!char.IsLetterOrDigit(c) && c != '!') {
                            break;
                        }
                    }

                    var span = _textBuffer.CurrentSnapshot.CreateTrackingSpan(position, point.Position - position, SpanTrackingMode.EdgeInclusive);

                    completionSets.Add(new FuzzyCompletionSet("PythonDjangoTemplateHtml", "HTML", span, completions, session.GetOptions(), CompletionComparer.UnderscoresLast));
                }
            }
        }
Exemplo n.º 51
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                throw new ObjectDisposedException("LuaCompletionSource");

            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            var word = start;
            word -= 1;
            var ch = word.GetChar();

            List<Completion> completions = new List<Completion>();

            if (ch == '.' || ch == ':' || ch == '_') //for table search
            {
                while (word > line.Start && Help.is_word_char((word - 1).GetChar()))
                {
                    word -= 1;
                }
                String w = snapshot.GetText(word.Position,start - 1 - word);
                if (ch == '_')
                {
                    if (!FillWord(w+"_",completions))
                        return;
                }
                else
                {
                    if (!FillTable(w,ch,completions))
                        return;
                }
            }
            else
                return;
            if (ch == '_')
            {
                while (start > line.Start && Help.is_word_char((start - 1).GetChar()))
                {
                    start -= 1;
                }
            }
            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
            var cs = new CompletionSet("All", "All", applicableTo, completions, null);
            completionSets.Add(cs);
            //session.SelectedCompletionSet = cs;
        }
Exemplo n.º 52
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
            var textBuffer = _textBuffer;
            var span = session.GetApplicableSpan(textBuffer);
            var triggerPoint = session.GetTriggerPoint(textBuffer);
            var options = session.GetOptions(_provider._serviceProvider);
            var provider = textBuffer.CurrentSnapshot.GetCompletions(_provider._serviceProvider, span, triggerPoint, options);

            var completions = provider.GetCompletions(_provider._glyphService);
           
            if (completions != null && completions.Completions.Count > 0) {
                completionSets.Add(completions);
            }
        }
Exemplo n.º 53
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (disposed)
                throw new ObjectDisposedException("GherkinStepCompletionSource");

            ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(snapshot);
            if (triggerPoint == null)
                return;

            if (IsKeywordCompletion(triggerPoint.Value))
            {
                IEnumerable<Completion> completions = GetKeywordCompletions();
                ITrackingSpan applicableTo = GetApplicableToForKeyword(snapshot, triggerPoint.Value);

                completionSets.Add(
                    new CustomCompletionSet(
                        "Keywords",
                        "Keywords",
                        applicableTo,
                        completions,
                        null));
            }
            else
            {
                string parsedKeyword;
                var bindingType = GetCurrentBindingType(triggerPoint.Value, out parsedKeyword);
                if (bindingType == null)
                    return;

                IEnumerable<Completion> completions;
                string statusText;
                GetCompletionsForBindingType(bindingType.Value, out completions, out statusText);

                ITrackingSpan applicableTo = GetApplicableToForStep(snapshot, triggerPoint.Value, parsedKeyword);

                string displayName = string.Format("All {0} Steps", bindingType.Value);
                var completionSet = new HierarchicalCompletionSet(
                    displayName, 
                    displayName, 
                    applicableTo, 
                    completions, 
                    null);

                if (!string.IsNullOrEmpty(statusText))
                    completionSet.StatusText = statusText;
                completionSets.Add(completionSet);
            }
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var compList = new List<Completion>();
            //var completion = new Completion("Test", "Test Insertion", "Test Description", null, null);
            var completion = new TestCompletion("Test", session);

            compList.Add(completion);

            completionSets.Add(new CompletionSet(
                "Test",    //the non-localized title of the tab
                "Test",    //the displaytitle of the tab
                FindTokenSpanAtPosition(session.GetTriggerPoint(_textBuffer), session),
                compList,
                null));
        }
Exemplo n.º 55
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            _triggerPoint = session.GetTriggerPoint(_textBuffer).GetPoint(_textBuffer.CurrentSnapshot);

            if (!session.Properties.TryGetProperty(typeof(ITrackingSpan), out _trackingSpan))
                _trackingSpan = _triggerPoint.Snapshot.CreateTrackingSpan(new Span(_triggerPoint, 0), SpanTrackingMode.EdgeInclusive);

            var syntax = new SparkSyntax();
            Node currentNode = syntax.ParseNode(_textBuffer.CurrentSnapshot.GetText(), _triggerPoint);
            CompletionSet sparkCompletions = GetCompletionSetFor(currentNode);
            if (sparkCompletions == null) return;

            MergeSparkWithAllCompletionsSet(completionSets, sparkCompletions);
            completionSets.Add(sparkCompletions);
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            List<string> elList = new List<string> { ".NET", ".COM", "Microsoft", "PacktPub", "Visual Studio", "Managed Extensibility Framework",
                "Windows Presentation Foundation", "Packt Publications"};
            lstCompletion = new List<Completion>();
            foreach (string el in elList)
                lstCompletion.Add(new Completion(el, el, el, null, null));

            completionSets.Add(new CompletionSet(
                "Tokens",
                "Tokens",
                FindTokenSpanAtPosition(session.GetTriggerPoint(txtBuffer), session),
                lstCompletion,
                null));
        }
Exemplo n.º 57
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var triggerPoint = session.GetTriggerPoint(_textBuffer).GetPoint(_textBuffer.CurrentSnapshot);

            if (!session.Properties.TryGetProperty(typeof(ITrackingSpan), out _trackingSpan))
                _trackingSpan = triggerPoint.Snapshot.CreateTrackingSpan(new Span(triggerPoint, 0), SpanTrackingMode.EdgeInclusive);

            CompletionSet sparkCompletions = CompletionSetFactory.GetCompletionSetFor(triggerPoint, _trackingSpan, _viewExplorer);
            if (sparkCompletions == null) return;

            MergeSparkWithAllCompletionsSet(completionSets, sparkCompletions);
            completionSets.Add(sparkCompletions);

            session.Committed += session_Committed;
        }
Exemplo n.º 58
0
        public void AugmentCompletionSession(ICompletionSession session, IList<VSCompletionSet> completionSets)
        {
            CompletionContext context;
            if (!session.Properties.TryGetProperty<CompletionContext>(typeof(CompletionContext), out context))
                return;

            SnapshotPoint point = session.GetTriggerPoint(textBuffer).GetPoint(textBuffer.CurrentSnapshot);

            CompletionSet set = CreateCompletionSet(context, point);

            if (set == null)
                return;

            completionSets.Add(set);
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            PhpProjectionBuffer projBuffer;
            if (_textBuffer.Properties.TryGetProperty<PhpProjectionBuffer>(typeof(PhpProjectionBuffer), out projBuffer))
            {
                List<Completion> completions = new List<Completion>();
                foreach (var tag in _htmlTags)
                {
                    completions.Add(new Completion(
                        tag,
                        tag,
                        "",
                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                        "")
                    );
                }
                foreach (var tag in _htmlTags)
                {
                    completions.Add(new Completion(
                        "/" + tag,
                        "/" + tag + ">",
                        "",
                        _completionSourceProvider._glyphService.GetGlyph(StandardGlyphGroup.GlyphXmlItem, StandardGlyphItem.GlyphItemPublic),
                        "")
                    );
                }

                //
                var triggerPoint = session.GetTriggerPoint(_textBuffer);

                var position = triggerPoint.GetPosition(_textBuffer.CurrentSnapshot);

                var span = _textBuffer.CurrentSnapshot.CreateTrackingSpan(position, 0, SpanTrackingMode.EdgeInclusive);

                var match = projBuffer.BufferGraph.MapUpToFirstMatch(
                    new SnapshotPoint(_textBuffer.CurrentSnapshot, position),
                    PointTrackingMode.Positive,
                    x => x.TextBuffer != _textBuffer,
                    PositionAffinity.Predecessor
                );

                if (match == null ||
                    !match.Value.Snapshot.TextBuffer.ContentType.IsOfType(PhpConstants.PhpContentType))
                {
                    completionSets.Add(new HtmlCompletionSet("", "", span, completions, new Completion[0]));
                }
            }
        }
Exemplo n.º 60
0
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            GetWords(NLAConfiguration.DataLocation);

             bool isUpperCase;
             var span = FindTokenSpanAtPosition(session.GetTriggerPoint(textBuffer), session, out isUpperCase);
             if (span != null)
             {
            completionSets.Add(new CompletionSet(
              "Tokens",    //the non-localized title of the tab
              "Tokens",    //the display title of the tab
              span,
              isUpperCase ? compListUppercase : compList,
              null));
             }
        }