Skip to content

Commit 3faf03a

Browse files
committed
merged/resolved conflicts
2 parents e5bef2f + 2d1aa69 commit 3faf03a

File tree

189 files changed

+5472
-3293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+5472
-3293
lines changed

RetailCoder.VBE/App.cs

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
using Rubberduck.Parsing.VBA;
1010
using Rubberduck.Settings;
1111
using Rubberduck.UI;
12-
using Rubberduck.UI.CodeInspections;
12+
using Rubberduck.UI.Command.MenuItems;
1313
using Rubberduck.UI.ParserErrors;
14-
using Rubberduck.VBEditor;
15-
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
1614

1715
namespace Rubberduck
1816
{
1917
public class App : IDisposable
2018
{
19+
private readonly IMessageBox _messageBox;
20+
private readonly IParserErrorsPresenterFactory _parserErrorsPresenterFactory;
21+
private readonly IRubberduckParserFactory _parserFactory;
22+
private readonly IInspectorFactory _inspectorFactory;
23+
private readonly IGeneralConfigService _configService;
24+
private readonly IAppMenu _appMenus;
25+
2126
private readonly VBE _vbe;
2227
private readonly AddIn _addIn;
2328
private Inspector _inspector;
@@ -27,40 +32,49 @@ public class App : IDisposable
2732
private readonly IRubberduckCodePaneFactory _factory;
2833
private readonly Logger _logger;
2934
private IRubberduckParser _parser;
35+
private IParserErrorsPresenter _parserErrorsPresenter;
3036

3137
private Configuration _config;
32-
private RubberduckMenu _menu;
33-
private FormContextMenu _formContextMenu;
34-
private CodeInspectionsToolbar _codeInspectionsToolbar;
35-
private bool _displayToolbar = false;
36-
private Point _toolbarCoords = new Point(-1, -1);
3738

38-
public App(VBE vbe, AddIn addIn)
39+
public App(IMessageBox messageBox,
40+
IParserErrorsPresenterFactory parserErrorsPresenterFactory,
41+
IRubberduckParserFactory parserFactory,
42+
IInspectorFactory inspectorFactory,
43+
IGeneralConfigService configService,
44+
IAppMenu appMenus)
3945
{
46+
_messageBox = messageBox;
47+
_parserErrorsPresenterFactory = parserErrorsPresenterFactory;
48+
_parserFactory = parserFactory;
49+
_inspectorFactory = inspectorFactory;
50+
_configService = configService;
51+
_appMenus = appMenus;
4052
_vbe = vbe;
4153
_addIn = addIn;
4254
_factory = new RubberduckCodePaneFactory();
4355
_logger = LogManager.GetCurrentClassLogger();
4456

45-
_parserErrorsPresenter = new ParserErrorsPresenter(vbe, addIn);
4657
_configService.SettingsChanged += _configService_SettingsChanged;
58+
}
4759

48-
_editor = new ActiveCodePaneEditor(vbe, _factory);
60+
public void Startup()
61+
{
62+
CleanReloadConfig();
4963

50-
LoadConfig();
64+
_appMenus.Initialize();
65+
_appMenus.Localize();
66+
}
5167

68+
private void CleanReloadConfig()
69+
{
70+
LoadConfig();
5271
CleanUp();
53-
5472
Setup();
5573
}
5674

5775
private void _configService_SettingsChanged(object sender, EventArgs e)
5876
{
59-
LoadConfig();
60-
61-
CleanUp();
62-
63-
Setup();
77+
CleanReloadConfig();
6478
}
6579

6680
private void LoadConfig()
@@ -85,28 +99,13 @@ private void LoadConfig()
8599

86100
private void Setup()
87101
{
88-
_parser = new RubberduckParser(_factory);
102+
_parser = _parserFactory.Create();
89103
_parser.ParseStarted += _parser_ParseStarted;
90104
_parser.ParserError += _parser_ParserError;
91105

92-
_inspector = new Inspector(_parser, _configService);
93-
94-
_parserErrorsPresenter = new ParserErrorsPresenter(_vbe, _addIn);
95-
96-
_menu = new RubberduckMenu(_vbe, _addIn, _configService, _parser, _editor, _inspector, _factory);
97-
_menu.Initialize();
98-
99-
_formContextMenu = new FormContextMenu(_vbe, _parser, _editor, _factory);
100-
_formContextMenu.Initialize();
101-
102-
_codeInspectionsToolbar = new CodeInspectionsToolbar(_vbe, _inspector);
103-
_codeInspectionsToolbar.Initialize();
106+
_inspectorFactory.Create();
104107

105-
if (_toolbarCoords.X != -1 && _toolbarCoords.Y != -1)
106-
{
107-
_codeInspectionsToolbar.ToolbarCoords = _toolbarCoords;
108-
}
109-
_codeInspectionsToolbar.ToolbarVisible = _displayToolbar;
108+
_parserErrorsPresenter = _parserErrorsPresenterFactory.Create();
110109
}
111110

112111
private void _parser_ParseStarted(object sender, ParseStartedEventArgs e)
@@ -134,33 +133,6 @@ protected virtual void Dispose(bool disposing)
134133

135134
private void CleanUp()
136135
{
137-
if (_menu != null)
138-
{
139-
_menu.Dispose();
140-
}
141-
142-
if (_formContextMenu != null)
143-
{
144-
_formContextMenu.Dispose();
145-
}
146-
147-
if (_codeInspectionsToolbar != null)
148-
{
149-
_displayToolbar = _codeInspectionsToolbar.ToolbarVisible;
150-
_toolbarCoords = _codeInspectionsToolbar.ToolbarCoords;
151-
_codeInspectionsToolbar.Dispose();
152-
}
153-
154-
if (_inspector != null)
155-
{
156-
_inspector.Dispose();
157-
}
158-
159-
if (_parserErrorsPresenter != null)
160-
{
161-
_parserErrorsPresenter.Dispose();
162-
}
163-
164136
if (_parser != null)
165137
{
166138
_parser.ParseStarted -= _parser_ParseStarted;

RetailCoder.VBE/AppMenu.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections.Generic;
2+
using Rubberduck.UI.Command;
3+
using Rubberduck.UI.Command.MenuItems;
4+
using Rubberduck.UI.Command.MenuItems.ParentMenus;
5+
6+
namespace Rubberduck
7+
{
8+
public class AppMenu : IAppMenu
9+
{
10+
private readonly IEnumerable<IParentMenuItem> _menus;
11+
12+
public AppMenu(IEnumerable<IParentMenuItem> menus)
13+
{
14+
_menus = menus;
15+
}
16+
17+
public void Initialize()
18+
{
19+
foreach (var menu in _menus)
20+
{
21+
menu.Initialize();
22+
}
23+
}
24+
25+
public void Localize()
26+
{
27+
foreach (var menu in _menus)
28+
{
29+
menu.Localize();
30+
}
31+
}
32+
}
33+
}

RetailCoder.VBE/Extension.cs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
using System.Windows.Forms;
55
using Extensibility;
66
using Microsoft.Vbe.Interop;
7+
using Ninject;
8+
using Ninject.Extensions.Factory;
9+
using Rubberduck.Root;
710
using Rubberduck.UI;
8-
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
911

1012
namespace Rubberduck
1113
{
1214
[ComVisible(true)]
1315
[Guid(ClassId)]
1416
[ProgId(ProgId)]
1517
[EditorBrowsable(EditorBrowsableState.Never)]
16-
// ReSharper disable once InconsistentNaming
17-
public class _Extension : IDTExtensibility2, IDisposable
18+
// ReSharper disable once InconsistentNaming // note: underscore prefix hides class from COM API
19+
public class _Extension : IDTExtensibility2
1820
{
1921
private const string ClassId = "8D052AD8-BBD2-4C59-8DEC-F697CA1F8A66";
2022
private const string ProgId = "Rubberduck.Extension";
2123

22-
private App _app;
24+
private readonly IKernel _kernel = new StandardKernel(new FuncModule());
2325

2426
public void OnAddInsUpdate(ref Array custom)
2527
{
@@ -29,15 +31,19 @@ public void OnBeginShutdown(ref Array custom)
2931
{
3032
}
3133

34+
// ReSharper disable InconsistentNaming
3235
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
3336
{
3437
try
3538
{
36-
_app = new App((VBE)Application, (AddIn)AddInInst);
39+
_kernel.Load(new RubberduckModule(_kernel, (VBE)Application, (AddIn)AddInInst));
40+
_kernel.Load(new CommandBarsModule(_kernel));
41+
var app = _kernel.Get<App>();
42+
app.Startup();
3743
}
3844
catch (Exception exception)
3945
{
40-
MessageBox.Show(exception.Message, RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
46+
System.Windows.Forms.MessageBox.Show(exception.ToString(), RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
4147
}
4248
}
4349

@@ -48,20 +54,7 @@ public void OnStartupComplete(ref Array custom)
4854

4955
public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
5056
{
51-
Dispose();
52-
}
53-
54-
public void Dispose()
55-
{
56-
Dispose(true);
57-
}
58-
59-
protected virtual void Dispose(bool disposing)
60-
{
61-
if (disposing & _app != null)
62-
{
63-
_app.Dispose();
64-
}
57+
_kernel.Dispose();
6558
}
6659
}
6760
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Rubberduck.Inspections
2+
{
3+
public abstract class CodeInspectionQuickFix
4+
{
5+
private readonly string _description;
6+
7+
public CodeInspectionQuickFix(string description)
8+
{
9+
_description = description;
10+
}
11+
12+
public string Description { get { return _description; } }
13+
14+
public abstract void Fix();
15+
}
16+
}

RetailCoder.VBE/Inspections/DefaultProjectNameInspection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace Rubberduck.Inspections
99
{
1010
public class DefaultProjectNameInspection : IInspection
1111
{
12-
private readonly IRubberduckCodePaneFactory _factory;
12+
private readonly ICodePaneWrapperFactory _wrapperFactory;
1313

1414
public DefaultProjectNameInspection()
1515
{
16-
_factory = new RubberduckCodePaneFactory();
16+
_wrapperFactory = new CodePaneWrapperFactory();
1717
Severity = CodeInspectionSeverity.Suggestion;
1818
}
1919

@@ -28,7 +28,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
2828
.Where(declaration => !declaration.IsBuiltIn
2929
&& declaration.DeclarationType == DeclarationType.Project
3030
&& declaration.IdentifierName.StartsWith("VBAProject"))
31-
.Select(issue => new DefaultProjectNameInspectionResult(string.Format(Description, issue.IdentifierName), Severity, issue, parseResult, _factory))
31+
.Select(issue => new DefaultProjectNameInspectionResult(string.Format(Description, issue.IdentifierName), Severity, issue, parseResult, _wrapperFactory))
3232
.ToList();
3333

3434
return issues;

RetailCoder.VBE/Inspections/DefaultProjectNameInspectionResult.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace Rubberduck.Inspections
1313
public class DefaultProjectNameInspectionResult : CodeInspectionResultBase
1414
{
1515
private readonly VBProjectParseResult _parseResult;
16-
private readonly IRubberduckCodePaneFactory _factory;
16+
private readonly ICodePaneWrapperFactory _wrapperFactory;
1717

18-
public DefaultProjectNameInspectionResult(string inspection, CodeInspectionSeverity type, Declaration target, VBProjectParseResult parseResult, IRubberduckCodePaneFactory factory)
18+
public DefaultProjectNameInspectionResult(string inspection, CodeInspectionSeverity type, Declaration target, VBProjectParseResult parseResult, ICodePaneWrapperFactory wrapperFactory)
1919
: base(inspection, type, target)
2020
{
2121
_parseResult = parseResult;
22-
_factory = factory;
22+
_wrapperFactory = wrapperFactory;
2323
}
2424

2525
public override IDictionary<string, Action> GetQuickFixes()
@@ -37,8 +37,8 @@ private void RenameProject()
3737

3838
using (var view = new RenameDialog())
3939
{
40-
var factory = new RenamePresenterFactory(vbe, view, _parseResult, new RubberduckMessageBox(), _factory);
41-
var refactoring = new RenameRefactoring(factory, new ActiveCodePaneEditor(vbe, _factory), new RubberduckMessageBox());
40+
var factory = new RenamePresenterFactory(vbe, view, _parseResult, new MessageBox(), _wrapperFactory);
41+
var refactoring = new RenameRefactoring(factory, new ActiveCodePaneEditor(vbe, _wrapperFactory), new MessageBox());
4242
refactoring.Refactor(Target);
4343
}
4444
}

RetailCoder.VBE/Inspections/Inspector.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@
1010

1111
namespace Rubberduck.Inspections
1212
{
13+
public interface IInspectorFactory
14+
{
15+
IInspector Create();
16+
}
17+
1318
public class Inspector : IInspector, IDisposable
1419
{
1520
private readonly IRubberduckParser _parser;
1621
private readonly IGeneralConfigService _configService;
17-
private readonly IList<IInspection> _inspections;
22+
private readonly IEnumerable<IInspection> _inspections;
1823

19-
public Inspector(IRubberduckParser parser, IGeneralConfigService configService)
24+
public Inspector(IRubberduckParser parser, IGeneralConfigService configService, IEnumerable<IInspection> inspections)
2025
{
26+
_inspections = inspections;
27+
2128
_parser = parser;
2229
_parser.ParseStarted += _parser_ParseStarted;
2330
_parser.ParseCompleted += _parser_ParseCompleted;
2431

2532
_configService = configService;
26-
_inspections = configService.GetImplementedCodeInspections();
2733
configService.SettingsChanged += ConfigServiceSettingsChanged;
2834
UpdateInspectionSeverity();
2935
}

RetailCoder.VBE/Inspections/ObsoleteCommentSyntaxInspectionResult.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ private void RemoveComment()
8383
module.DeleteLines(Comment.QualifiedSelection.Selection.StartLine, Comment.QualifiedSelection.Selection.LineCount);
8484
}
8585

86-
if (!string.IsNullOrEmpty(code))
87-
{
88-
module.ReplaceLine(Comment.QualifiedSelection.Selection.StartLine, code);
89-
}
86+
module.ReplaceLine(Comment.QualifiedSelection.Selection.StartLine, code);
9087
}
9188
}
9289
}

RetailCoder.VBE/Inspections/OptionBaseInspection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace Rubberduck.Inspections
1010
{
1111
public class OptionBaseInspection : IInspection
1212
{
13-
private readonly IRubberduckCodePaneFactory _factory;
13+
private readonly ICodePaneWrapperFactory _wrapperFactory;
1414

1515
public OptionBaseInspection()
1616
{
17-
_factory = new RubberduckCodePaneFactory();
17+
_wrapperFactory = new CodePaneWrapperFactory();
1818
Severity = CodeInspectionSeverity.Warning;
1919
}
2020

@@ -37,7 +37,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
3737
}
3838

3939
var issues = options.Where(option => ((VBAParser.OptionBaseStmtContext)option.Context).INTEGERLITERAL().GetText() == "1")
40-
.Select(issue => new OptionBaseInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName, _factory));
40+
.Select(issue => new OptionBaseInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName, _wrapperFactory));
4141

4242
return issues;
4343
}

0 commit comments

Comments
 (0)