Skip to content

Commit 2ed334e

Browse files
committed
merge next
2 parents 62dfc35 + 1991a0c commit 2ed334e

File tree

327 files changed

+8798
-8688
lines changed

Some content is hidden

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

327 files changed

+8798
-8688
lines changed

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.API/Rubberduck.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project Sdk="Microsoft.NET.Sdk">
2+
<Project Sdk="Sunburst.NET.Sdk.WPF/1.0.47">
33
<PropertyGroup>
44
<Product>Rubberduck.API</Product>
55
<Description>Rubberduck Reflection API</Description>

Rubberduck.API/VBA/Parser.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
using System.Linq;
66
using System.Runtime.InteropServices;
77
using System.Threading;
8-
using Rubberduck.Common;
98
using Rubberduck.Parsing.ComReflection;
109
using Rubberduck.Parsing.PreProcessing;
1110
using Rubberduck.Parsing.Rewriter;
1211
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
1312
using Rubberduck.Parsing.VBA;
14-
using Rubberduck.Parsing.Symbols;
1513
using Rubberduck.Parsing.UIContext;
1614
using Rubberduck.Parsing.VBA.ComReferenceLoading;
1715
using Rubberduck.Parsing.VBA.DeclarationCaching;
@@ -98,8 +96,6 @@ internal Parser(object vbe) : this()
9896
var projectRepository = new ProjectsRepository(_vbe);
9997
_state = new RubberduckParserState(_vbe, projectRepository, declarationFinderFactory, _vbeEvents);
10098
_state.StateChanged += _state_StateChanged;
101-
102-
var sourceFileHandler = _vbe.TempSourceFileHandler;
10399
var vbeVersion = double.Parse(_vbe.Version, CultureInfo.InvariantCulture);
104100
var predefinedCompilationConstants = new VBAPredefinedCompilationConstants(vbeVersion);
105101
var typeLibProvider = new TypeLibWrapperProvider(projectRepository);
@@ -112,7 +108,6 @@ internal Parser(object vbe) : this()
112108
var mainTokenStreamParser = new VBATokenStreamParser(mainParseErrorListenerFactory, mainParseErrorListenerFactory);
113109
var tokenStreamProvider = new SimpleVBAModuleTokenStreamProvider();
114110
var stringParser = new TokenStreamParserStringParserAdapterWithPreprocessing(tokenStreamProvider, mainTokenStreamParser, preprocessor);
115-
var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
116111
var projectManager = new RepositoryProjectManager(projectRepository);
117112
var moduleToModuleReferenceManager = new ModuleToModuleReferenceManager();
118113
var parserStateManager = new ParserStateManager(_state);
@@ -133,14 +128,12 @@ internal Parser(object vbe) : this()
133128
}
134129
);
135130
var codePaneSourceCodeHandler = new CodePaneSourceCodeHandler(projectRepository);
136-
var moduleRewriterFactory = new ModuleRewriterFactory(
137-
codePaneSourceCodeHandler,
138-
attributesSourceCodeHandler);
131+
var sourceFileHandler = _vbe.TempSourceFileHandler;
132+
var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
139133
var moduleParser = new ModuleParser(
140134
codePaneSourceCodeHandler,
141135
attributesSourceCodeHandler,
142-
stringParser,
143-
moduleRewriterFactory);
136+
stringParser);
144137
var parseRunner = new ParseRunner(
145138
_state,
146139
parserStateManager,

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
}

0 commit comments

Comments
 (0)