Skip to content

Commit

Permalink
Merge branch 'rubberduck-vba/next' into CodeBuilder_ChangeDefaultRHSP…
Browse files Browse the repository at this point in the history
…aram
  • Loading branch information
BZngr committed Aug 13, 2020
2 parents dd845d1 + d5a5587 commit 1b9073d
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 175 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -186,6 +186,7 @@ CodeGraphData/

# Generated Artifacts
Rubberduck.CodeAnalysis.xml
Rubberduck.Parsing.xml

#Gradle
/.gradle/
Expand Down
Expand Up @@ -55,5 +55,21 @@ public static INode GetFirstNode(this INode node, ICollection<Type> excludedType

return GetFirstNode(node.Children[0], excludedTypes);
}

public static bool TryGetAncestorNode<T>(this INode node, out T ancestor) where T: INode
{
ancestor = default;
if (node.Parent is null)
{
return false;
}

if (node.Parent is T result)
{
ancestor = result;
return true;
}
return TryGetAncestorNode(node.Parent, out ancestor);
}
}
}
@@ -0,0 +1,9 @@
using Antlr4.Runtime.Tree;

namespace Rubberduck.Inspections.CodePathAnalysis.Nodes
{
public class AssignmentExpressionNode : NodeBase
{
public AssignmentExpressionNode(IParseTree tree) : base(tree) { }
}
}
4 changes: 4 additions & 0 deletions Rubberduck.CodeAnalysis/CodePathAnalysis/Walker.cs
Expand Up @@ -33,6 +33,10 @@ public INode GenerateTree(IParseTree tree, Declaration declaration)
case VBAParser.BlockContext _:
node = new BlockNode(tree);
break;
case VBAParser.LetStmtContext _:
case VBAParser.SetStmtContext _:
node = new AssignmentExpressionNode(tree);
break;
}

if (declaration.Context == tree)
Expand Down

0 comments on commit 1b9073d

Please sign in to comment.