Skip to content

Commit 556869c

Browse files
authored
Merge branch 'next' into features2355
2 parents 25f9dfe + a5480c9 commit 556869c

File tree

206 files changed

+5539
-3465
lines changed

Some content is hidden

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

206 files changed

+5539
-3465
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.sln.docstates
88
*.csproj.user
99
*.csproj.DotSettings
10+
launchSettings.json
1011

1112
# External NuGet Packages
1213
[Pp]ackages/
@@ -178,4 +179,7 @@ $RECYCLE.BIN/
178179
Installers/
179180
*.xlsx
180181

181-
CodeGraphData/
182+
CodeGraphData/
183+
/Rubberduck.Deployment/Properties/launchSettings.json
184+
/Rubberduck.Deployment/Rubberduck.API.idl
185+
/Rubberduck.Deployment/Rubberduck.idl

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you like this project and would like to thank its contributors, you are welco
1818

1919
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Percentage of issues still open")
2020

21-
> **[rubberduckvba.com](http://rubberduckvba.com)** [Wiki](https://github.com/retailcoder/Rubberduck/wiki) [Rubberduck News](https://rubberduckvba.wordpress.com/)
21+
> **[rubberduckvba.com](http://rubberduckvba.com)** [Wiki](https://github.com/rubberduck-vba/Rubberduck/wiki) [Rubberduck News](https://rubberduckvba.wordpress.com/)
2222
> devs@rubberduckvba.com
2323
> Follow [@rubberduckvba](https://twitter.com/rubberduckvba) on Twitter
2424

Rubberduck.CodeAnalysis/CodePathAnalysis/Extensions/NodeExtensions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using Rubberduck.Parsing.Symbols;
56

67
namespace Rubberduck.Inspections.CodePathAnalysis.Extensions
78
{
@@ -50,5 +51,34 @@ public static INode GetFirstNode(this INode node, IEnumerable<Type> excludedType
5051

5152
return GetFirstNode(node.Children[0], excludedTypes);
5253
}
54+
55+
public static List<IdentifierReference> GetIdentifierReferences(this INode node)
56+
{
57+
var nodes = new List<IdentifierReference>();
58+
59+
var blockNodes = node.GetNodes(new[] { typeof(BlockNode) });
60+
foreach (var block in blockNodes)
61+
{
62+
INode lastNode = default;
63+
foreach (var flattenedNode in block.GetFlattenedNodes(new[] { typeof(GenericNode), typeof(BlockNode) }))
64+
{
65+
if (flattenedNode is AssignmentNode &&
66+
lastNode is AssignmentNode)
67+
{
68+
nodes.Add(lastNode.Reference);
69+
}
70+
71+
lastNode = flattenedNode;
72+
}
73+
74+
if (lastNode is AssignmentNode &&
75+
block.Children[0].GetFirstNode(new[] { typeof(GenericNode) }) is DeclarationNode)
76+
{
77+
nodes.Add(lastNode.Reference);
78+
}
79+
}
80+
81+
return nodes;
82+
}
5383
}
5484
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Antlr4.Runtime.Tree;
4+
using Rubberduck.Parsing.Symbols;
5+
6+
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
7+
{
8+
public abstract class NodeBase : INode
9+
{
10+
protected NodeBase(IParseTree tree)
11+
{
12+
Children = new List<INode>().ToImmutableList();
13+
ParseTree = tree;
14+
}
15+
16+
public int SortOrder { get; set; }
17+
public ImmutableList<INode> Children { get; set; }
18+
public INode Parent { get; set; }
19+
public IParseTree ParseTree { get; }
20+
public Declaration Declaration { get; set; }
21+
public IdentifierReference Reference { get; set; }
22+
}
23+
}

Rubberduck.CodeAnalysis/CodePathAnalysis/Nodes/INode.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Rubberduck.Parsing.Symbols;
22
using System.Collections.Immutable;
3+
using Antlr4.Runtime.Tree;
34

45
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
56
{
@@ -8,7 +9,7 @@ public interface INode
89
int SortOrder { get; set; }
910
ImmutableList<INode> Children { get; set; }
1011
INode Parent { get; set; }
11-
12+
IParseTree ParseTree { get; }
1213
Declaration Declaration { get; set; }
1314
IdentifierReference Reference { get; set; }
1415
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using System.Collections.Generic;
2-
using System.Collections.Immutable;
3-
using Rubberduck.Parsing.Symbols;
1+
using Antlr4.Runtime.Tree;
42

53
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
64
{
7-
public class AssignmentNode : INode
5+
public class AssignmentNode : NodeBase
86
{
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; }
7+
public AssignmentNode(IParseTree tree) : base(tree) { }
208
}
219
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using System.Collections.Generic;
2-
using System.Collections.Immutable;
3-
using Rubberduck.Parsing.Symbols;
1+
using Antlr4.Runtime.Tree;
42

53
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
64
{
7-
public class BlockNode : INode
5+
public class BlockNode : NodeBase
86
{
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; }
7+
public BlockNode(IParseTree tree) : base(tree) { }
208
}
219
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using System.Collections.Generic;
2-
using System.Collections.Immutable;
3-
using Rubberduck.Parsing.Symbols;
1+
using Antlr4.Runtime.Tree;
42

53
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
64
{
7-
public class BranchNode : IBranchNode
5+
public class BranchNode : NodeBase, IBranchNode
86
{
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; }
7+
public BranchNode(IParseTree tree) : base(tree) { }
208
}
219
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using System.Collections.Generic;
2-
using System.Collections.Immutable;
3-
using Rubberduck.Parsing.Symbols;
1+
using Antlr4.Runtime.Tree;
42

53
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
64
{
7-
public class DeclarationNode : INode
5+
public class DeclarationNode : NodeBase
86
{
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; }
7+
public DeclarationNode(IParseTree tree) : base(tree) { }
208
}
219
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using System.Collections.Generic;
2-
using System.Collections.Immutable;
3-
using Rubberduck.Parsing.Symbols;
1+
using Antlr4.Runtime.Tree;
42

53
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
64
{
7-
public class GenericNode : INode
5+
public class GenericNode : NodeBase
86
{
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; }
7+
public GenericNode(IParseTree tree) : base(tree) { }
208
}
219
}

0 commit comments

Comments
 (0)