Пример #1
0
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            // RaringCoder: "Examples:" can occur in-line in a scenario block, so we have to check here to see if a
            //              table from a prior step needs creating.
            CheckTableOutline();

            var editorLine = headerSpan.StartPosition.Line;

            OnCloseLevel2Outlinings(CalculateRegionEndLine(editorLine));

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);

            ScenarioOutlineExampleSet exampleSet = new ScenarioOutlineExampleSet(keyword, name,
                                                                                 editorLine - CurrentFileBlockBuilder.KeywordLine);

            CurrentFileBlockBuilder.ExampleSets.Add(exampleSet);
            currentStep = null;

            CloseLevel2Outlinings += regionEndLine =>
            {
                if (regionEndLine > editorLine)
                {
                    AddOutline(
                        editorLine,
                        regionEndLine,
                        exampleSet.FullTitle());
                }
            };
        }
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            var editorLine = headerSpan.StartPosition.Line;

            OnCloseLevel2Outlinings(CalculateRegionEndLine(editorLine));

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);

            ScenarioOutlineExampleSet exampleSet = new ScenarioOutlineExampleSet(keyword, name,
                                                                                 editorLine - CurrentFileBlockBuilder.KeywordLine);

            CurrentFileBlockBuilder.ExampleSets.Add(exampleSet);
            currentStep = null;

            CloseLevel2Outlinings += regionEndLine =>
            {
                if (regionEndLine > editorLine)
                {
                    AddOutline(
                        editorLine,
                        regionEndLine,
                        exampleSet.FullTitle());
                }
            };
        }
        public virtual void Background(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            NewBlock(headerSpan.StartPosition.Line);
            CurrentFileBlockBuilder.SetMainData(typeof(IBackgroundBlock), headerSpan.StartPosition.Line, keyword, name);
            currentStep = null;

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);
        }
 private void EnsureNewScenario(int editorLine)
 {
     if (CurrentFileBlockBuilder.IsComplete)
     {
         CloseBlock(editorLine);
         OnScenarioBlockCreating(editorLine);
         CreateBlock(editorLine);
         currentStep = null;
     }
 }
Пример #5
0
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            // RaringCoder: When a new step is created, we check to see if the previous step had a table, if so we outline it.
            CheckTableOutline();

            var editorLine  = stepSpan.StartPosition.Line;
            var tags        = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);

            var bindingMatchService = projectScope.BindingMatchService;

            if (enableStepMatchColoring && bindingMatchService != null && bindingMatchService.Ready)
            {
                List <BindingMatch>           candidatingMatches;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = projectScope.SpecFlowProjectConfiguration.RuntimeConfiguration.BindingCulture ?? currentStep.StepContext.Language;
                var         match          = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (match.Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
                    int linePos = stepSpan.StartPosition.LinePosition + keyword.Length;
                    foreach (var stringArg in match.Arguments.OfType <string>())
                    {
                        linePos = ColorizeLinePart(stringArg, stepSpan, classifications.StepArgument, linePos);
                    }
                }
                else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && placeholderRe.Match(text).Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); // we do not show binding errors in placeholdered scenario outline steps
                    //TODO: check match based on the scenario examples - unfortunately the steps are parsed earlier than the examples, so we would need to delay the colorization somehow
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.UnboundStepText);
                }
            }
            else
            {
                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);
                }
            }
        }
Пример #6
0
        private static GherkinStep GetSubstitutedStep(GherkinStep step, IDictionary <string, string> exampleDictionary)
        {
            var replacedText = paramRe.Replace(step.Text,
                                               match =>
            {
                string value;
                return(exampleDictionary.TryGetValue(match.Groups["param"].Value, out value) ? value : match.Value);
            });

            return(new GherkinStep(step.StepDefinitionType, step.StepDefinitionKeyword, replacedText, step.StepContext, step.Keyword, step.BlockRelativeLine));
        }
