@@ -260,17 +260,14 @@ private void ParseAll()
260
260
return ;
261
261
}
262
262
263
- lock ( State ) // note, method is invoked from UI thread... really need the lock here?
263
+ foreach ( var component in toParse )
264
264
{
265
- foreach ( var component in toParse )
266
- {
267
- State . SetModuleState ( component , ParserState . Pending ) ;
268
- }
269
- foreach ( var component in unchanged )
270
- {
271
- // note: seting to 'Parsed' would include them in the resolver walk. 'Ready' excludes them.
272
- State . SetModuleState ( component , ParserState . Ready ) ;
273
- }
265
+ State . SetModuleState ( component , ParserState . Pending ) ;
266
+ }
267
+ foreach ( var component in unchanged )
268
+ {
269
+ // note: seting to 'Parsed' would include them in the resolver walk. 'Ready' excludes them.
270
+ State . SetModuleState ( component , ParserState . Ready ) ;
274
271
}
275
272
276
273
// invalidation cleanup should go into ParseAsync?
@@ -304,10 +301,7 @@ private void ParseAll()
304
301
Logger . Debug ( "Module '{0}' {1}" , qualifiedName . ComponentName ,
305
302
State . IsNewOrModified ( qualifiedName ) ? "was modified" : "was NOT modified" ) ;
306
303
307
- lock ( State )
308
- {
309
- State . SetModuleState ( toParse [ index ] , ParserState . ResolvingDeclarations ) ;
310
- }
304
+ State . SetModuleState ( toParse [ index ] , ParserState . ResolvingDeclarations ) ;
311
305
312
306
ResolveDeclarations ( qualifiedName . Component ,
313
307
State . ParseTrees . Find ( s => s . Key == qualifiedName ) . Value ) ;
@@ -349,10 +343,7 @@ private Task[] ResolveReferencesAsync()
349
343
350
344
tasks [ index ] = Task . Run ( ( ) =>
351
345
{
352
- lock ( State )
353
- {
354
- State . SetModuleState ( kvp . Key . Component , ParserState . ResolvingReferences ) ;
355
- }
346
+ State . SetModuleState ( kvp . Key . Component , ParserState . ResolvingReferences ) ;
356
347
357
348
ResolveReferences ( finder , kvp . Key . Component , kvp . Value ) ;
358
349
} ) ;
@@ -363,14 +354,11 @@ private Task[] ResolveReferencesAsync()
363
354
364
355
private void AddBuiltInDeclarations ( )
365
356
{
366
- lock ( State )
357
+ foreach ( var customDeclarationLoader in _customDeclarationLoaders )
367
358
{
368
- foreach ( var customDeclarationLoader in _customDeclarationLoaders )
359
+ foreach ( var declaration in customDeclarationLoader . Load ( ) )
369
360
{
370
- foreach ( var declaration in customDeclarationLoader . Load ( ) )
371
- {
372
- State . AddDeclaration ( declaration ) ;
373
- }
361
+ State . AddDeclaration ( declaration ) ;
374
362
}
375
363
}
376
364
}
@@ -512,12 +500,8 @@ private void UnloadComReference(Reference reference, IReadOnlyList<VBProject> pr
512
500
513
501
private Task ParseAsync ( VBComponent component , CancellationToken token , TokenStreamRewriter rewriter = null )
514
502
{
515
- lock ( State )
516
- lock ( component )
517
- {
518
- State . ClearStateCache ( component ) ;
519
- State . SetModuleState ( component , ParserState . Pending ) ; // also clears module-exceptions
520
- }
503
+ State . ClearStateCache ( component ) ;
504
+ State . SetModuleState ( component , ParserState . Pending ) ; // also clears module-exceptions
521
505
522
506
var linkedTokenSource = CancellationTokenSource . CreateLinkedTokenSource ( _central . Token , token ) ;
523
507
@@ -566,11 +550,7 @@ private void ParseAsyncInternal(VBComponent component, CancellationToken token,
566
550
var parser = new ComponentParseTask ( component , preprocessor , _attributeParser , rewriter ) ;
567
551
parser . ParseFailure += ( sender , e ) =>
568
552
{
569
- lock ( State )
570
- lock ( component )
571
- {
572
- State . SetModuleState ( component , ParserState . Error , e . Cause as SyntaxErrorException ) ;
573
- }
553
+ State . SetModuleState ( component , ParserState . Error , e . Cause as SyntaxErrorException ) ;
574
554
} ;
575
555
parser . ParseCompleted += ( sender , e ) =>
576
556
{
@@ -587,11 +567,8 @@ private void ParseAsyncInternal(VBComponent component, CancellationToken token,
587
567
State . SetModuleState ( component , ParserState . Parsed ) ;
588
568
}
589
569
} ;
590
- lock ( State )
591
- lock ( component )
592
- {
593
- State . SetModuleState ( component , ParserState . Parsing ) ;
594
- }
570
+ State . SetModuleState ( component , ParserState . Parsing ) ;
571
+
595
572
parser . Start ( token ) ;
596
573
}
597
574
@@ -611,10 +588,7 @@ private void ResolveDeclarations(VBComponent component, IParseTree tree)
611
588
{
612
589
projectDeclaration = CreateProjectDeclaration ( projectQualifiedName , project ) ;
613
590
_projectDeclarations . AddOrUpdate ( projectQualifiedName . ProjectId , projectDeclaration , ( s , c ) => projectDeclaration ) ;
614
- lock ( State )
615
- {
616
- State . AddDeclaration ( projectDeclaration ) ;
617
- }
591
+ State . AddDeclaration ( projectDeclaration ) ;
618
592
}
619
593
Logger . Debug ( "Creating declarations for module {0}." , qualifiedModuleName . Name ) ;
620
594
var declarationsListener = new DeclarationSymbolsListener ( State , qualifiedModuleName , component . Type , State . GetModuleAnnotations ( component ) , State . GetModuleAttributes ( component ) , projectDeclaration ) ;
@@ -627,10 +601,7 @@ private void ResolveDeclarations(VBComponent component, IParseTree tree)
627
601
catch ( Exception exception )
628
602
{
629
603
Logger . Error ( exception , "Exception thrown acquiring declarations for '{0}' (thread {1})." , component . Name , Thread . CurrentThread . ManagedThreadId ) ;
630
- lock ( State )
631
- {
632
- State . SetModuleState ( component , ParserState . ResolverError ) ;
633
- }
604
+ State . SetModuleState ( component , ParserState . ResolverError ) ;
634
605
}
635
606
}
636
607
0 commit comments