public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches = placeholderRe.Matches(text);
                foreach (Match match in matches)
                {
                    ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder);
                }
            }

            var editorLine = stepSpan.StartPosition.Line;
            var tags       = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepScope  = new StepScopeNew(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray());

            currentStep = new GherkinStep((BindingType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepScope, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);
        }
Example #2
0
 public StepInstance(ScenarioStep step, StepScopeNew stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory, int level = 1)
     : base((BindingType)step.ScenarioBlock, (StepDefinitionKeyword)step.StepKeyword, step.Keyword, step.Text, stepScope)
 {
     this.NativeSuggestionItem = nativeSuggestionItemFactory.Create(step.Text, GetInsertionText(step), level, BindingType.ToString().Substring(0, 1), this);
 }
Example #3
0
        public StepInstanceTemplate(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, StepScopeNew stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory)
        {
            BindingType = (BindingType)scenarioStep.ScenarioBlock;

            NativeSuggestionItem = nativeSuggestionItemFactory.Create(scenarioStep.Text, StepInstance <TNativeSuggestionItem> .GetInsertionText(scenarioStep), 1, BindingType.ToString().Substring(0, 1) + "-t", this);
            instances            = new StepSuggestionList <TNativeSuggestionItem>(nativeSuggestionItemFactory);
            AddInstances(scenarioStep, scenarioOutline, stepScope, nativeSuggestionItemFactory);

            var match = paramRe.Match(scenarioStep.Text);

            StepPrefix = match.Success ? scenarioStep.Text.Substring(0, match.Index) : scenarioStep.Text;
        }
Example #4
0
 public GherkinStep(BindingType bindingType, StepDefinitionKeyword stepDefinitionKeyword, string stepText, StepScopeNew stepScope, string keyword, int blockRelativeLine)
     : base(bindingType, stepDefinitionKeyword, keyword, stepText, stepScope)
 {
     BlockRelativeLine = blockRelativeLine;
     BindingStatus     = BindingStatus.UnknownBindingStatus;
 }
Example #5
0
        private void AddInstances(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, StepScopeNew stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory)
        {
            foreach (var exampleSet in scenarioOutline.Examples.ExampleSets)
            {
                foreach (var row in exampleSet.Table.Body)
                {
                    var replacedText = paramRe.Replace(scenarioStep.Text,
                                                       match =>
                    {
                        string param    = match.Groups["param"].Value;
                        int headerIndex = Array.FindIndex(exampleSet.Table.Header.Cells, c => c.Value.Equals(param));
                        if (headerIndex < 0)
                        {
                            return(match.Value);
                        }
                        return(row.Cells[headerIndex].Value);
                    });

                    var newStep = scenarioStep.Clone();
                    newStep.Text = replacedText;
                    instances.Add(new StepInstance <TNativeSuggestionItem>(newStep, stepScope, nativeSuggestionItemFactory, 2)
                    {
                        ParentTemplate = this
                    });
                }
            }
        }