@@ -57,12 +57,12 @@ public RubberduckParser(VBE vbe, RubberduckParserState state, IAttributeParser a
57
57
state . StateChanged += StateOnStateChanged ;
58
58
}
59
59
60
- private void StateOnStateChanged ( object sender , EventArgs e )
60
+ private void StateOnStateChanged ( object sender , ParserStateEventArgs e )
61
61
{
62
- ParserStateEventArgs args = e as ParserStateEventArgs ;
63
- Debug . WriteLine ( "RubberduckParser handles OnStateChanged ({0})" , _state . Status ) ;
64
- // why access _state and not pass through EventArgs?
65
- if ( args . State == ParserState . Parsed )
62
+ Debug . WriteLine ( "RubberduckParser handles OnStateChanged ({0})" , e . State ) ;
63
+ Debug . Assert ( e . State == _state . Status ) ;
64
+
65
+ if ( e . State == ParserState . Parsed )
66
66
{
67
67
Debug . WriteLine ( "(handling OnStateChanged) Starting resolver task" ) ;
68
68
Resolve ( _central . Token ) ; // Tests expect this to be synchronous
@@ -91,7 +91,12 @@ public void Parse()
91
91
. Cast < VBProject > ( )
92
92
. Where ( project => project . Protection == vbext_ProjectProtection . vbext_pp_none ) ;
93
93
94
- var components = projects . SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) ;
94
+ var components = projects . SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) . ToList ( ) ;
95
+ foreach ( var component in components )
96
+ {
97
+ _state . SetModuleState ( component , ParserState . Pending ) ;
98
+ }
99
+
95
100
// invalidation cleanup should go into ParseAsync?
96
101
foreach ( var invalidated in _componentAttributes . Keys . Except ( components ) )
97
102
{
@@ -116,7 +121,12 @@ private void ParseAll()
116
121
. Cast < VBProject > ( )
117
122
. Where ( project => project . Protection == vbext_ProjectProtection . vbext_pp_none ) ;
118
123
119
- var components = projects . SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) ;
124
+ var components = projects . SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) . ToList ( ) ;
125
+ foreach ( var component in components )
126
+ {
127
+ _state . SetModuleState ( component , ParserState . Pending ) ;
128
+ }
129
+
120
130
// invalidation cleanup should go into ParseAsync?
121
131
foreach ( var invalidated in _componentAttributes . Keys . Except ( components ) )
122
132
{
@@ -258,7 +268,7 @@ private void ResolveDeclarations(VBComponent component, IParseTree tree)
258
268
// cannot locate declarations in one pass *the way it's currently implemented*,
259
269
// because the context in EnterSubStmt() doesn't *yet* have child nodes when the context enters.
260
270
// so we need to EnterAmbiguousIdentifier() and evaluate the parent instead - this *might* work.
261
- DeclarationSymbolsListener declarationsListener = new DeclarationSymbolsListener ( qualifiedModuleName , Accessibility . Implicit , component . Type , _state . GetModuleComments ( component ) , _state . getModuleAttributes ( component ) ) ;
271
+ var declarationsListener = new DeclarationSymbolsListener ( qualifiedModuleName , Accessibility . Implicit , component . Type , _state . GetModuleComments ( component ) , _state . getModuleAttributes ( component ) ) ;
262
272
// TODO: should we unify the API? consider working like the other listeners instead of event-based
263
273
declarationsListener . NewDeclaration += ( sender , e ) => _state . AddDeclaration ( e . Declaration ) ;
264
274
declarationsListener . CreateModuleDeclarations ( ) ;
0 commit comments