@@ -148,23 +148,7 @@ private void ParseAll()
148
148
. ToList ( ) ;
149
149
150
150
var components = projects . SelectMany ( p => p . VBComponents . Cast < VBComponent > ( ) ) . ToList ( ) ;
151
- foreach ( var component in components )
152
- {
153
- _state . SetModuleState ( component , ParserState . LoadingReference ) ;
154
- }
155
-
156
- if ( ! _state . AllDeclarations . Any ( item => item . IsBuiltIn ) )
157
- {
158
- var references = projects . SelectMany ( p => p . References . Cast < Reference > ( ) ) . ToList ( ) ;
159
- foreach ( var reference in references )
160
- {
161
- var items = _comReflector . GetDeclarationsForReference ( reference ) . ToList ( ) ;
162
- foreach ( var declaration in items )
163
- {
164
- _state . AddDeclaration ( declaration ) ;
165
- }
166
- }
167
- }
151
+ LoadComReferences ( components , projects ) ;
168
152
169
153
foreach ( var component in components )
170
154
{
@@ -185,18 +169,31 @@ private void ParseAll()
185
169
}
186
170
}
187
171
172
+ private void LoadComReferences ( IEnumerable < VBComponent > components , IEnumerable < VBProject > projects )
173
+ {
174
+ foreach ( var component in components )
175
+ {
176
+ _state . SetModuleState ( component , ParserState . LoadingReference ) ;
177
+ }
178
+
179
+ if ( ! _state . AllDeclarations . Any ( item => item . IsBuiltIn ) )
180
+ {
181
+ var references = projects . SelectMany ( p => p . References . Cast < Reference > ( ) ) . ToList ( ) ;
182
+ foreach ( var reference in references )
183
+ {
184
+ var items = _comReflector . GetDeclarationsForReference ( reference ) . ToList ( ) ;
185
+ foreach ( var declaration in items )
186
+ {
187
+ _state . AddDeclaration ( declaration ) ;
188
+ }
189
+ }
190
+ }
191
+ }
192
+
188
193
public Task ParseAsync ( VBComponent component , CancellationToken token , TokenStreamRewriter rewriter = null )
189
194
{
190
- // Remove invalidated "things" from _state
191
- // this includes: Declarations, Comments, Attributes, Exceptions, ParseTree and TokenStream
192
- // how that works with the Inspecion results is not quite clear
193
- _state . ClearDeclarations ( component ) ;
194
- _state . AddParseTree ( component , null ) ;
195
- _state . AddTokenStream ( component , null ) ;
196
-
195
+ _state . ClearDeclarations ( component ) ;
197
196
_state . SetModuleState ( component , ParserState . Pending ) ; // also clears module-exceptions
198
- _state . SetModuleComments ( component , Enumerable . Empty < CommentNode > ( ) ) ;
199
- _state . SetModuleAttributes ( component , new Dictionary < Tuple < string , DeclarationType > , Attributes > ( ) ) ;
200
197
201
198
var linkedTokenSource = CancellationTokenSource . CreateLinkedTokenSource ( _central . Token , token ) ;
202
199
0 commit comments