Skip to content

Commit 70ed85a

Browse files
committed
Extract ISelectionProvider from ISelectionService
This separates the part for getting selections from the one setting them. This commit also renames ISelectedDeclarationService to ISelectedDeclarationProvider because it only provides data.
1 parent 98a76a6 commit 70ed85a

File tree

43 files changed

+198
-140
lines changed

Some content is hidden

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

43 files changed

+198
-140
lines changed

Rubberduck.Core/UI/Command/ComCommands/FindAllImplementationsCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ namespace Rubberduck.UI.Command.ComCommands
1313
[ComVisible(false)]
1414
public class FindAllImplementationsCommand : ComCommandBase
1515
{
16-
private readonly ISelectedDeclarationService _selectedDeclarationService;
16+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
1717
private readonly IParserStatusProvider _parserStatusProvider;
1818
private readonly FindAllImplementationsService _finder;
1919

2020
public FindAllImplementationsCommand(
2121
IParserStatusProvider parserStatusProvider,
22-
ISelectedDeclarationService selectedDeclarationService,
22+
ISelectedDeclarationProvider selectedDeclarationProvider,
2323
ISearchResultsWindowViewModel viewModel,
2424
FindAllImplementationsService finder,
2525
IVbeEvents vbeEvents)
2626
: base(vbeEvents)
2727
{
2828
_finder = finder;
29-
_selectedDeclarationService = selectedDeclarationService;
29+
_selectedDeclarationProvider = selectedDeclarationProvider;
3030
_parserStatusProvider = parserStatusProvider;
3131

3232
AddToCanExecuteEvaluation(SpecialEvaluateCanExecute);
@@ -66,7 +66,7 @@ private Declaration FindTarget(object parameter)
6666
return declaration;
6767
}
6868

69-
var selectedDeclaration = _selectedDeclarationService.SelectedDeclaration();
69+
var selectedDeclaration = _selectedDeclarationProvider.SelectedDeclaration();
7070

7171
return selectedDeclaration;
7272
}

