@@ -29,8 +29,6 @@ public class RubberduckParser : IRubberduckParser
29
29
private readonly IDictionary < VBComponent , IDictionary < Tuple < string , DeclarationType > , Attributes > > _componentAttributes
30
30
= new Dictionary < VBComponent , IDictionary < Tuple < string , DeclarationType > , Attributes > > ( ) ;
31
31
32
- private readonly ReferencedDeclarationsCollector _comReflector ;
33
-
34
32
private readonly VBE _vbe ;
35
33
private readonly RubberduckParserState _state ;
36
34
private readonly IAttributeParser _attributeParser ;
@@ -52,8 +50,6 @@ public RubberduckParser(
52
50
_preprocessorFactory = preprocessorFactory ;
53
51
_customDeclarationLoaders = customDeclarationLoaders ;
54
52
55
- _comReflector = new ReferencedDeclarationsCollector ( _state ) ;
56
-
57
53
state . ParseRequest += ReparseRequested ;
58
54
}
59
55
@@ -69,6 +65,14 @@ private void ReparseRequested(object sender, ParseRequestEventArgs e)
69
65
Cancel ( e . Component ) ;
70
66
Task . Run ( ( ) =>
71
67
{
68
+ SyncComReferences ( _state . Projects ) ;
69
+ AddBuiltInDeclarations ( ) ;
70
+
71
+ if ( _resolverTokenSource . IsCancellationRequested || _central . IsCancellationRequested )
72
+ {
73
+ return ;
74
+ }
75
+
72
76
ParseAsync ( e . Component , CancellationToken . None ) . Wait ( ) ;
73
77
74
78
if ( _resolverTokenSource . IsCancellationRequested || _central . IsCancellationRequested )
@@ -388,11 +392,17 @@ private void SyncComReferences(IReadOnlyList<VBProject> projects)
388
392
if ( ! map . IsLoaded )
389
393
{
390
394
_state . OnStatusMessageUpdate ( ParserState . LoadingReference . ToString ( ) ) ;
391
- var items = _comReflector . GetDeclarationsForReference ( reference ) ;
392
- foreach ( var declaration in items )
395
+
396
+ Task . Run ( ( ) =>
393
397
{
394
- _state . AddDeclaration ( declaration ) ;
395
- }
398
+ var comReflector = new ReferencedDeclarationsCollector ( _state ) ;
399
+ var items = comReflector . GetDeclarationsForReference ( reference ) ;
400
+
401
+ foreach ( var declaration in items )
402
+ {
403
+ _state . AddDeclaration ( declaration ) ;
404
+ }
405
+ } ) ;
396
406
map . IsLoaded = true ;
397
407
}
398
408
}
0 commit comments