Skip to content

Commit

Permalink
Fix tests execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Socolin committed Mar 11, 2021
1 parent d5e3efe commit aae5ff4
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
using JetBrains.ReSharper.Psi.Files;
using JetBrains.RiderTutorials.Utils;
using JetBrains.Util;
using ReSharperPlugin.SpecflowRiderPlugin.Extensions;
using ReSharperPlugin.SpecflowRiderPlugin.Psi;

namespace ReSharperPlugin.SpecflowRiderPlugin.Caching.StepsUsages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Linq;
using JetBrains.Annotations;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using JetBrains.ReSharper.Psi.Files;
using JetBrains.ReSharper.Psi.Paths;
using JetBrains.Util;
Expand All @@ -10,6 +13,13 @@ namespace ReSharperPlugin.SpecflowRiderPlugin.Extensions
{
public static class ProjectExtensions
{
[CanBeNull]
public static ICSharpFile GetCSharpFile(this IProject project, string filename)
{
var sourceFileInProject = project.GetPsiSourceFileInProject(FileSystemPath.Parse(filename, FileSystemPathInternStrategy.INTERN));
return sourceFileInProject?.GetPsiFiles<CSharpLanguage>().SafeOfType<ICSharpFile>().SingleOrDefault<ICSharpFile>();
}

[CanBeNull]
public static GherkinFile GetGherkinFile(this IProject project, string filename)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using JetBrains.ReSharper.Psi.Tree;

namespace ReSharperPlugin.SpecflowRiderPlugin.Extensions
{
public static class TreeNodeExtensions
{
public static ITreeNode GetLastNodeInLine(this ITreeNode node)
{
while (node.NextSibling != null)
node = node.NextSibling;
return node;
}

public static IEnumerable<ITreeNode> GetChildrenInSubtrees(
[NotNull] this ITreeNode node)
{
if (node.FirstChild != null)
{
ITreeNode child;
for (child = node.FirstChild; child != null; child = child.NextSibling)
{
yield return child;
foreach (ITreeNode childrenInSubtree in child.GetChildrenInSubtrees())
yield return childrenInSubtree;
}
child = (ITreeNode) null;
}
}

public static IEnumerable<T> GetChildrenInSubtrees<T>([NotNull] this ITreeNode node) where T : class, ITreeNode
{
if (node.FirstChild != null)
{
ITreeNode child;
for (child = node.FirstChild; child != null; child = child.NextSibling)
{
if (child is T obj)
yield return obj;
foreach (T childrenInSubtree in child.GetChildrenInSubtrees<T>())
yield return childrenInSubtree;
}
child = (ITreeNode) null;
}
}

public static T GetParentOfType<T>([NotNull] this ITreeNode node) where T : class, ITreeNode
{
for (; node != null; node = node.Parent)
{
if (node is T obj)
return obj;
}
return default(T);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
using JetBrains.ReSharper.Psi.Naming.Settings;
using JetBrains.ReSharper.Psi.Resources;
using JetBrains.ReSharper.Psi.Transactions;
using JetBrains.RiderTutorials.Utils;
using JetBrains.TextControl;
using JetBrains.UI.RichText;
using JetBrains.Util;
using ReSharperPlugin.SpecflowRiderPlugin.Caching.StepsDefinitions;
using ReSharperPlugin.SpecflowRiderPlugin.Extensions;
using ReSharperPlugin.SpecflowRiderPlugin.Helpers;
using ReSharperPlugin.SpecflowRiderPlugin.Psi;
using ReSharperPlugin.SpecflowRiderPlugin.References;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using JetBrains.ReSharper.Psi.Resolve;
using JetBrains.ReSharper.Psi.Search;
using JetBrains.ReSharper.Psi.Tree;
using JetBrains.RiderTutorials.Utils;
using ReSharperPlugin.SpecflowRiderPlugin.Extensions;
using ReSharperPlugin.SpecflowRiderPlugin.Psi;

namespace ReSharperPlugin.SpecflowRiderPlugin.Searchers
Expand Down

0 comments on commit aae5ff4

Please sign in to comment.