Rubberduck.Core/UI/Command/ComCommands/FindAllReferencesCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ public class FindAllReferencesCommand : ComCommandBase
1616
{
1717
private readonly IParserStatusProvider _parserStatusProvider;
1818
private readonly IDeclarationFinderProvider _declarationFinderProvider;
19-
private readonly ISelectedDeclarationService _selectedDeclarationService;
19+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
2020
private readonly IVBE _vbe;
2121
private readonly FindAllReferencesService _finder;
2222

2323
public FindAllReferencesCommand(
2424
IParserStatusProvider parserStatusProvider,
2525
IDeclarationFinderProvider declarationFinderProvider,
26-
ISelectedDeclarationService selectedDeclarationService,
26+
ISelectedDeclarationProvider selectedDeclarationProvider,
2727
IVBE vbe,
2828
ISearchResultsWindowViewModel viewModel,
2929
FindAllReferencesService finder,
@@ -32,7 +32,7 @@ public FindAllReferencesCommand(
3232
{
3333
_parserStatusProvider = parserStatusProvider;
3434
_declarationFinderProvider = declarationFinderProvider;
35-
_selectedDeclarationService = selectedDeclarationService;
35+
_selectedDeclarationProvider = selectedDeclarationProvider;
3636
_vbe = vbe;
3737
_finder = finder;
3838

@@ -105,7 +105,7 @@ private Declaration FindTarget(object parameter)
105105

106106
private Declaration FindCodePaneTarget()
107107
{
108-
return _selectedDeclarationService.SelectedDeclaration();
108+
return _selectedDeclarationProvider.SelectedDeclaration();
109109
}
110110

111111
//Assumes the component has a designer.

Rubberduck.Core/UI/Command/ComCommands/NoIndentAnnotationCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ namespace Rubberduck.UI.Command.ComCommands
1111
[ComVisible(false)]
1212
public class NoIndentAnnotationCommand : ComCommandBase
1313
{
14-
private readonly ISelectedDeclarationService _selectedDeclarationService;
14+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
1515
private readonly IAnnotationUpdater _annotationUpdater;
1616
private readonly IRewritingManager _rewritingManager;
1717

1818
public NoIndentAnnotationCommand(
19-
ISelectedDeclarationService selectedDeclarationService,
19+
ISelectedDeclarationProvider selectedDeclarationProvider,
2020
IRewritingManager rewritingManager,
2121
IAnnotationUpdater annotationUpdater,
2222
IVbeEvents vbeEvents)
2323
: base(vbeEvents)
2424
{
25-
_selectedDeclarationService = selectedDeclarationService;
25+
_selectedDeclarationProvider = selectedDeclarationProvider;
2626
_rewritingManager = rewritingManager;
2727
_annotationUpdater = annotationUpdater;
2828

@@ -57,7 +57,7 @@ private Declaration FindTarget(object parameter)
5757
return declaration;
5858
}
5959

60-
return _selectedDeclarationService.SelectedModule();
60+
return _selectedDeclarationProvider.SelectedModule();
6161
}
6262
}
6363
}

Rubberduck.Core/UI/Command/ComCommands/SyncCodeExplorerCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public CodeExplorerSyncProvider(
3232
public SyncCodeExplorerCommand GetSyncCommand(CodeExplorerViewModel explorer)
3333
{
3434
var selectionService = new SelectionService(_vbe, _state.ProjectsProvider);
35-
var selectedDeclarationService = new SelectedDeclarationService(selectionService, _state);
35+
var selectedDeclarationService = new SelectedDeclarationProvider(selectionService, _state);
3636
return new SyncCodeExplorerCommand(_vbe, _state, _state, selectedDeclarationService, explorer, _vbeEvents);
3737
}
3838
}
@@ -41,22 +41,22 @@ public class SyncCodeExplorerCommand : ComCommandBase
4141
{
4242
private readonly IVBE _vbe;
4343
private readonly IDeclarationFinderProvider _declarationFinderProvider;
44-
private readonly ISelectedDeclarationService _selectedDeclarationService;
44+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
4545
private readonly IParserStatusProvider _parserStatusProvider;
4646
private readonly CodeExplorerViewModel _explorer;
4747

4848
public SyncCodeExplorerCommand(
4949
IVBE vbe,
5050
IDeclarationFinderProvider declarationFinderProvider,
5151
IParserStatusProvider parserStatusProvider,
52-
ISelectedDeclarationService selectedDeclarationService,
52+
ISelectedDeclarationProvider selectedDeclarationProvider,
5353
CodeExplorerViewModel explorer,
5454
IVbeEvents vbeEvents)
5555
: base(vbeEvents)
5656
{
5757
_vbe = vbe;
5858
_declarationFinderProvider = declarationFinderProvider;
59-
_selectedDeclarationService = selectedDeclarationService;
59+
_selectedDeclarationProvider = selectedDeclarationProvider;
6060
_parserStatusProvider = parserStatusProvider;
6161
_explorer = explorer;
6262

@@ -92,7 +92,7 @@ private ICodeExplorerNode FindTargetNode()
9292

9393
private Declaration FindTargetDeclaration()
9494
{
95-
return _selectedDeclarationService.SelectedDeclaration()
95+
return _selectedDeclarationProvider.SelectedDeclaration()
9696
?? ActiveProjectDeclaration();
9797
}
9898

Rubberduck.Core/UI/Command/Refactorings/CodePaneRefactorRenameCommand.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ namespace Rubberduck.UI.Command.Refactorings
1111
public class CodePaneRefactorRenameCommand : RefactorCodePaneCommandBase
1212
{
1313
private readonly RubberduckParserState _state;
14-
private readonly ISelectedDeclarationService _selectedDeclarationService;
14+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
1515

1616
public CodePaneRefactorRenameCommand(
1717
RenameRefactoring refactoring,
1818
RenameFailedNotifier renameFailedNotifier,
1919
RubberduckParserState state,
20-
ISelectionService selectionService,
21-
ISelectedDeclarationService selectedDeclarationService)
22-
: base (refactoring, renameFailedNotifier, selectionService, state)
20+
ISelectionProvider selectionProvider,
21+
ISelectedDeclarationProvider selectedDeclarationProvider)
22+
: base (refactoring, renameFailedNotifier, selectionProvider, state)
2323
{
2424
_state = state;
25-
_selectedDeclarationService = selectedDeclarationService;
25+
_selectedDeclarationProvider = selectedDeclarationProvider;
2626

2727
AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute);
2828
}
@@ -38,7 +38,7 @@ private bool SpecializedEvaluateCanExecute(object parameter)
3838

3939
private Declaration GetTarget()
4040
{
41-
return _selectedDeclarationService.SelectedDeclaration();
41+
return _selectedDeclarationProvider.SelectedDeclaration();
4242
}
4343
}
4444
}

Rubberduck.Core/UI/Command/Refactorings/FormDesignerRefactorRenameCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Rubberduck.UI.Command.Refactorings.Notifiers;
77
using Rubberduck.VBEditor;
88
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
9-
using Rubberduck.VBEditor.Utility;
109

1110
namespace Rubberduck.UI.Command.Refactorings
1211
{
@@ -16,7 +15,7 @@ public class FormDesignerRefactorRenameCommand : RefactorDeclarationCommandBase
1615
private readonly RubberduckParserState _state;
1716
private readonly IVBE _vbe;
1817

19-
public FormDesignerRefactorRenameCommand(RenameRefactoring refactoring, RenameFailedNotifier renameFailedNotifier, IVBE vbe, RubberduckParserState state, ISelectionService selectionService)
18+
public FormDesignerRefactorRenameCommand(RenameRefactoring refactoring, RenameFailedNotifier renameFailedNotifier, IVBE vbe, RubberduckParserState state)
2019
: base (refactoring, renameFailedNotifier, state)
2120
{
2221
_state = state;

Rubberduck.Core/UI/Command/Refactorings/ProjectExplorerRefactorRenameCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Rubberduck.Refactorings.Rename;
66
using Rubberduck.UI.Command.Refactorings.Notifiers;
77
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
8-
using Rubberduck.VBEditor.Utility;
98

109
namespace Rubberduck.UI.Command.Refactorings
1110
{
@@ -15,7 +14,7 @@ public class ProjectExplorerRefactorRenameCommand : RefactorDeclarationCommandBa
1514
private readonly RubberduckParserState _state;
1615
private readonly IVBE _vbe;
1716

18-
public ProjectExplorerRefactorRenameCommand(RenameRefactoring refactoring, RenameFailedNotifier renameFailedNotifier, IVBE vbe, RubberduckParserState state, ISelectionService selectionService)
17+
public ProjectExplorerRefactorRenameCommand(RenameRefactoring refactoring, RenameFailedNotifier renameFailedNotifier, IVBE vbe, RubberduckParserState state)
1918
: base(refactoring, renameFailedNotifier, state)
2019
{
2120
_state = state;

Rubberduck.Core/UI/Command/Refactorings/RefactorCodePaneCommandBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ namespace Rubberduck.UI.Command.Refactorings
88
{
99
public abstract class RefactorCodePaneCommandBase : RefactorCommandBase
1010
{
11-
protected readonly ISelectionService SelectionService;
11+
protected readonly ISelectionProvider SelectionProvider;
1212

13-
protected RefactorCodePaneCommandBase(IRefactoring refactoring, IRefactoringFailureNotifier failureNotifier, ISelectionService selectionService, IParserStatusProvider parserStatusProvider)
13+
protected RefactorCodePaneCommandBase(IRefactoring refactoring, IRefactoringFailureNotifier failureNotifier, ISelectionProvider selectionProvider, IParserStatusProvider parserStatusProvider)
1414
: base (refactoring, failureNotifier, parserStatusProvider)
1515
{
16-
SelectionService = selectionService;
16+
SelectionProvider = selectionProvider;
1717

1818
AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute);
1919
}
2020

2121
private bool SpecializedEvaluateCanExecute(object parameter)
2222
{
23-
return SelectionService.ActiveSelection().HasValue;
23+
return SelectionProvider.ActiveSelection().HasValue;
2424
}
2525

2626
protected override void OnExecute(object parameter)
2727
{
28-
var activeSelection = SelectionService.ActiveSelection();
28+
var activeSelection = SelectionProvider.ActiveSelection();
2929
if (!activeSelection.HasValue)
3030
{
3131
return;

Rubberduck.Core/UI/Command/Refactorings/RefactorEncapsulateFieldCommand.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ namespace Rubberduck.UI.Command.Refactorings
1111
public class RefactorEncapsulateFieldCommand : RefactorCodePaneCommandBase
1212
{
1313
private readonly RubberduckParserState _state;
14-
private readonly ISelectedDeclarationService _selectedDeclarationService;
14+
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider;
1515

1616
public RefactorEncapsulateFieldCommand(
1717
EncapsulateFieldRefactoring refactoring,
1818
EncapsulateFieldFailedNotifier encapsulateFieldFailedNotifier,
1919
RubberduckParserState state,
20-
ISelectionService selectionService,
21-
ISelectedDeclarationService selectedDeclarationService)
22-
: base(refactoring, encapsulateFieldFailedNotifier, selectionService, state)
20+
ISelectionProvider selectionProvider,
21+
ISelectedDeclarationProvider selectedDeclarationProvider)
22+
: base(refactoring, encapsulateFieldFailedNotifier, selectionProvider, state)
2323
{
2424
_state = state;
25-
_selectedDeclarationService = selectedDeclarationService;
25+
_selectedDeclarationProvider = selectedDeclarationProvider;
2626

2727
AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute);
2828
}
@@ -39,7 +39,7 @@ private bool SpecializedEvaluateCanExecute(object parameter)
3939

4040
private Declaration GetTarget()
4141
{
42-
return _selectedDeclarationService.SelectedDeclaration();
42+
return _selectedDeclarationProvider.SelectedDeclaration();
4343
}
4444
}
4545
}

Rubberduck.Core/UI/Command/Refactorings/RefactorExtractInterfaceCommand.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ public class RefactorExtractInterfaceCommand : RefactorCodePaneCommandBase
1717
{
1818
private readonly RubberduckParserState _state;
1919

20-
public RefactorExtractInterfaceCommand(ExtractInterfaceRefactoring refactoring, ExtractInterfaceFailedNotifier extractInterfaceFailedNotifier, RubberduckParserState state, ISelectionService selectionService)
21-
:base(refactoring, extractInterfaceFailedNotifier, selectionService, state)
20+
public RefactorExtractInterfaceCommand(
21+
ExtractInterfaceRefactoring refactoring,
22+
ExtractInterfaceFailedNotifier extractInterfaceFailedNotifier,
23+
RubberduckParserState state,
24+
ISelectionProvider selectionProvider)
25+
:base(refactoring, extractInterfaceFailedNotifier, selectionProvider, state)
2226
{
2327
_state = state;
2428

@@ -27,7 +31,7 @@ public RefactorExtractInterfaceCommand(ExtractInterfaceRefactoring refactoring,
2731

2832
private bool SpecializedEvaluateCanExecute(object parameter)
2933
{
30-
var activeSelection = SelectionService.ActiveSelection();
34+
var activeSelection = SelectionProvider.ActiveSelection();
3135
if (!activeSelection.HasValue)
3236
{
3337
return false;

0 commit comments

Comments
 (0)