@@ -28,7 +28,7 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
28
28
_folderHelper = folderHelper ;
29
29
_state = state ;
30
30
_state . StateChanged += ParserState_StateChanged ;
31
-
31
+
32
32
_refreshCommand = new DelegateCommand ( param => _state . OnParseRequested ( this ) ,
33
33
param => ! IsBusy && _state . IsDirty ( ) ) ;
34
34
@@ -188,38 +188,38 @@ public string PanelTitle
188
188
189
189
if ( SelectedItem is CodeExplorerProjectViewModel )
190
190
{
191
- var node = ( CodeExplorerProjectViewModel ) SelectedItem ;
191
+ var node = ( CodeExplorerProjectViewModel ) SelectedItem ;
192
192
return node . Declaration . IdentifierName + string . Format ( " - ({0})" , node . Declaration . DeclarationType ) ;
193
193
}
194
194
195
195
if ( SelectedItem is CodeExplorerComponentViewModel )
196
196
{
197
- var node = ( CodeExplorerComponentViewModel ) SelectedItem ;
197
+ var node = ( CodeExplorerComponentViewModel ) SelectedItem ;
198
198
return node . Declaration . IdentifierName + string . Format ( " - ({0})" , node . Declaration . DeclarationType ) ;
199
199
}
200
200
201
201
if ( SelectedItem is CodeExplorerMemberViewModel )
202
202
{
203
- var node = ( CodeExplorerMemberViewModel ) SelectedItem ;
203
+ var node = ( CodeExplorerMemberViewModel ) SelectedItem ;
204
204
return node . Declaration . IdentifierName + string . Format ( " - ({0})" , node . Declaration . DeclarationType ) ;
205
205
}
206
206
207
207
return SelectedItem . Name ;
208
208
}
209
209
}
210
-
210
+
211
211
public string Description
212
212
{
213
213
get
214
214
{
215
215
if ( SelectedItem is ICodeExplorerDeclarationViewModel )
216
216
{
217
- return ( ( ICodeExplorerDeclarationViewModel ) SelectedItem ) . Declaration . DescriptionString ;
217
+ return ( ( ICodeExplorerDeclarationViewModel ) SelectedItem ) . Declaration . DescriptionString ;
218
218
}
219
219
220
220
if ( SelectedItem is CodeExplorerCustomFolderViewModel )
221
221
{
222
- return ( ( CodeExplorerCustomFolderViewModel ) SelectedItem ) . FolderAttribute ;
222
+ return ( ( CodeExplorerCustomFolderViewModel ) SelectedItem ) . FolderAttribute ;
223
223
}
224
224
225
225
return string . Empty ;
@@ -237,47 +237,44 @@ public ObservableCollection<CodeExplorerItemViewModel> Projects
237
237
set
238
238
{
239
239
_projects = new ObservableCollection < CodeExplorerItemViewModel > ( value . OrderBy ( o => o . NameWithSignature ) ) ;
240
-
240
+
241
241
ReorderChildNodes ( _projects ) ;
242
242
OnPropertyChanged ( ) ;
243
243
}
244
244
}
245
245
246
246
private void ParserState_StateChanged ( object sender , EventArgs e )
247
247
{
248
- UiDispatcher . InvokeAsync ( ( ) =>
248
+ if ( Projects == null )
249
249
{
250
- if ( Projects == null )
251
- {
252
- Projects = new ObservableCollection < CodeExplorerItemViewModel > ( ) ;
253
- }
250
+ Projects = new ObservableCollection < CodeExplorerItemViewModel > ( ) ;
251
+ }
254
252
255
- IsBusy = _state . Status < ParserState . ResolvedDeclarations ;
256
- if ( _state . Status != ParserState . ResolvedDeclarations )
257
- {
258
- return ;
259
- }
253
+ IsBusy = _state . Status < ParserState . ResolvedDeclarations ;
254
+ if ( _state . Status != ParserState . ResolvedDeclarations )
255
+ {
256
+ return ;
257
+ }
260
258
261
- var userDeclarations = _state . AllUserDeclarations
262
- . GroupBy ( declaration => declaration . Project )
263
- . Where ( grouping => grouping . Key != null )
264
- . ToList ( ) ;
259
+ var userDeclarations = _state . AllUserDeclarations
260
+ . GroupBy ( declaration => declaration . Project )
261
+ . Where ( grouping => grouping . Key != null )
262
+ . ToList ( ) ;
265
263
266
- if ( userDeclarations . Any (
264
+ if ( userDeclarations . Any (
267
265
grouping => grouping . All ( declaration => declaration . DeclarationType != DeclarationType . Project ) ) )
268
- {
269
- return ;
270
- }
266
+ {
267
+ return ;
268
+ }
271
269
272
- var newProjects = userDeclarations . Select ( grouping =>
273
- new CodeExplorerProjectViewModel ( _folderHelper ,
274
- grouping . SingleOrDefault ( declaration => declaration . DeclarationType == DeclarationType . Project ) ,
275
- grouping ) ) . ToList ( ) ;
270
+ var newProjects = userDeclarations . Select ( grouping =>
271
+ new CodeExplorerProjectViewModel ( _folderHelper ,
272
+ grouping . SingleOrDefault ( declaration => declaration . DeclarationType == DeclarationType . Project ) ,
273
+ grouping ) ) . ToList ( ) ;
276
274
277
- UpdateNodes ( Projects , newProjects ) ;
275
+ UpdateNodes ( Projects , newProjects ) ;
278
276
279
- Projects = new ObservableCollection < CodeExplorerItemViewModel > ( newProjects ) ;
280
- } ) ;
277
+ Projects = new ObservableCollection < CodeExplorerItemViewModel > ( newProjects ) ;
281
278
}
282
279
283
280
private void UpdateNodes ( IEnumerable < CodeExplorerItemViewModel > oldList ,
@@ -406,7 +403,7 @@ private void SetErrorState(CodeExplorerItemViewModel itemNode, VBComponent compo
406
403
407
404
if ( node is CodeExplorerComponentViewModel )
408
405
{
409
- var componentNode = ( CodeExplorerComponentViewModel ) node ;
406
+ var componentNode = ( CodeExplorerComponentViewModel ) node ;
410
407
if ( componentNode . GetSelectedDeclaration ( ) . QualifiedName . QualifiedModuleName . Component == component )
411
408
{
412
409
componentNode . IsErrorState = true ;
@@ -475,8 +472,8 @@ private void SetErrorState(CodeExplorerItemViewModel itemNode, VBComponent compo
475
472
// this is a special case--we have to reset SelectedItem to prevent a crash
476
473
private void ExecuteRemoveComand ( object param )
477
474
{
478
- var node = ( CodeExplorerComponentViewModel ) SelectedItem ;
479
- SelectedItem = Projects . First ( p => ( ( CodeExplorerProjectViewModel ) p ) . Declaration . Project == node . Declaration . Project ) ;
475
+ var node = ( CodeExplorerComponentViewModel ) SelectedItem ;
476
+ SelectedItem = Projects . First ( p => ( ( CodeExplorerProjectViewModel ) p ) . Declaration . Project == node . Declaration . Project ) ;
480
477
481
478
_externalRemoveCommand . Execute ( param ) ;
482
479
}
0 commit comments