Skip to content

Commit b522309

Browse files
committed
DI IMessageBox
1 parent af485fb commit b522309

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

RetailCoder.VBE/Inspections/UseMeaningfulNameInspection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using Rubberduck.Parsing.VBA;
4+
using Rubberduck.UI;
45
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
56

67
namespace Rubberduck.Inspections
@@ -28,7 +29,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(RubberduckPars
2829
char.IsDigit(declaration.IdentifierName.Last()) ||
2930
!declaration.IdentifierName.Any(c => new[] {'a', 'e', 'i', 'o', 'u', 'y'}.Contains(c))
3031
))
31-
.Select(issue => new UseMeaningfulNameInspectionResult(this, issue, state, _wrapperFactory))
32+
.Select(issue => new UseMeaningfulNameInspectionResult(this, issue, state, _wrapperFactory, new MessageBox()))
3233
.ToList();
3334

3435
return issues;

RetailCoder.VBE/Inspections/UseMeaningfulNameInspectionResult.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class UseMeaningfulNameInspectionResult : CodeInspectionResultBase
1414
{
1515
private readonly IEnumerable<CodeInspectionQuickFix> _quickFixes;
1616

17-
public UseMeaningfulNameInspectionResult(IInspection inspection, Declaration target, RubberduckParserState parserState, ICodePaneWrapperFactory wrapperFactory)
17+
public UseMeaningfulNameInspectionResult(IInspection inspection, Declaration target, RubberduckParserState parserState, ICodePaneWrapperFactory wrapperFactory, IMessageBox messageBox)
1818
: base(inspection, string.Format(inspection.Description, target.IdentifierName), target)
1919
{
2020
_quickFixes = new[]
2121
{
22-
new RenameDeclarationQuickFix(target.Context, target.QualifiedSelection, target, parserState, wrapperFactory),
22+
new RenameDeclarationQuickFix(target.Context, target.QualifiedSelection, target, parserState, wrapperFactory, messageBox),
2323
};
2424
}
2525

@@ -34,13 +34,15 @@ public class RenameDeclarationQuickFix : CodeInspectionQuickFix
3434
private readonly Declaration _target;
3535
private readonly RubberduckParserState _parserState;
3636
private readonly ICodePaneWrapperFactory _wrapperFactory;
37+
private readonly IMessageBox _messageBox;
3738

38-
public RenameDeclarationQuickFix(ParserRuleContext context, QualifiedSelection selection, Declaration target, RubberduckParserState parserState, ICodePaneWrapperFactory wrapperFactory)
39+
public RenameDeclarationQuickFix(ParserRuleContext context, QualifiedSelection selection, Declaration target, RubberduckParserState parserState, ICodePaneWrapperFactory wrapperFactory, IMessageBox messageBox)
3940
: base(context, selection, string.Format(RubberduckUI.Rename_DeclarationType, RubberduckUI.ResourceManager.GetString("DeclarationType_" + target.DeclarationType, RubberduckUI.Culture)))
4041
{
4142
_target = target;
4243
_parserState = parserState;
4344
_wrapperFactory = wrapperFactory;
45+
_messageBox = messageBox;
4446
}
4547

4648
public override void Fix()
@@ -49,8 +51,8 @@ public override void Fix()
4951

5052
using (var view = new RenameDialog())
5153
{
52-
var factory = new RenamePresenterFactory(vbe, view, _parserState, new MessageBox(), _wrapperFactory);
53-
var refactoring = new RenameRefactoring(factory, new ActiveCodePaneEditor(vbe, _wrapperFactory), new MessageBox());
54+
var factory = new RenamePresenterFactory(vbe, view, _parserState, _messageBox, _wrapperFactory);
55+
var refactoring = new RenameRefactoring(factory, new ActiveCodePaneEditor(vbe, _wrapperFactory), _messageBox);
5456
refactoring.Refactor(_target);
5557
}
5658
}

0 commit comments

Comments
 (0)