Skip to content

Commit

Permalink
Fix issue when resolving test associated to a scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Socolin committed Dec 10, 2023
1 parent 20d3821 commit c864253
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.23.4
- Fix issue when resolving test associated to a scenario

## 1.23.3
- Fix issue when resolving step. The cache was depending on another cache not ready yet.

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ org.gradle.jvmargs=-Xmx2g
DotnetPluginId=ReSharperPlugin.SpecflowRiderPlugin
DotnetSolution=SpecflowRiderPlugin.sln
RiderPluginId=specflowriderplugin
PluginVersion=1.23.3
PluginVersion=1.23.4

BuildConfiguration=Release
BuildConfiguration=Debug
# Possible values:
# 2019.2-SNAPSHOT
# 2019.2-EAP2-SNAPSHOT
Expand All @@ -20,4 +20,4 @@ ProductVersion=2023.3-RC1-SNAPSHOT
# https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-released/#stdlib-default
kotlin.stdlib.default.dependency=false
# see: https://jb.gg/intellij-platform-kotlin-oom
kotlin.incremental.useClasspathSnapshot=false
kotlin.incremental.useClasspathSnapshot=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
using System.Collections.Generic;
using System.Text;
using JetBrains.Util;

namespace ReSharperPlugin.SpecflowRiderPlugin.UnitTestExplorers;

public static class NamespaceHelper
{
public static void ConvertFolderNameToToIdentifierPart(string name, StringBuilder sb)
{
var lastIsSeparator = true;
if (name.Length > 0 && name[0].IsDigitFast())
sb.Append('_');

foreach (var c in name)
{
switch (c)
{
case '\'':
case '"':
case ' ':
case '\t':
lastIsSeparator = true;
break;
case '-':
case '.':
case '_':
lastIsSeparator = true;
sb.Append('_');
break;
default:
if (!c.IsIdentifierPart() && accentReplacements.TryGetValue(c, out var replacement))
{
if (lastIsSeparator)
{
lastIsSeparator = false;
sb.Append(replacement.Capitalize());
}
else
sb.Append(replacement);
}
else
{
if (lastIsSeparator)
{
lastIsSeparator = false;
sb.Append(c.ToUpperFast());
}
else
sb.Append(c);
}
break;
}

}
}

private static readonly Dictionary<char, string> accentReplacements = new()
{
{'\u00C0', "A"},
{'\u00C1', "A"},
{'\u00C2', "A"},
{'\u00C3', "A"},
{'\u00C4', "A"},
{'\u00C5', "A"},
{'\u00C6', "AE"},
{'\u00C7', "C"},
{'\u00C8', "E"},
{'\u00C9', "E"},
{'\u00CA', "E"},
{'\u00CB', "E"},
{'\u00CC', "I"},
{'\u00CD', "I"},
{'\u00CE', "I"},
{'\u00CF', "I"},
{'\u00D0', "D"},
{'\u00D1', "N"},
{'\u00D2', "O"},
{'\u00D3', "O"},
{'\u00D4', "O"},
{'\u00D5', "O"},
{'\u00D6', "O"},
{'\u00D8', "O"},
{'\u00D9', "U"},
{'\u00DA', "U"},
{'\u00DB', "U"},
{'\u00DC', "U"},
{'\u00DD', "Y"},
{'\u00DF', "B"},
{'\u00E0', "a"},
{'\u00E1', "a"},
{'\u00E2', "a"},
{'\u00E3', "a"},
{'\u00E4', "a"},
{'\u00E5', "a"},
{'\u00E6', "ae"},
{'\u00E7', "c"},
{'\u00E8', "e"},
{'\u00E9', "e"},
{'\u00EA', "e"},
{'\u00EB', "e"},
{'\u00EC', "i"},
{'\u00ED', "i"},
{'\u00EE', "i"},
{'\u00EF', "i"},
//{'\u00F0', "d"},
{'\u00F1', "n"},
{'\u00F2', "o"},
{'\u00F3', "o"},
{'\u00F4', "o"},
{'\u00F5', "o"},
{'\u00F6', "o"},
{'\u00F8', "o"},
{'\u00F9', "u"},
{'\u00FA', "u"},
{'\u00FB', "u"},
{'\u00FC', "u"},
{'\u00FD', "y"},
{'\u00FF', "y"},


{'\u0104', "A"},
{'\u0141', "L"},
{'\u013D', "L"},
{'\u015A', "S"},
{'\u0160', "S"},
{'\u015E', "S"},
{'\u0164', "T"},
{'\u0179', "Z"},
{'\u017D', "Z"},
{'\u017B', "Z"},
{'\u0105', "a"},
{'\u0142', "l"},
{'\u013E', "l"},
{'\u015B', "s"},
{'\u0161', "s"},
{'\u015F', "s"},
{'\u0165', "t"},
{'\u017A', "z"},
{'\u017E', "z"},
{'\u017C', "z"},
{'\u0154', "R"},
{'\u0102', "A"},
{'\u0139', "L"},
{'\u0106', "C"},
{'\u010C', "C"},
{'\u0118', "E"},
{'\u011A', "E"},
{'\u010E', "D"},
{'\u0110', "D"},
{'\u0143', "N"},
{'\u0147', "N"},
{'\u0150', "O"},
{'\u0158', "R"},
{'\u016E', "U"},
{'\u0170', "U"},
{'\u0162', "T"},
{'\u0155', "r"},
{'\u0103', "a"},
{'\u013A', "l"},
{'\u0107', "c"},
{'\u010D', "c"},
{'\u0119', "e"},
{'\u011B', "e"},
{'\u010F', "d"},
{'\u0111', "d"},
{'\u0144', "n"},
{'\u0148', "n"},
{'\u0151', "o"},
{'\u0159', "r"},
{'\u016F', "u"},
{'\u0171', "u"},
{'\u0163', "t"},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using JetBrains.Diagnostics;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.JavaScript.Util.Literals;
using JetBrains.ReSharper.Psi.Tree;
using JetBrains.ReSharper.UnitTestFramework.Criteria;
using JetBrains.ReSharper.UnitTestFramework.Elements;
using JetBrains.ReSharper.UnitTestFramework.Persistence;
using JetBrains.Util;
using ReSharperPlugin.SpecflowRiderPlugin.Psi;
using TechTalk.SpecFlow.Tracing;

Expand Down Expand Up @@ -42,7 +44,7 @@ private static string GetGeneratedNamespace(GherkinFile gherkinFile)
{
if (projectItem is IProjectFolder projectFolder)
{
sb.Append(projectFolder.Name);
NamespaceHelper.ConvertFolderNameToToIdentifierPart(projectFolder.Name, sb);
sb.Append('.');
}
}
Expand All @@ -56,4 +58,4 @@ private static string GetGeneratedClassName(GherkinFile gherkinFile)
return $"{gherkinFile.GetFeatures().FirstOrDefault()?.GetFeatureText()?.ToIdentifier()}Feature";
}
}
}
}

0 comments on commit c864253

Please sign in to comment.