@@ -337,8 +337,47 @@ async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBCom
337
337
_sourceControlPanelVM . HandleRenamedComponent ( e . Item , e . OldName ) ;
338
338
339
339
_logger . Debug ( "Component '{0}' was renamed to '{1}'." , e . OldName , e . Item . Name ) ;
340
+
341
+ var projectId = e . Item . Collection . Parent . HelpFile ;
342
+ var componentDeclaration = _parser . State . AllDeclarations . FirstOrDefault ( f =>
343
+ f . ProjectId == projectId &&
344
+ f . DeclarationType == DeclarationType . ClassModule &&
345
+ f . IdentifierName == e . OldName ) ;
346
+
347
+ if ( e . Item . Type == vbext_ComponentType . vbext_ct_Document &&
348
+ componentDeclaration != null &&
349
+
350
+ // according to ThunderFrame, Excel is the only one we explicitly support
351
+ // with two Document-component types just skip the Worksheet component
352
+ ( ( ClassModuleDeclaration ) componentDeclaration ) . Supertypes . All ( a => a . IdentifierName != "Worksheet" ) )
353
+ {
354
+ _componentsEventsSinks . Remove ( projectId ) ;
355
+ _referencesEventsSinks . Remove ( projectId ) ;
356
+ _parser . State . RemoveProject ( projectId ) ;
357
+
358
+ _logger . Debug ( "Project '{0}' was removed." , e . Item . Name ) ;
359
+ Tuple < IConnectionPoint , int > componentsTuple ;
360
+ if ( _componentsEventsConnectionPoints . TryGetValue ( projectId , out componentsTuple ) )
361
+ {
362
+ componentsTuple . Item1 . Unadvise ( componentsTuple . Item2 ) ;
363
+ _componentsEventsConnectionPoints . Remove ( projectId ) ;
364
+ }
365
+
366
+ Tuple < IConnectionPoint , int > referencesTuple ;
367
+ if ( _referencesEventsConnectionPoints . TryGetValue ( projectId , out referencesTuple ) )
368
+ {
369
+ referencesTuple . Item1 . Unadvise ( referencesTuple . Item2 ) ;
370
+ _referencesEventsConnectionPoints . Remove ( projectId ) ;
371
+ }
340
372
341
- _parser . State . RemoveRenamedComponent ( e . Item , e . OldName ) ;
373
+ _parser . State . AddProject ( e . Item . Collection . Parent ) ;
374
+ }
375
+ else
376
+ {
377
+ _parser . State . RemoveRenamedComponent ( e . Item , e . OldName ) ;
378
+ }
379
+
380
+ _parser . State . OnParseRequested ( this ) ;
342
381
}
343
382
344
383
async void sink_ComponentRemoved ( object sender , DispatcherEventArgs < VBComponent > e )
0 commit comments