Skip to content

Commit d974cb5

Browse files
committed
Merge next
2 parents 44b3deb + f38ebf7 commit d974cb5

File tree

64 files changed

+4886
-704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4886
-704
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Rubberduck.Inspections.CodePathAnalysis.Nodes;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
namespace Rubberduck.Inspections.CodePathAnalysis.Extensions
7+
{
8+
public static class NodeExtensions
9+
{
10+
public static IEnumerable<INode> GetFlattenedNodes(this INode node, IEnumerable<Type> excludedTypes)
11+
{
12+
foreach (var child in node.Children)
13+
{
14+
if (!excludedTypes.Contains(child.GetType()))
15+
{
16+
yield return child;
17+
}
18+
else
19+
{
20+
foreach (var nextChild in GetFlattenedNodes(child, excludedTypes))
21+
{
22+
yield return nextChild;
23+
}
24+
}
25+
}
26+
}
27+
28+
public static IEnumerable<INode> GetNodes(this INode node, IEnumerable<Type> types)
29+
{
30+
if (types.Contains(node.GetType()))
31+
{
32+
yield return node;
33+
}
34+
35+
foreach (var child in node.Children)
36+
{
37+
foreach (var childNode in GetNodes(child, types))
38+
{
39+
yield return childNode;
40+
}
41+
}
42+
}
43+
44+
public static INode GetFirstNode(this INode node, IEnumerable<Type> excludedTypes)
45+
{
46+
if (!excludedTypes.Contains(node.GetType()))
47+
{
48+
return node;
49+
}
50+
51+
return GetFirstNode(node.Children[0], excludedTypes);
52+
}
53+
}
54+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
2+
{
3+
public interface IBranchNode : INode
4+
{
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
2+
{
3+
public interface ILoopNode : INode
4+
{
5+
}
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Rubberduck.Parsing.Symbols;
2+
using System.Collections.Immutable;
3+
4+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
5+
{
6+
public interface INode
7+
{
8+
int SortOrder { get; set; }
9+
ImmutableList<INode> Children { get; set; }
10+
INode Parent { get; set; }
11+
12+
Declaration Declaration { get; set; }
13+
IdentifierReference Reference { get; set; }
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class AssignmentNode : INode
8+
{
9+
public AssignmentNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class BlockNode : INode
8+
{
9+
public BlockNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class BranchNode : IBranchNode
8+
{
9+
public BranchNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class DeclarationNode : INode
8+
{
9+
public DeclarationNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class GenericNode : INode
8+
{
9+
public GenericNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Rubberduck.Parsing.Symbols;
2+
using System.Collections.Generic;
3+
using System.Collections.Immutable;
4+
5+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
6+
{
7+
public class LoopNode : ILoopNode
8+
{
9+
public LoopNode()
10+
{
11+
Children = new List<INode>().ToImmutableList();
12+
}
13+
14+
public int SortOrder { get; set; }
15+
public ImmutableList<INode> Children { get; set; }
16+
public INode Parent { get; set; }
17+
18+
public Declaration Declaration { get; set; }
19+
public IdentifierReference Reference { get; set; }
20+
}
21+
}

0 commit comments

Comments
 (0)