17
17
using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
18
18
using System . Runtime . InteropServices ;
19
19
using Rubberduck . VBEditor . Application ;
20
- using Rubberduck . VBEditor . Extensions ;
21
20
22
21
// ReSharper disable LoopCanBeConvertedToQuery
23
22
@@ -75,8 +74,8 @@ public ParseCoordinator(
75
74
// but the cancelees need to use their own token.
76
75
private readonly List < CancellationTokenSource > _cancellationTokens = new List < CancellationTokenSource > { new CancellationTokenSource ( ) } ;
77
76
78
- private readonly Object _cancellationSyncObject = new Object ( ) ;
79
- private readonly Object _parsingRunSyncObject = new Object ( ) ;
77
+ private readonly object _cancellationSyncObject = new object ( ) ;
78
+ private readonly object _parsingRunSyncObject = new object ( ) ;
80
79
81
80
private void ReparseRequested ( object sender , EventArgs e )
82
81
{
@@ -89,7 +88,7 @@ private void ReparseRequested(object sender, EventArgs e)
89
88
90
89
if ( ! _isTestScope )
91
90
{
92
- Task . Run ( ( ) => ParseAll ( sender , token ) ) ;
91
+ Task . Run ( ( ) => ParseAll ( sender , token ) , token ) ;
93
92
}
94
93
else
95
94
{
@@ -295,7 +294,7 @@ private void ClearModuleToModuleReferences(ICollection<QualifiedModuleName> toCl
295
294
}
296
295
}
297
296
298
- //This doesn not live on the RubberduckParserState to keep concurrency haanlding out of it.
297
+ //This does not live on the RubberduckParserState to keep concurrency haanlding out of it.
299
298
public void RemoveAllReferencesBy ( ICollection < QualifiedModuleName > referencesFromToRemove , ICollection < QualifiedModuleName > modulesNotNeedingReferenceRemoval , DeclarationFinder finder , CancellationToken token )
300
299
{
301
300
var referencedModulesNeedingReferenceRemoval = State . ModulesReferencedBy ( referencesFromToRemove ) . Where ( qmn => ! modulesNotNeedingReferenceRemoval . Contains ( qmn ) ) ;
@@ -343,7 +342,7 @@ private void ParseComponents(ICollection<IVBComponent> components, CancellationT
343
342
{
344
343
if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
345
344
{
346
- throw exception . InnerException ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
345
+ throw exception . InnerException ?? exception ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
347
346
}
348
347
State . SetStatusAndFireStateChanged ( this , ParserState . Error ) ;
349
348
throw ;
@@ -438,7 +437,7 @@ private void ResolveAllDeclarations(ICollection<IVBComponent> components, Cancel
438
437
{
439
438
if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
440
439
{
441
- throw exception . InnerException ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
440
+ throw exception . InnerException ?? exception ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
442
441
}
443
442
State . SetStatusAndFireStateChanged ( this , ParserState . ResolverError ) ;
444
443
throw ;
@@ -537,7 +536,7 @@ private void ResolveAllReferences(ICollection<QualifiedModuleName> toResolve, Ca
537
536
{
538
537
if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
539
538
{
540
- throw exception . InnerException ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
539
+ throw exception . InnerException ?? exception ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
541
540
}
542
541
State . SetStatusAndFireStateChanged ( this , ParserState . ResolverError ) ;
543
542
throw ;
@@ -611,9 +610,12 @@ private void ResolveReferences(DeclarationFinder finder, QualifiedModuleName qua
611
610
612
611
private void AddModuleToModuleReferences ( DeclarationFinder finder , CancellationToken token )
613
612
{
614
- var options = new ParallelOptions ( ) ;
615
- options . CancellationToken = token ;
616
- options . MaxDegreeOfParallelism = _maxDegreeOfReferenceResolverParallelism ;
613
+ var options = new ParallelOptions
614
+ {
615
+ CancellationToken = token ,
616
+ MaxDegreeOfParallelism = _maxDegreeOfReferenceResolverParallelism
617
+ } ;
618
+
617
619
try
618
620
{
619
621
Parallel . For ( 0 , State . ParseTrees . Count , options ,
@@ -624,7 +626,7 @@ private void AddModuleToModuleReferences(DeclarationFinder finder, CancellationT
624
626
{
625
627
if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
626
628
{
627
- throw exception . InnerException ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
629
+ throw exception . InnerException ?? exception ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
628
630
}
629
631
State . SetStatusAndFireStateChanged ( this , ParserState . ResolverError ) ;
630
632
throw ;
@@ -749,9 +751,9 @@ private void ParseAllInternal(object requestor, CancellationToken token)
749
751
/// </summary>
750
752
private bool CleanUpRemovedComponents ( ICollection < IVBComponent > components , CancellationToken token )
751
753
{
752
- var removedModuledecalrations = RemovedModuleDeclarations ( components ) ;
753
- var componentRemoved = removedModuledecalrations . Any ( ) ;
754
- var removedModules = removedModuledecalrations . Select ( declaration => declaration . QualifiedName . QualifiedModuleName ) . ToHashSet ( ) ;
754
+ var removedModuleDeclarations = RemovedModuleDeclarations ( components ) . ToArray ( ) ;
755
+ var componentRemoved = removedModuleDeclarations . Any ( ) ;
756
+ var removedModules = removedModuleDeclarations . Select ( declaration => declaration . QualifiedName . QualifiedModuleName ) . ToHashSet ( ) ;
755
757
if ( removedModules . Any ( ) )
756
758
{
757
759
RemoveAllReferencesBy ( removedModules , removedModules , State . DeclarationFinder , token ) ;
@@ -865,7 +867,7 @@ private void SyncComReferences(IReadOnlyList<IVBProject> projects, CancellationT
865
867
{
866
868
if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
867
869
{
868
- throw exception . InnerException ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
870
+ throw exception . InnerException ?? exception ; //This eliminates the stack trace, but for the cancellation, this is irrelevant.
869
871
}
870
872
State . SetStatusAndFireStateChanged ( this , ParserState . Error ) ;
871
873
throw ;
@@ -952,7 +954,7 @@ private void LoadReference(IReference localReference, ConcurrentBag<IReference>
952
954
}
953
955
else
954
956
{
955
- LoadReferenceByCOMReflection ( localReference , comReflector ) ;
957
+ LoadReferenceFromTypeLibrary ( localReference , comReflector ) ;
956
958
}
957
959
}
958
960
catch ( Exception exception )
@@ -973,7 +975,7 @@ private void LoadReferenceByDeserialization(IReference localReference, Reference
973
975
}
974
976
}
975
977
976
- private void LoadReferenceByCOMReflection ( IReference localReference , ReferencedDeclarationsCollector comReflector )
978
+ private void LoadReferenceFromTypeLibrary ( IReference localReference , ReferencedDeclarationsCollector comReflector )
977
979
{
978
980
Logger . Trace ( string . Format ( "COM reflecting reference '{0}'." , localReference . Name ) ) ;
979
981
var declarations = comReflector . LoadDeclarationsFromLibrary ( ) ;
0 commit comments