Skip to content

Commit ea22e58

Browse files
committed
Put AnnotateDeclaration in its own code pane menu
It now looks like the indent sub menu. This also fixes that the Refactorings sub menu was in the wrong place for ages.
1 parent 5ac6d38 commit ea22e58

19 files changed

+406
-32
lines changed

Rubberduck.Core/UI/Command/MenuItems/CodePaneAnnotateDeclarationCommandMenuItem.cs renamed to Rubberduck.Core/UI/Command/MenuItems/AnnotateSelectedDeclarationCommandMenuItem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace Rubberduck.UI.Command.MenuItems
66
{
7-
public class CodePaneAnnotateDeclarationCommandMenuItem : CommandMenuItemBase
7+
public class AnnotateSelectedDeclarationCommandMenuItem : CommandMenuItemBase
88
{
9-
public CodePaneAnnotateDeclarationCommandMenuItem(CodePaneAnnotateDeclarationCommand command)
9+
public AnnotateSelectedDeclarationCommandMenuItem(AnnotateSelectedDeclarationCommand command)
1010
: base(command)
1111
{ }
1212

13-
public override string Key => "RefactorMenu_AnnotateDeclaration";
14-
public override int DisplayOrder => (int)RefactoringsMenuItemDisplayOrder.AnnotateDeclaration;
13+
public override string Key => "AnnotateMenu_SelectedDeclaration";
14+
public override int DisplayOrder => (int)AnnotateParentMenuItemDisplayOrder.SelectedDeclaration;
1515

1616
public override bool EvaluateCanExecute(RubberduckParserState state)
1717
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Rubberduck.Parsing.VBA;
2+
using Rubberduck.UI.Command.MenuItems.ParentMenus;
3+
using Rubberduck.UI.Command.Refactorings;
4+
5+
namespace Rubberduck.UI.Command.MenuItems
6+
{
7+
public class AnnotateSelectedMemberCommandMenuItem : CommandMenuItemBase
8+
{
9+
public AnnotateSelectedMemberCommandMenuItem(AnnotateSelectedMemberCommand command)
10+
: base(command)
11+
{ }
12+
13+
public override string Key => "AnnotateMenu_SelectedMember";
14+
public override int DisplayOrder => (int)AnnotateParentMenuItemDisplayOrder.SelectedMember;
15+
16+
public override bool EvaluateCanExecute(RubberduckParserState state)
17+
{
18+
return state != null && Command.CanExecute(null);
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Rubberduck.Parsing.VBA;
2+
using Rubberduck.UI.Command.MenuItems.ParentMenus;
3+
using Rubberduck.UI.Command.Refactorings;
4+
5+
namespace Rubberduck.UI.Command.MenuItems
6+
{
7+
public class AnnotateSelectedModuleCommandMenuItem : CommandMenuItemBase
8+
{
9+
public AnnotateSelectedModuleCommandMenuItem(AnnotateSelectedModuleCommand command)
10+
: base(command)
11+
{ }
12+
13+
public override string Key => "AnnotateMenu_SelectedModule";
14+
public override int DisplayOrder => (int)AnnotateParentMenuItemDisplayOrder.SelectedModule;
15+
16+
public override bool EvaluateCanExecute(RubberduckParserState state)
17+
{
18+
return state != null && Command.CanExecute(null);
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
3+
namespace Rubberduck.UI.Command.MenuItems.ParentMenus
4+
{
5+
public class AnnotateParentMenu : ParentMenuItemBase
6+
{
7+
public AnnotateParentMenu(IEnumerable<IMenuItem> items)
8+
: base("AnnotateMenu", items)
9+
{
10+
}
11+
12+
public override int DisplayOrder => (int)CodePaneContextMenuItemDisplayOrder.Annotate;
13+
}
14+
15+
public enum AnnotateParentMenuItemDisplayOrder
16+
{
17+
SelectedDeclaration,
18+
SelectedModule,
19+
SelectedMember,
20+
}
21+
}

Rubberduck.Core/UI/Command/MenuItems/ParentMenus/CodePaneContextParentMenu.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public CodePaneContextParentMenu(IEnumerable<IMenuItem> items, int beforeIndex)
1515
public enum CodePaneContextMenuItemDisplayOrder
1616
{
1717
Refactorings,
18+
Annotate,
1819
Indenter,
1920
RegexSearchReplace,
2021
FindSymbol,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace Rubberduck.UI.Command.MenuItems.ParentMenus
4+
{
5+
public class CodePaneRefactoringsParentMenu : ParentMenuItemBase
6+
{
7+
public CodePaneRefactoringsParentMenu(IEnumerable<IMenuItem> items)
8+
: base("RubberduckMenu_CodePaneRefactor", items)
9+
{ }
10+
11+
//This display order is different from the main menu; it is the sole reason this class is separate from the main menu one.
12+
public override int DisplayOrder => (int)CodePaneContextMenuItemDisplayOrder.Refactorings;
13+
}
14+
}

Rubberduck.Core/UI/Command/MenuItems/ParentMenus/RefactoringsParentMenu.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public RefactoringsParentMenu(IEnumerable<IMenuItem> items)
1414

1515
public enum RefactoringsMenuItemDisplayOrder
1616
{
17-
AnnotateDeclaration,
1817
RenameIdentifier,
1918
ExtractMethod,
2019
ExtractInterface,

Rubberduck.Core/UI/Command/Refactorings/CodePaneAnnotateDeclarationCommand.cs renamed to Rubberduck.Core/UI/Command/Refactorings/AnnotateDeclarationCodePaneCommandBase.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@
66

77
namespace Rubberduck.UI.Command.Refactorings
88
{
9-
public class CodePaneAnnotateDeclarationCommand : RefactorCodePaneCommandBase
9+
public abstract class AnnotateDeclarationCodePaneCommandBase : RefactorCodePaneCommandBase
1010
{
1111
private readonly RubberduckParserState _state;
12-
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
1312

14-
public CodePaneAnnotateDeclarationCommand(
13+
protected AnnotateDeclarationCodePaneCommandBase(
1514
AnnotateDeclarationRefactoring refactoring,
1615
AnnotateDeclarationFailedNotifier failureNotifier,
1716
ISelectionProvider selectionProvider,
1817
IParserStatusProvider parserStatusProvider,
19-
RubberduckParserState state,
20-
ISelectedDeclarationProvider selectedDeclarationProvider)
18+
RubberduckParserState state)
2119
: base(refactoring, failureNotifier, selectionProvider, parserStatusProvider)
2220
{
23-
_selectedDeclarationProvider = selectedDeclarationProvider;
2421
_state = state;
2522

2623
AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute);
2724
}
2825

26+
protected abstract Declaration GetTarget();
27+
2928
private bool SpecializedEvaluateCanExecute(object parameter)
3029
{
3130
var target = GetTarget();
@@ -47,10 +46,5 @@ private bool SpecializedEvaluateCanExecute(object parameter)
4746

4847
return !_state.IsNewOrModified(target.QualifiedModuleName);
4948
}
50-
51-
private Declaration GetTarget()
52-
{
53-
return _selectedDeclarationProvider.SelectedDeclaration();
54-
}
5549
}
5650
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Rubberduck.Parsing.Symbols;
2+
using Rubberduck.Parsing.VBA;
3+
using Rubberduck.Refactorings.AnnotateDeclaration;
4+
using Rubberduck.UI.Command.Refactorings.Notifiers;
5+
using Rubberduck.VBEditor.Utility;
6+
7+
namespace Rubberduck.UI.Command.Refactorings
8+
{
9+
public class AnnotateSelectedDeclarationCommand : AnnotateDeclarationCodePaneCommandBase
10+
{
11+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
12+
13+
public AnnotateSelectedDeclarationCommand(
14+
AnnotateDeclarationRefactoring refactoring,
15+
AnnotateDeclarationFailedNotifier failureNotifier,
16+
ISelectionProvider selectionProvider,
17+
IParserStatusProvider parserStatusProvider,
18+
RubberduckParserState state,
19+
ISelectedDeclarationProvider selectedDeclarationProvider)
20+
: base(refactoring, failureNotifier, selectionProvider, parserStatusProvider, state)
21+
{
22+
_selectedDeclarationProvider = selectedDeclarationProvider;
23+
}
24+
25+
protected override Declaration GetTarget()
26+
{
27+
return _selectedDeclarationProvider.SelectedDeclaration();
28+
}
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Rubberduck.Parsing.Symbols;
2+
using Rubberduck.Parsing.VBA;
3+
using Rubberduck.Refactorings.AnnotateDeclaration;
4+
using Rubberduck.UI.Command.Refactorings.Notifiers;
5+
using Rubberduck.VBEditor.Utility;
6+
7+
namespace Rubberduck.UI.Command.Refactorings
8+
{
9+
public class AnnotateSelectedMemberCommand : AnnotateDeclarationCodePaneCommandBase
10+
{
11+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
12+
13+
public AnnotateSelectedMemberCommand(
14+
AnnotateDeclarationRefactoring refactoring,
15+
AnnotateDeclarationFailedNotifier failureNotifier,
16+
ISelectionProvider selectionProvider,
17+
IParserStatusProvider parserStatusProvider,
18+
RubberduckParserState state,
19+
ISelectedDeclarationProvider selectedDeclarationProvider)
20+
: base(refactoring, failureNotifier, selectionProvider, parserStatusProvider, state)
21+
{
22+
_selectedDeclarationProvider = selectedDeclarationProvider;
23+
}
24+
25+
protected override Declaration GetTarget()
26+
{
27+
return _selectedDeclarationProvider.SelectedMember();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)