Skip to content

Commit be38cf2

Browse files
committed
fixed excessive effort from parser to deal with null built-in parse trees (#1582)
* added AsTypeName to the context-sensitive commandbar * clear built-in references at every resolution; fixed issue with null parse trees, given built-in modules get a module state instance.
1 parent b7acc64 commit be38cf2

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

RetailCoder.VBE/Inspections/Inspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private ParseTreeResults GetParseTreeResults(RubberduckParserState state)
104104
{
105105
var result = new ParseTreeResults();
106106

107-
foreach (var componentTreePair in state.ParseTrees.Where(kvp => kvp.Value != null))
107+
foreach (var componentTreePair in state.ParseTrees)
108108
{
109109
/*
110110
Need to reinitialize these for each and every ParseTree we process, since the results are aggregated in the instances themselves

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ private void ResolveInternal(CancellationToken token)
484484
return;
485485
}
486486
_projectDeclarations.Clear();
487+
_state.ClearBuiltInReferences();
487488
foreach (var kvp in _state.ParseTrees)
488489
{
489490
var qualifiedName = kvp.Key;

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ public bool ClearStateCache(VBComponent component, bool notifyStateChanged = fal
445445
{
446446
if (component == null) { return false; }
447447

448-
ClearBuiltInReferences();
449-
450448
var match = new QualifiedModuleName(component);
451449
var keys = _moduleStates.Keys.Where(kvp => kvp.Equals(match))
452450
.Union(new[] { match }).Distinct(); // make sure the key is present, even if there are no declarations left
@@ -530,8 +528,8 @@ public IEnumerable<KeyValuePair<QualifiedModuleName, IParseTree>> ParseTrees
530528
{
531529
get
532530
{
533-
return _moduleStates.Select(
534-
item => new KeyValuePair<QualifiedModuleName, IParseTree>(item.Key, item.Value.ParseTree));
531+
return _moduleStates.Where(state => state.Value.ParseTree != null)
532+
.Select(item => new KeyValuePair<QualifiedModuleName, IParseTree>(item.Key, item.Value.ParseTree));
535533
}
536534
}
537535

0 commit comments

Comments
 (0)