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 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); } } //TODO: register step }
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); }
public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { 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.SpecFlowConfiguration.BindingCulture ?? currentStep.StepContext.Language; var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches); if (match.Success) { ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); var regexMatch = match.StepBinding.Regex.Match(text); if (regexMatch.Success) { var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine); foreach (Group matchGroup in regexMatch.Groups.Cast <Group>().Skip(1)) { var captures = matchGroup.Captures; var lastCapture = captures[captures.Count - 1]; var partStart = textStart + captures[0].Index; var partEnd = textStart + lastCapture.Index + lastCapture.Length; ColorizeLinePart(partStart, partEnd, stepSpan, classifications.StepArgument); } } else { // this should never happen } } 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); var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine); foreach (Match match in matches) { var capture = match.Groups[0].Captures[0]; var start = textStart + capture.Index; ColorizeLinePart(start, start + capture.Length, stepSpan, classifications.Placeholder); } } }