1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
+ using System . Threading . Tasks ;
3
4
using Rubberduck . Parsing . Symbols ;
4
5
using Rubberduck . Parsing . VBA ;
5
6
@@ -21,24 +22,42 @@ public IEnumerable<ExplorerItemViewModel> Build()
21
22
{
22
23
var project = projectDeclaration ;
23
24
var projectItem = new ExplorerItemViewModel ( project ) ;
24
- foreach ( var componentDeclaration in userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , project ) ) )
25
+ Parallel . ForEach ( userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , project ) ) , ( componentDeclaration ) =>
25
26
{
26
27
var component = componentDeclaration ;
27
- yield return new ExplorerItemViewModel ( component ) ;
28
- foreach ( var member in userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , component ) ) )
28
+ var componentItem = new ExplorerItemViewModel ( component ) ;
29
+ foreach ( var memberDeclaration in userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , component ) ) )
29
30
{
30
- yield return new ExplorerItemViewModel ( member ) ;
31
+ var member = memberDeclaration ;
32
+ var memberItem = new ExplorerItemViewModel ( member ) ;
31
33
if ( member . DeclarationType == DeclarationType . UserDefinedType )
32
34
{
33
-
35
+ foreach ( var item in userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , component )
36
+ && d . DeclarationType == DeclarationType . UserDefinedTypeMember
37
+ && d . ParentScope == member . Scope ) )
38
+ {
39
+ memberItem . AddChild ( new ExplorerItemViewModel ( item ) ) ;
40
+ }
34
41
}
35
42
36
43
if ( member . DeclarationType == DeclarationType . Enumeration )
37
44
{
38
-
45
+ foreach ( var item in userDeclarations . Where ( d => ReferenceEquals ( d . ParentDeclaration , component )
46
+ && d . DeclarationType == DeclarationType . EnumerationMember
47
+ && d . ParentScope == member . Scope ) )
48
+ {
49
+ memberItem . AddChild ( new ExplorerItemViewModel ( item ) ) ;
50
+ }
39
51
}
52
+
53
+ componentItem . AddChild ( memberItem ) ;
40
54
}
41
- }
55
+
56
+ projectItem . AddChild ( componentItem ) ;
57
+ } ) ;
58
+
59
+ // todo: figure out a way to yield return before that
60
+ yield return projectItem ;
42
61
}
43
62
}
44
63
}
0 commit comments