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