Пример #7
0
        public static GherkinStep GetSubstitutedStep(this GherkinStep step, IScenarioOutlineBlock scenarioOutlineBlock)
        {
            var firstNonEmptyExampleSet = scenarioOutlineBlock.ExampleSets.FirstOrDefault(es => es.ExamplesTable != null && es.ExamplesTable.RowCount > 0);

            if (firstNonEmptyExampleSet == null)
            {
                return(step);
            }

            return(GetSubstitutedStep(step, firstNonEmptyExampleSet.ExamplesTable.Rows.First()));
        }
        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);
        }
 private void EnsureNewScenario(int editorLine)
 {
     if (CurrentFileBlockBuilder.IsComplete)
     {
         CloseBlock(editorLine);
         OnScenarioBlockCreating(editorLine);
         CreateBlock(editorLine);
         currentStep = null;
     }
 }
        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 StepScope(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);
        }
        public void Examples(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            // RaringCoder: "Examples:" can occur in-line in a scenario block, so we have to check here to see if a 
            //              table from a prior step needs creating.
            CheckTableOutline();

            var editorLine = headerSpan.StartPosition.Line;
            OnCloseLevel2Outlinings(CalculateRegionEndLine(editorLine));

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);

            ScenarioOutlineExampleSet exampleSet = new ScenarioOutlineExampleSet(keyword, name, 
                editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.ExampleSets.Add(exampleSet);
            currentStep = null;

            CloseLevel2Outlinings += regionEndLine =>
                                         {
                                             if (regionEndLine > editorLine)
                                                 AddOutline(
                                                     editorLine,
                                                     regionEndLine,
                                                     exampleSet.FullTitle());
                                         };
        }
 private static bool IsListed(GherkinStep step, IStepDefinitionMatchService bindingMatchService, CultureInfo bindingCulture)
 {
     List<BindingMatch> candidatingMatches;
     StepDefinitionAmbiguityReason ambiguityReason;
     var match = bindingMatchService.GetBestMatch(step, bindingCulture, out ambiguityReason, out candidatingMatches);
     bool isListed = !match.Success;
     if (isListed && candidatingMatches.Count > 0)
     {
         isListed = ambiguityReason == StepDefinitionAmbiguityReason.AmbiguousScopes; // if it is already ambiguous (except scopes), we rather not list it
     }
     return isListed;
 }
Пример #13
0
 public static string FullTitle(this GherkinStep keywordLine)
 {
     return(keywordLine.Keyword + keywordLine.Text);
 }
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            // RaringCoder: When a new step is created, we check to see if the previous step had a table, if so we outline it.
            CheckTableOutline();

            var editorLine = stepSpan.StartPosition.Line;
            var tags = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);

            var bindingMatchService = projectScope.BindingMatchService;
            if (enableStepMatchColoring && bindingMatchService != null && bindingMatchService.Ready)
            {
                List<BindingMatch> candidatingMatches;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = projectScope.SpecFlowProjectConfiguration.RuntimeConfiguration.BindingCulture ?? currentStep.StepContext.Language;
                var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (match.Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
                    int linePos = stepSpan.StartPosition.LinePosition + keyword.Length;
                    foreach (var stringArg in match.Arguments.OfType<string>())
                    {
                        linePos = ColorizeLinePart(stringArg, stepSpan, classifications.StepArgument, linePos);
                    }
                }
                else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && placeholderRe.Match(text).Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); // we do not show binding errors in placeholdered scenario outline steps
                    //TODO: check match based on the scenario examples - unfortunately the steps are parsed earlier than the examples, so we would need to delay the colorization somehow
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.UnboundStepText);
                }
            }
            else
                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);
            }
        }
        public virtual void Background(string keyword, string name, string description, GherkinBufferSpan headerSpan, GherkinBufferSpan descriptionSpan)
        {
            NewBlock(headerSpan.StartPosition.Line);
            CurrentFileBlockBuilder.SetMainData(typeof(IBackgroundBlock), headerSpan.StartPosition.Line, keyword, name);
            currentStep = null;

            RegisterKeyword(keyword, headerSpan);
            ColorizeSpan(descriptionSpan, classifications.Description);
        }
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            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 stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);



            var bindingMatchService = projectScope.BindingMatchService;
         


            if (bindingMatchService.Ready && bindingMatchService != null)
            {
                List<BindingMatch> candidatingMatches;
                candidatingMatches = null;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = currentStep.StepContext.Language;
                var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (candidatingMatches.Count == 0)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.KnownStepText);
                    foreach (String value in candidatingMatches.First().StepBinding.Regex.Split(text))
                        ColorizeLinePart(value, stepSpan, classifications.Variable);
                }
                  

            
            }
            else
                ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

        }
Пример #17
0
 private static GherkinStep GetSubstitutedStep(GherkinStep step, IDictionary<string, string> exampleDictionary)
 {
     var replacedText = paramRe.Replace(step.Text,
                                        match =>
                                            {
                                                string value;
                                                return exampleDictionary.TryGetValue(match.Groups["param"].Value, out value) ? value : match.Value;
                                            });
     return new GherkinStep(step.StepDefinitionType, step.StepDefinitionKeyword, replacedText, step.StepContext, step.Keyword, step.BlockRelativeLine);
 }