|
4 | 4 | using System;
|
5 | 5 | using System.Threading;
|
6 | 6 | using System.Threading.Tasks;
|
7 |
| -using Microsoft.Extensions.Logging; |
8 | 7 | using Microsoft.PowerShell.EditorServices.Services;
|
9 | 8 | using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
|
10 | 9 | using OmniSharp.Extensions.JsonRpc;
|
11 | 10 |
|
12 | 11 | namespace Microsoft.PowerShell.EditorServices.Handlers
|
13 | 12 | {
|
14 |
| - // TODO: Inherit from ABCs instead of satisfying interfaces. |
15 |
| - internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler |
| 13 | + internal class ContinueHandler : ContinueHandlerBase |
16 | 14 | {
|
17 |
| - private readonly ILogger _logger; |
18 | 15 | private readonly DebugService _debugService;
|
19 | 16 |
|
20 |
| - public DebuggerActionHandlers( |
21 |
| - ILoggerFactory loggerFactory, |
22 |
| - DebugService debugService) |
23 |
| - { |
24 |
| - _logger = loggerFactory.CreateLogger<ContinueHandlerBase>(); |
25 |
| - _debugService = debugService; |
26 |
| - } |
| 17 | + public ContinueHandler(DebugService debugService) => _debugService = debugService; |
27 | 18 |
|
28 |
| - public Task<ContinueResponse> Handle(ContinueArguments request, CancellationToken cancellationToken) |
| 19 | + public override Task<ContinueResponse> Handle(ContinueArguments request, CancellationToken cancellationToken) |
29 | 20 | {
|
30 | 21 | _debugService.Continue();
|
31 | 22 | return Task.FromResult(new ContinueResponse());
|
32 | 23 | }
|
| 24 | + } |
| 25 | + |
| 26 | + internal class NextHandler : NextHandlerBase |
| 27 | + { |
| 28 | + private readonly DebugService _debugService; |
33 | 29 |
|
34 |
| - public Task<NextResponse> Handle(NextArguments request, CancellationToken cancellationToken) |
| 30 | + public NextHandler(DebugService debugService) => _debugService = debugService; |
| 31 | + |
| 32 | + public override Task<NextResponse> Handle(NextArguments request, CancellationToken cancellationToken) |
35 | 33 | {
|
36 | 34 | _debugService.StepOver();
|
37 | 35 | return Task.FromResult(new NextResponse());
|
38 | 36 | }
|
| 37 | + } |
| 38 | + |
| 39 | + internal class PauseHandler : PauseHandlerBase |
| 40 | + { |
| 41 | + private readonly DebugService _debugService; |
39 | 42 |
|
40 |
| - public Task<PauseResponse> Handle(PauseArguments request, CancellationToken cancellationToken) |
| 43 | + public PauseHandler(DebugService debugService) => _debugService = debugService; |
| 44 | + |
| 45 | + public override Task<PauseResponse> Handle(PauseArguments request, CancellationToken cancellationToken) |
41 | 46 | {
|
42 | 47 | try
|
43 | 48 | {
|
44 | 49 | _debugService.Break();
|
45 | 50 | return Task.FromResult(new PauseResponse());
|
46 | 51 | }
|
47 |
| - catch(NotSupportedException e) |
| 52 | + catch (NotSupportedException e) |
48 | 53 | {
|
49 | 54 | throw new RpcErrorException(0, e.Message);
|
50 | 55 | }
|
51 | 56 | }
|
| 57 | + } |
| 58 | + |
| 59 | + internal class StepInHandler : StepInHandlerBase |
| 60 | + { |
| 61 | + private readonly DebugService _debugService; |
| 62 | + |
| 63 | + public StepInHandler(DebugService debugService) => _debugService = debugService; |
52 | 64 |
|
53 |
| - public Task<StepInResponse> Handle(StepInArguments request, CancellationToken cancellationToken) |
| 65 | + public override Task<StepInResponse> Handle(StepInArguments request, CancellationToken cancellationToken) |
54 | 66 | {
|
55 | 67 | _debugService.StepIn();
|
56 | 68 | return Task.FromResult(new StepInResponse());
|
57 | 69 | }
|
| 70 | + } |
| 71 | + |
| 72 | + internal class StepOutHandler : StepOutHandlerBase |
| 73 | + { |
| 74 | + private readonly DebugService _debugService; |
| 75 | + |
| 76 | + public StepOutHandler(DebugService debugService) => _debugService = debugService; |
58 | 77 |
|
59 |
| - public Task<StepOutResponse> Handle(StepOutArguments request, CancellationToken cancellationToken) |
| 78 | + public override Task<StepOutResponse> Handle(StepOutArguments request, CancellationToken cancellationToken) |
60 | 79 | {
|
61 | 80 | _debugService.StepOut();
|
62 | 81 | return Task.FromResult(new StepOutResponse());
|
|
0 commit comments