From e221b186acd80528033033a7a21251e6f5691c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20Nagy?= Date: Thu, 29 Aug 2024 14:47:13 +0200 Subject: [PATCH] Offer language updates of Gherkin v29 in the editor (updated from Gherkin v22) (#33) (#34) --- CHANGELOG.md | 6 ++++-- Reqnroll.VisualStudio.sln.DotSettings | 3 ++- .../Editor/Services/Parser/DeveroomGherkinAstBuilder.cs | 4 ++-- .../Editor/Services/Parser/DeveroomGherkinStep.cs | 4 ++-- Reqnroll.VisualStudio/Reqnroll.VisualStudio.csproj | 2 +- .../Discovery/ProjectBindingRegistryTestsBase.cs | 4 +++- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5db4df8..244756bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,16 @@ # [vNext] -* Fix: GH28: Define Steps produces incorrect regex for step definition + ## Improvements: * Find Unused Step Definitions Command: Improved handling of Step Definitions decorated with the 'StepDefinition' attribute. If a Step Definition is used in any Given/Then/When step in a Feature file, the step will no longer show in the 'Find Unused Step Definitions' context menu. (#24) * Detect existence of SpecFlow for Visual Studio extension and show a warning (#16) -* Extend searched config file locations to match the locations searched for the reqnroll runtime +* Extend searched config file locations to match the locations searched for the reqnroll runtime (#31) +* Offer language updates of Gherkin v29 in the editor (updated from Gherkin v22) (#33) ## Bug fixes: * Fix: Using the extension side-by-side with the SpecFlow for Visual Studio extension causes CompositionFailedException (#25) +* Fix: Define Steps produces incorrect regex for step definition (#28) *Contributors of this release (in alphabetical order):* @clrudolphi, @gasparnagy, @jdb0123, @UL-ChrisGlew diff --git a/Reqnroll.VisualStudio.sln.DotSettings b/Reqnroll.VisualStudio.sln.DotSettings index 346f4419..5eabefcf 100644 --- a/Reqnroll.VisualStudio.sln.DotSettings +++ b/Reqnroll.VisualStudio.sln.DotSettings @@ -1,3 +1,4 @@  ID - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinAstBuilder.cs b/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinAstBuilder.cs index 2f8255bc..82ae853b 100644 --- a/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinAstBuilder.cs +++ b/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinAstBuilder.cs @@ -52,14 +52,14 @@ private static StepKeyword GetStepKeyword(GherkinDialect dialect, string stepKey return StepKeyword.And; } - protected override Step CreateStep(Location location, string keyword, string text, StepArgument argument, + protected override Step CreateStep(Location location, string keyword, StepKeywordType keywordType, string text, StepArgument argument, AstNode node) { var token = node.GetToken(TokenType.StepLine); var stepKeyword = GetStepKeyword(token.MatchedGherkinDialect, keyword); _scenarioBlock = stepKeyword.ToScenarioBlock() ?? _scenarioBlock; - return new DeveroomGherkinStep(location, keyword, text, argument, stepKeyword, _scenarioBlock); + return new DeveroomGherkinStep(location, keyword, keywordType, text, argument, stepKeyword, _scenarioBlock); } private void ResetBlock() diff --git a/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinStep.cs b/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinStep.cs index 38d0b2e3..2b4b5a16 100644 --- a/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinStep.cs +++ b/Reqnroll.VisualStudio/Editor/Services/Parser/DeveroomGherkinStep.cs @@ -4,8 +4,8 @@ namespace Reqnroll.VisualStudio.Editor.Services.Parser; public class DeveroomGherkinStep : Step { - public DeveroomGherkinStep(Location location, string keyword, string text, StepArgument argument, - StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument) + public DeveroomGherkinStep(Location location, string keyword, StepKeywordType keywordType, string text, StepArgument argument, + StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, keywordType, text, argument) { StepKeyword = stepKeyword; ScenarioBlock = scenarioBlock; diff --git a/Reqnroll.VisualStudio/Reqnroll.VisualStudio.csproj b/Reqnroll.VisualStudio/Reqnroll.VisualStudio.csproj index 9f28b5a6..656d3394 100644 --- a/Reqnroll.VisualStudio/Reqnroll.VisualStudio.csproj +++ b/Reqnroll.VisualStudio/Reqnroll.VisualStudio.csproj @@ -12,7 +12,7 @@ - + diff --git a/Tests/Reqnroll.VisualStudio.Tests/Discovery/ProjectBindingRegistryTestsBase.cs b/Tests/Reqnroll.VisualStudio.Tests/Discovery/ProjectBindingRegistryTestsBase.cs index b5b32881..18789e39 100644 --- a/Tests/Reqnroll.VisualStudio.Tests/Discovery/ProjectBindingRegistryTestsBase.cs +++ b/Tests/Reqnroll.VisualStudio.Tests/Discovery/ProjectBindingRegistryTestsBase.cs @@ -1,4 +1,6 @@ #nullable disable +using Gherkin; + namespace Reqnroll.VisualStudio.Tests.Discovery; public abstract class ProjectBindingRegistryTestsBase @@ -14,7 +16,7 @@ protected ProjectBindingRegistry CreateSut() } protected Step CreateStep(StepKeyword stepKeyword = StepKeyword.Given, string text = "my step", - StepArgument stepArgument = null) => new DeveroomGherkinStep(null, stepKeyword + " ", text, stepArgument, + StepArgument stepArgument = null) => new DeveroomGherkinStep(null, stepKeyword + " ", StepKeywordType.Context, text, stepArgument, stepKeyword, (ScenarioBlock) stepKeyword); protected ProjectStepDefinitionBinding CreateStepDefinitionBinding(string regex,