Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }