Skip to content

Commit 99b8a33

Browse files
committed
Cleaned up namespace, demagicked numbers
1 parent 31c017e commit 99b8a33

File tree

9 files changed

+48
-31
lines changed

9 files changed

+48
-31
lines changed

Rubberduck.Main/Root/RubberduckIoCInstaller.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
using Rubberduck.VBEditor.Utility;
5151
using Rubberduck.AutoComplete;
5252
using Rubberduck.CodeAnalysis.CodeMetrics;
53-
using Rubberduck.VBEditor.Host;
53+
using Rubberduck.VBEditor;
5454

5555
namespace Rubberduck.Root
5656
{
@@ -401,7 +401,7 @@ private Type[] CodePaneContextMenuItems()
401401

402402
private void RegisterFormDesignerContextMenu(IWindsorContainer container)
403403
{
404-
var location = _addin.CommandBarLocations[CommandBarSite.MsForms];
404+
var location = _addin.CommandBarLocations[CommandBarSite.MsForm];
405405
var controls = MainCommandBarControls(location.ParentId);
406406
var beforeIndex = FindRubberduckMenuInsertionIndex(controls, location.BeforeControlId);
407407
var menuItemTypes = FormDesignerContextMenuItems();
@@ -419,7 +419,7 @@ private Type[] FormDesignerContextMenuItems()
419419

420420
private void RegisterFormDesignerControlContextMenu(IWindsorContainer container)
421421
{
422-
var location = _addin.CommandBarLocations[CommandBarSite.MsFormsControl];
422+
var location = _addin.CommandBarLocations[CommandBarSite.MsFormControl];
423423
var controls = MainCommandBarControls(location.ParentId);
424424
var beforeIndex = FindRubberduckMenuInsertionIndex(controls, location.BeforeControlId);
425425
var menuItemTypes = FormDesignerContextMenuItems();

Rubberduck.VBEEditor/Host/CommandBarLocation.cs renamed to Rubberduck.VBEEditor/CommandBarLocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Rubberduck.VBEditor.Host
1+
namespace Rubberduck.VBEditor
22
{
33
public class CommandBarLocation
44
{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
namespace Rubberduck.VBEditor.Host
1+
namespace Rubberduck.VBEditor
22
{
33
public enum CommandBarSite
44
{
55
MenuBar,
66
CodeWindow,
77
ProjectExplorer,
8-
MsForms,
9-
MsFormsControl
8+
MsForm,
9+
MsFormControl
1010
}
1111
}

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
<Compile Include="Factories\ISafeComWrapperProvider.cs" />
6767
<Compile Include="Factories\VBEFactory.cs" />
6868
<Compile Include="HashCode.cs" />
69-
<Compile Include="Host\CommandBarLocation.cs" />
69+
<Compile Include="CommandBarLocation.cs" />
7070
<Compile Include="ISourceCodeHandler.cs" />
7171
<Compile Include="SafeComWrappers\Abstract\HostApplicationBase.cs" />
7272
<Compile Include="SafeComWrappers\Abstract\ISafeComWrapper.cs" />
73-
<Compile Include="Host\CommandBarSite.cs" />
73+
<Compile Include="CommandBarSite.cs" />
7474
<Compile Include="SafeComWrappers\SafeComWrapper.cs" />
7575
<Compile Include="SafeComWrappers\SafeRedirectedEventedComWrapper.cs" />
7676
<Compile Include="SafeComWrappers\VB\Abstract\IHostApplication.cs" />

Rubberduck.VBEEditor/SafeComWrappers/VB/Abstract/IAddIn.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using Rubberduck.VBEditor.Host;
43

54
namespace Rubberduck.VBEditor.SafeComWrappers.Abstract
65
{

Rubberduck.VBEditor.VB6/SafeComWrappers/VB/AddIn.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
3-
using Rubberduck.VBEditor.Host;
43
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
54
using VB = Microsoft.Vbe.Interop.VB6;
65

@@ -9,16 +8,30 @@ namespace Rubberduck.VBEditor.SafeComWrappers.VB6
98
{
109
public class AddIn : SafeComWrapper<VB.AddIn>, IAddIn
1110
{
11+
12+
private const int MenuBar = 1;
13+
private const int CodeWindow = 15;
14+
private const int ProjectExplorer = 22;
15+
private const int MsForm = 20;
16+
private const int MsFormControl = 21;
17+
18+
private const int WindowMenu = 30009;
19+
private const int ListProperties = 2529;
20+
private const int ProjectProperties = 2578;
21+
private const int UpdateUserControls = 746;
22+
private const int ViewCode = 2558;
23+
24+
1225
public AddIn(VB.AddIn target, bool rewrapping = false)
1326
: base(target, rewrapping)
14-
{
27+
{
1528
CommandBarLocations = new ReadOnlyDictionary<CommandBarSite, CommandBarLocation>(new Dictionary<CommandBarSite, CommandBarLocation>
1629
{
17-
{CommandBarSite.MenuBar, new CommandBarLocation(1, 30009)},
18-
{CommandBarSite.CodeWindow, new CommandBarLocation(15, 2529)},
19-
{CommandBarSite.ProjectExplorer, new CommandBarLocation(22, 2578)},
20-
{CommandBarSite.MsForms, new CommandBarLocation(20, 746)},
21-
{CommandBarSite.MsFormsControl, new CommandBarLocation(21, 2558)}
30+
{CommandBarSite.MenuBar, new CommandBarLocation(MenuBar, WindowMenu)},
31+
{CommandBarSite.CodeWindow, new CommandBarLocation(CodeWindow, ListProperties)},
32+
{CommandBarSite.ProjectExplorer, new CommandBarLocation(ProjectExplorer, ProjectProperties)},
33+
{CommandBarSite.MsForm, new CommandBarLocation(MsForm, UpdateUserControls)},
34+
{CommandBarSite.MsFormControl, new CommandBarLocation(MsFormControl, ViewCode)}
2235
});
2336
}
2437

Rubberduck.VBEditor.VBA/SafeComWrappers/VB/AddIn.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
3-
using Rubberduck.VBEditor.Host;
43
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
54
using VB = Microsoft.Vbe.Interop;
65

@@ -9,16 +8,27 @@ namespace Rubberduck.VBEditor.SafeComWrappers.VBA
98
{
109
public class AddIn : SafeComWrapper<VB.AddIn>, IAddIn
1110
{
11+
private const int MenuBar = 1;
12+
private const int CodeWindow = 9;
13+
private const int ProjectExplorer = 14;
14+
private const int MsForm = 17;
15+
private const int MsFormControl = 18;
16+
17+
private const int WindowMenu = 30009;
18+
private const int ListProperties = 2529;
19+
private const int ProjectProperties = 2578;
20+
private const int ViewCode = 2558;
21+
1222
public AddIn(VB.AddIn target, bool rewrapping = false)
1323
: base(target, rewrapping)
1424
{
1525
CommandBarLocations = new ReadOnlyDictionary<CommandBarSite, CommandBarLocation>(new Dictionary<CommandBarSite, CommandBarLocation>
1626
{
17-
{CommandBarSite.MenuBar, new CommandBarLocation(1, 30009)},
18-
{CommandBarSite.CodeWindow, new CommandBarLocation(9, 2529)},
19-
{CommandBarSite.ProjectExplorer, new CommandBarLocation(14, 2578)},
20-
{CommandBarSite.MsForms, new CommandBarLocation(17, 2558)},
21-
{CommandBarSite.MsFormsControl, new CommandBarLocation(18, 2558)}
27+
{CommandBarSite.MenuBar, new CommandBarLocation(MenuBar, WindowMenu)},
28+
{CommandBarSite.CodeWindow, new CommandBarLocation(CodeWindow, ListProperties)},
29+
{CommandBarSite.ProjectExplorer, new CommandBarLocation(ProjectExplorer, ProjectProperties)},
30+
{CommandBarSite.MsForm, new CommandBarLocation(MsForm, ViewCode)},
31+
{CommandBarSite.MsFormControl, new CommandBarLocation(MsFormControl, ViewCode)}
2232
});
2333

2434
}

RubberduckTests/IoCContainer/IoCRegistrationTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System.Collections.Generic;
2-
using System.Collections.ObjectModel;
32
using Castle.Windsor;
43
using NUnit.Framework;
5-
using Moq;
64
using Rubberduck.Settings;
7-
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
85
using Rubberduck.Root;
9-
using Rubberduck.UI;
10-
using Rubberduck.VBEditor.Host;
116
using RubberduckTests.Mocks;
127

138
namespace RubberduckTests.IoCContainer

RubberduckTests/Mocks/MockAddinBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
33
using Moq;
4-
using Rubberduck.VBEditor.Host;
4+
using Rubberduck.VBEditor;
55
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
66

77
namespace RubberduckTests.Mocks
@@ -24,8 +24,8 @@ private Mock<IAddIn> CreateAddInMock()
2424
{CommandBarSite.MenuBar, new CommandBarLocation(1, 1)},
2525
{CommandBarSite.CodeWindow, new CommandBarLocation(2, 2)},
2626
{CommandBarSite.ProjectExplorer, new CommandBarLocation(3, 3)},
27-
{CommandBarSite.MsForms, new CommandBarLocation(4, 4)},
28-
{CommandBarSite.MsFormsControl, new CommandBarLocation(5, 5)}
27+
{CommandBarSite.MsForm, new CommandBarLocation(4, 4)},
28+
{CommandBarSite.MsFormControl, new CommandBarLocation(5, 5)}
2929
}));
3030

3131
return addIn;

0 commit comments

Comments
 (0)