@@ -517,6 +517,47 @@ public bool ClearStateCache(VBComponent component, bool setStateChanged = false)
517517 return success ;
518518 }
519519
520+ public bool RemoveRenamedComponent ( VBComponent component , string oldComponentName )
521+ {
522+ var match = new QualifiedModuleName ( component , oldComponentName ) ;
523+ var keys = _declarations . Keys . Where ( kvp => kvp . ComponentName == oldComponentName && kvp . ProjectId == match . ProjectId ) ;
524+
525+ var success = true ;
526+ var declarationsRemoved = 0 ;
527+ foreach ( var key in keys )
528+ {
529+ ConcurrentDictionary < Declaration , byte > declarations = null ;
530+ success = success && ( ! _declarations . ContainsKey ( key ) || _declarations . TryRemove ( key , out declarations ) ) ;
531+ declarationsRemoved = declarations == null ? 0 : declarations . Count ;
532+
533+ IParseTree tree ;
534+ success = success && ( ! _parseTrees . ContainsKey ( key ) || _parseTrees . TryRemove ( key , out tree ) ) ;
535+
536+ int contentHash ;
537+ success = success && ( ! _moduleContentHashCodes . ContainsKey ( key ) || _moduleContentHashCodes . TryRemove ( key , out contentHash ) ) ;
538+
539+ IList < IAnnotation > annotations ;
540+ success = success && ( ! _annotations . ContainsKey ( key ) || _annotations . TryRemove ( key , out annotations ) ) ;
541+
542+ ITokenStream stream ;
543+ success = success && ( ! _tokenStreams . ContainsKey ( key ) || _tokenStreams . TryRemove ( key , out stream ) ) ;
544+
545+ ParserState state ;
546+ success = success && ( ! _moduleStates . ContainsKey ( key ) || _moduleStates . TryRemove ( key , out state ) ) ;
547+
548+ SyntaxErrorException exception ;
549+ success = success && ( ! _moduleExceptions . ContainsKey ( key ) || _moduleExceptions . TryRemove ( key , out exception ) ) ;
550+
551+ IList < CommentNode > nodes ;
552+ success = success && ( ! _comments . ContainsKey ( key ) || _comments . TryRemove ( key , out nodes ) ) ;
553+ }
554+
555+ OnStateChanged ( ) ;
556+
557+ Debug . WriteLine ( "RemoveRenamedComponent({0}): {1} - {2} declarations removed" , oldComponentName , success ? "succeeded" : "failed" , declarationsRemoved ) ;
558+ return success ;
559+ }
560+
520561 public void AddTokenStream ( VBComponent component , ITokenStream stream )
521562 {
522563 _tokenStreams [ new QualifiedModuleName ( component ) ] = stream ;
0 commit comments