@@ -22,14 +22,14 @@ public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel
22
22
23
23
private readonly IVBE _vbe ;
24
24
25
- public CodeExplorerProjectViewModel ( Declaration declaration , IEnumerable < Declaration > declarations , RubberduckParserState state , IVBE vbe , bool references = true ) : base ( null , declaration )
25
+ public CodeExplorerProjectViewModel ( Declaration project , List < Declaration > declarations , RubberduckParserState state , IVBE vbe , bool references = true ) : base ( null , project )
26
26
{
27
27
State = state ;
28
28
_vbe = vbe ;
29
29
ShowReferences = references ;
30
30
31
31
SetName ( ) ;
32
- AddNewChildren ( declarations . ToList ( ) ) ;
32
+ AddNewChildren ( ExtractTrackedDeclarationsForProject ( project , declarations ) ) ;
33
33
IsExpanded = true ;
34
34
}
35
35
@@ -75,7 +75,7 @@ public override void Synchronize(List<Declaration> updated)
75
75
76
76
Declaration = match ;
77
77
updated . Remove ( Declaration ) ;
78
- var children = updated . Where ( declaration => declaration . ProjectId . Equals ( Declaration . ProjectId ) ) . ToList ( ) ;
78
+ var children = ExtractTrackedDeclarationsForProject ( Declaration , updated ) ;
79
79
updated . RemoveAll ( declaration => declaration . ProjectId . Equals ( Declaration . ProjectId ) ) ;
80
80
81
81
// Reference synchronization is deferred to AddNewChildren for 2 reasons. First, it doesn't make sense to sling around a List of
@@ -129,7 +129,7 @@ private void SynchronizeReferences()
129
129
130
130
foreach ( var type in types )
131
131
{
132
- AddChild ( new CodeExplorerReferenceFolderViewModel ( this , State . DeclarationFinder , type . ToList ( ) , type . Key ) ) ;
132
+ AddChild ( new CodeExplorerReferenceFolderViewModel ( this , State ? . DeclarationFinder , type . ToList ( ) , type . Key ) ) ;
133
133
}
134
134
}
135
135
@@ -170,5 +170,35 @@ private void SetName()
170
170
171
171
OnNameChanged ( ) ;
172
172
}
173
+
174
+ private static readonly List < DeclarationType > UntrackedTypes = new List < DeclarationType >
175
+ {
176
+ DeclarationType . Parameter ,
177
+ DeclarationType . LineLabel ,
178
+ DeclarationType . UnresolvedMember ,
179
+ DeclarationType . BracketedExpression ,
180
+ DeclarationType . ComAlias
181
+ } ;
182
+
183
+ private static readonly List < DeclarationType > ModuleRestrictedTypes = new List < DeclarationType >
184
+ {
185
+ DeclarationType . Variable ,
186
+ DeclarationType . Control ,
187
+ DeclarationType . Constant
188
+ } ;
189
+
190
+ public static List < Declaration > ExtractTrackedDeclarationsForProject ( Declaration project , List < Declaration > declarations )
191
+ {
192
+ var owned = declarations . Where ( declaration => declaration . ProjectId . Equals ( project . ProjectId ) ) . ToList ( ) ;
193
+
194
+ foreach ( var declaration in owned )
195
+ {
196
+ declarations . Remove ( declaration ) ;
197
+ }
198
+
199
+ return owned . Where ( declaration => ! UntrackedTypes . Contains ( declaration . DeclarationType ) &&
200
+ ! ModuleRestrictedTypes . Contains ( declaration . DeclarationType ) ||
201
+ declaration . ParentDeclaration . DeclarationType . HasFlag ( DeclarationType . Module ) ) . ToList ( ) ;
202
+ }
173
203
}
174
204
}
0 commit comments