blob: c7ec9b1301028fb161f6ea9e40a7174175d6d15b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.Text.Operations.Implementation
{
[Export(typeof(ICommandHandler))]
[Name(nameof(ExpandContractSelectionCommandHandler))]
[ContentType("any")]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
[TextViewRole(PredefinedTextViewRoles.EmbeddedPeekTextView)]
internal sealed class ExpandContractSelectionCommandHandler
: ICommandHandler<ExpandSelectionCommandArgs>, ICommandHandler<ContractSelectionCommandArgs>
{
[ImportingConstructor]
public ExpandContractSelectionCommandHandler(
IEditorOptionsFactoryService editorOptionsFactoryService,
ITextStructureNavigatorSelectorService navigatorSelectorService)
{
this.EditorOptionsFactoryService = editorOptionsFactoryService;
this.NavigatorSelectorService = navigatorSelectorService;
}
public IEditorOptionsFactoryService EditorOptionsFactoryService { get; }
private readonly ITextStructureNavigatorSelectorService NavigatorSelectorService;
public string DisplayName => Strings.ExpandContractSelectionCommandHandlerName;
public CommandState GetCommandState(ExpandSelectionCommandArgs args)
{
var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
args.TextView,
this.EditorOptionsFactoryService,
this.NavigatorSelectorService);
return storedCommandState.GetExpandCommandState(args.TextView);
}
public CommandState GetCommandState(ContractSelectionCommandArgs args)
{
var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
args.TextView,
this.EditorOptionsFactoryService,
this.NavigatorSelectorService);
return storedCommandState.GetContractCommandState(args.TextView);
}
public bool ExecuteCommand(ExpandSelectionCommandArgs args, CommandExecutionContext context)
{
var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
args.TextView,
this.EditorOptionsFactoryService,
this.NavigatorSelectorService);
return storedCommandState.ExpandSelection(args.TextView);
}
public bool ExecuteCommand(ContractSelectionCommandArgs args, CommandExecutionContext context)
{
var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
args.TextView,
this.EditorOptionsFactoryService,
this.NavigatorSelectorService);
return storedCommandState.ContractSelection(args.TextView);
}
}
}
|