Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
425bb6e
commit f057121
Showing
8 changed files
with
121 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
Rubberduck.Parsing/Grammar/PartialExtensions/AssignmentNodeContexts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Rubberduck.Parsing.Grammar.Abstract.CodePathAnalysis; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Rubberduck.Parsing.Grammar | ||
{ | ||
public partial class VBAParser | ||
{ | ||
public partial class SetStmtContext : IAssignmentNode | ||
{ | ||
private readonly IDictionary<IExecutionContext, bool> _hasExecuted | ||
= new Dictionary<IExecutionContext, bool>(); | ||
|
||
public bool HasExecuted(IExecutionContext context) | ||
=> _hasExecuted.TryGetValue(context, out var value) && value; | ||
|
||
public void Execute(IExecutionContext context) | ||
=> _hasExecuted[context] = true; | ||
|
||
private readonly IDictionary<IExecutionContext, IList<IReferenceNode>> _references | ||
= new Dictionary<IExecutionContext, IList<IReferenceNode>>(); | ||
|
||
public void AddReference(IReferenceNode node, IExecutionContext context) | ||
{ | ||
if (!_references.TryGetValue(context, out var refs) || refs is null) | ||
{ | ||
_references[context] = refs = new List<IReferenceNode>(); | ||
} | ||
refs.Add(node); | ||
} | ||
|
||
public IReadOnlyList<IReferenceNode> References(IExecutionContext context) | ||
{ | ||
if (!_references.TryGetValue(context, out var refs) || refs is null) | ||
{ | ||
_references[context] = refs = new List<IReferenceNode>(); | ||
} | ||
return refs.ToList(); | ||
} | ||
} | ||
|
||
public partial class LetStmtContext : IAssignmentNode | ||
{ | ||
private readonly IDictionary<IExecutionContext, bool> _hasExecuted | ||
= new Dictionary<IExecutionContext, bool>(); | ||
|
||
public bool HasExecuted(IExecutionContext context) | ||
=> _hasExecuted.TryGetValue(context, out var value) && value; | ||
|
||
public void Execute(IExecutionContext context) | ||
=> _hasExecuted[context] = true; | ||
|
||
private readonly IDictionary<IExecutionContext, IList<IReferenceNode>> _references | ||
= new Dictionary<IExecutionContext, IList<IReferenceNode>>(); | ||
|
||
public void AddReference(IReferenceNode node, IExecutionContext context) | ||
{ | ||
if (!_references.TryGetValue(context, out var refs) || refs is null) | ||
{ | ||
_references[context] = refs = new List<IReferenceNode>(); | ||
} | ||
refs.Add(node); | ||
} | ||
|
||
public IReadOnlyList<IReferenceNode> References(IExecutionContext context) | ||
{ | ||
if (!_references.TryGetValue(context, out var refs) || refs is null) | ||
{ | ||
_references[context] = refs = new List<IReferenceNode>(); | ||
} | ||
return refs.ToList(); | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Rubberduck.Parsing/Grammar/PartialExtensions/BlockStmtContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Rubberduck.Parsing.Grammar.Abstract.CodePathAnalysis; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Rubberduck.Parsing.Grammar.PartialExtensions | ||
{ | ||
public partial class VBAParser | ||
{ | ||
public partial class BlockStmtContext : IExecutableNode | ||
{ | ||
private readonly IDictionary<IExecutionContext, bool> _hasExecuted | ||
= new Dictionary<IExecutionContext, bool>(); | ||
|
||
public bool HasExecuted(IExecutionContext context) | ||
=> _hasExecuted.TryGetValue(context, out var value) && value; | ||
|
||
public void Execute(IExecutionContext context) | ||
=> _hasExecuted[context] = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters