55using  Microsoft . CSharp . RuntimeBinder ; 
66using  Rubberduck . Parsing . Inspections . Abstract ; 
77using  Rubberduck . Parsing . Rewriter ; 
8- using  Rubberduck . Parsing . VBA ; 
98using  Rubberduck . Parsing . VBA . Parsing ; 
109using  Rubberduck . VBEditor ; 
1110
@@ -14,11 +13,13 @@ namespace Rubberduck.Inspections.QuickFixes
1413    public  class  QuickFixProvider  :  IQuickFixProvider 
1514    { 
1615        private  readonly  IRewritingManager  _rewritingManager ; 
16+         private  readonly  IQuickFixFailureNotifier  _failureNotifier ; 
1717        private  readonly  Dictionary < Type ,  HashSet < IQuickFix > >  _quickFixes  =  new  Dictionary < Type ,  HashSet < IQuickFix > > ( ) ; 
1818
19-         public  QuickFixProvider ( IRewritingManager  rewritingManager ,  IEnumerable < IQuickFix >  quickFixes ) 
19+         public  QuickFixProvider ( IRewritingManager  rewritingManager ,  IQuickFixFailureNotifier   failureNotifier ,   IEnumerable < IQuickFix >  quickFixes ) 
2020        { 
2121            _rewritingManager  =  rewritingManager ; 
22+             _failureNotifier  =  failureNotifier ; 
2223            foreach  ( var  quickFix  in  quickFixes ) 
2324            { 
2425                foreach  ( var  supportedInspection  in  quickFix . SupportedInspections ) 
@@ -78,7 +79,15 @@ public void Fix(IQuickFix fix, IInspectionResult result)
7879
7980            var  rewriteSession  =  RewriteSession ( fix . TargetCodeKind ) ; 
8081            fix . Fix ( result ,  rewriteSession ) ; 
81-             rewriteSession . TryRewrite ( ) ; 
82+             Apply ( rewriteSession ) ; 
83+         } 
84+ 
85+         private  void  Apply ( IRewriteSession  rewriteSession ) 
86+         { 
87+             if  ( ! rewriteSession . TryRewrite ( ) ) 
88+             { 
89+                 _failureNotifier . NotifyQuickFixExecutionFailure ( rewriteSession . Status ) ; 
90+             } 
8291        } 
8392
8493        private  IRewriteSession  RewriteSession ( CodeKind  targetCodeKind ) 
@@ -115,7 +124,7 @@ public void FixInProcedure(IQuickFix fix, QualifiedMemberName? qualifiedMember,
115124
116125                fix . Fix ( result ,  rewriteSession ) ; 
117126            } 
118-             rewriteSession . TryRewrite ( ) ; 
127+             Apply ( rewriteSession ) ; 
119128        } 
120129
121130        public  void  FixInModule ( IQuickFix  fix ,  QualifiedSelection  selection ,  Type  inspectionType ,  IEnumerable < IInspectionResult >  results ) 
@@ -137,7 +146,7 @@ public void FixInModule(IQuickFix fix, QualifiedSelection selection, Type inspec
137146
138147                fix . Fix ( result ,  rewriteSession ) ; 
139148            } 
140-             rewriteSession . TryRewrite ( ) ; 
149+             Apply ( rewriteSession ) ; 
141150        } 
142151
143152        public  void  FixInProject ( IQuickFix  fix ,  QualifiedSelection  selection ,  Type  inspectionType ,  IEnumerable < IInspectionResult >  results ) 
@@ -159,7 +168,7 @@ public void FixInProject(IQuickFix fix, QualifiedSelection selection, Type inspe
159168
160169                fix . Fix ( result ,  rewriteSession ) ; 
161170            } 
162-             rewriteSession . TryRewrite ( ) ; 
171+             Apply ( rewriteSession ) ; 
163172        } 
164173
165174        public  void  FixAll ( IQuickFix  fix ,  Type  inspectionType ,  IEnumerable < IInspectionResult >  results ) 
@@ -181,7 +190,7 @@ public void FixAll(IQuickFix fix, Type inspectionType, IEnumerable<IInspectionRe
181190
182191                fix . Fix ( result ,  rewriteSession ) ; 
183192            } 
184-             rewriteSession . TryRewrite ( ) ; 
193+             Apply ( rewriteSession ) ; 
185194        } 
186195
187196        public  bool  HasQuickFixes ( IInspectionResult  inspectionResult ) 
0 commit comments