@@ -288,28 +288,30 @@ public bool ClearDeclarations(VBComponent component)
288
288
kvp . Project == project && kvp . ComponentName == component . Name ) ; // VBComponent reference seems to mismatch
289
289
290
290
var success = true ;
291
+ var declarationsRemoved = 0 ;
291
292
foreach ( var key in keys )
292
293
{
293
- ConcurrentDictionary < Declaration , byte > declarations ;
294
+ ConcurrentDictionary < Declaration , byte > declarations = null ;
294
295
success = success && ( ! _declarations . ContainsKey ( key ) || _declarations . TryRemove ( key , out declarations ) ) ;
295
- }
296
-
297
- ParserState state ;
298
- success = success && ( ! _moduleStates . ContainsKey ( component ) || _moduleStates . TryRemove ( component , out state ) ) ;
296
+ declarationsRemoved = declarations == null ? 0 : declarations . Count ;
299
297
300
- SyntaxErrorException exception ;
301
- success = success && ( ! _moduleExceptions . ContainsKey ( component ) || _moduleExceptions . TryRemove ( component , out exception ) ) ;
298
+ IParseTree tree ;
299
+ success = success && ( ! _parseTrees . ContainsKey ( key . Component ) || _parseTrees . TryRemove ( key . Component , out tree ) ) ;
302
300
303
- var components = _comments . Keys . Where ( key =>
304
- key . Collection . Parent == project && key . Name == component . Name ) ;
301
+ ITokenStream stream ;
302
+ success = success && ( ! _tokenStreams . ContainsKey ( key . Component ) || _tokenStreams . TryRemove ( key . Component , out stream ) ) ;
303
+
304
+ ParserState state ;
305
+ success = success && ( ! _moduleStates . ContainsKey ( key . Component ) || _moduleStates . TryRemove ( key . Component , out state ) ) ;
306
+
307
+ SyntaxErrorException exception ;
308
+ success = success && ( ! _moduleExceptions . ContainsKey ( key . Component ) || _moduleExceptions . TryRemove ( key . Component , out exception ) ) ;
305
309
306
- foreach ( var commentKey in components )
307
- {
308
310
IList < CommentNode > nodes ;
309
- success = success && ( ! _comments . ContainsKey ( commentKey ) || _comments . TryRemove ( commentKey , out nodes ) ) ;
311
+ success = success && ( ! _comments . ContainsKey ( key . Component ) || _comments . TryRemove ( key . Component , out nodes ) ) ;
310
312
}
311
313
312
- Debug . WriteLine ( "ClearDeclarations({0}): {1}" , component . Name , success ? "succeeded" : "failed" ) ;
314
+ Debug . WriteLine ( "ClearDeclarations({0}): {1} - {2} declarations removed " , component . Name , success ? "succeeded" : "failed" , declarationsRemoved ) ;
313
315
return success ;
314
316
}
315
317
0 commit comments