@@ -23,13 +23,7 @@ namespace Rubberduck.Parsing.VBA
23
23
{
24
24
public class RubberduckParser : IRubberduckParser , IDisposable
25
25
{
26
- public RubberduckParserState State
27
- {
28
- get
29
- {
30
- return _state ;
31
- }
32
- }
26
+ public RubberduckParserState State { get { return _state ; } }
33
27
34
28
private CancellationTokenSource _central = new CancellationTokenSource ( ) ;
35
29
private CancellationTokenSource _resolverTokenSource ; // linked to _central later
@@ -64,11 +58,11 @@ private void StateOnStateChanged(object sender, EventArgs e)
64
58
{
65
59
Logger . Debug ( "RubberduckParser handles OnStateChanged ({0})" , _state . Status ) ;
66
60
67
- if ( _state . Status == ParserState . Parsed )
61
+ /* if (_state.Status == ParserState.Parsed)
68
62
{
69
63
Logger.Debug("(handling OnStateChanged) Starting resolver task");
70
64
Resolve(_central.Token); // Tests expect this to be synchronous
71
- }
65
+ }*/
72
66
}
73
67
74
68
private void ReparseRequested ( object sender , ParseRequestEventArgs e )
@@ -81,7 +75,10 @@ private void ReparseRequested(object sender, ParseRequestEventArgs e)
81
75
else
82
76
{
83
77
Cancel ( e . Component ) ;
84
- ParseAsync ( e . Component , CancellationToken . None ) ;
78
+ ParseAsync ( e . Component , CancellationToken . None ) . Wait ( ) ;
79
+
80
+ Logger . Trace ( "Starting resolver task" ) ;
81
+ Resolve ( _central . Token ) ; // Tests expect this to be synchronous
85
82
}
86
83
}
87
84
@@ -137,6 +134,14 @@ private void ParseAll()
137
134
var toParse = components . Where ( c => _state . IsNewOrModified ( c ) ) . ToList ( ) ;
138
135
var unchanged = components . Where ( c => ! _state . IsNewOrModified ( c ) ) . ToList ( ) ;
139
136
137
+ File . AppendAllLines ( "C:/Users/hosch/Desktop/debug.txt" , new [ ]
138
+ {
139
+ "Projects: " + projects . Count ,
140
+ "Components: " + components . Count ,
141
+ "ToParse: " + toParse . Count ,
142
+ "Unchanged: " + unchanged . Count
143
+ } ) ;
144
+
140
145
AddBuiltInDeclarations ( projects ) ;
141
146
142
147
if ( ! toParse . Any ( ) )
@@ -168,10 +173,11 @@ private void ParseAll()
168
173
_componentAttributes . Remove ( invalidated ) ;
169
174
}
170
175
171
- foreach ( var vbComponent in toParse )
172
- {
173
- ParseAsync ( vbComponent , CancellationToken . None ) ;
174
- }
176
+ var parseTasks = toParse . Select ( vbComponent => ParseAsync ( vbComponent , CancellationToken . None ) ) . ToArray ( ) ;
177
+ Task . WaitAll ( parseTasks ) ;
178
+
179
+ Logger . Trace ( "Starting resolver task" ) ;
180
+ Resolve ( _central . Token ) ; // Tests expect this to be synchronous
175
181
}
176
182
177
183
private void AddBuiltInDeclarations ( IReadOnlyList < VBProject > projects )
@@ -479,10 +485,14 @@ private void ResolveInternal(CancellationToken token)
479
485
var components = _state . Projects
480
486
. Where ( project => project . Protection == vbext_ProjectProtection . vbext_pp_none )
481
487
. SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) . ToList ( ) ;
482
- if ( ! _state . HasAllParseTrees ( components ) )
488
+
489
+ File . AppendAllLines ( "C:/Users/hosch/Desktop/debug.txt" , new [ ]
483
490
{
484
- return ;
485
- }
491
+ "Parse tree count: " + _state . ParseTrees . Count ( )
492
+ } ) ;
493
+
494
+ Debug . Assert ( _state . HasAllParseTrees ( components ) , string . Format ( "Expected parse trees: {0}\r \n Parse trees: {1}" , components . Count , _state . ParseTrees . Count ( ) ) ) ;
495
+
486
496
_projectDeclarations . Clear ( ) ;
487
497
_state . ClearBuiltInReferences ( ) ;
488
498
foreach ( var kvp in _state . ParseTrees )
0 commit comments