Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a384a2c

Browse files
WIP OmniSharp update
1 parent 95cdc09 commit a384a2c

18 files changed

+94
-134
lines changed

‎src/PowerShellEditorServices/Server/PsesLanguageServer.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public async Task StartAsync()
6767
.AddPsesLanguageServices(_hostDetails))
6868
.ConfigureLogging(builder => builder
6969
.AddSerilog(Log.Logger)
70-
.AddLanguageProtocolLogging(_minimumLogLevel)
70+
.AddLanguageProtocolLogging()
7171
.SetMinimumLevel(_minimumLogLevel))
7272
.WithHandler<PsesWorkspaceSymbolsHandler>()
7373
.WithHandler<PsesTextDocumentHandler>()

‎src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
146146
break;
147147
}
148148

149-
OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint;
149+
var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint
150+
{
151+
Verified = e.UpdateType != BreakpointUpdateType.Disabled
152+
};
153+
150154
if (e.Breakpoint is LineBreakpoint)
151155
{
152156
breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint));
@@ -162,8 +166,6 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
162166
return;
163167
}
164168

165-
breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled;
166-
167169
_debugAdapterServer.SendNotification(EventNames.Breakpoint,
168170
new BreakpointEvent
169171
{

‎src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public DebuggerActionHandlers(
2222
ILoggerFactory loggerFactory,
2323
DebugService debugService)
2424
{
25-
_logger = loggerFactory.CreateLogger<ContinueHandler>();
25+
_logger = loggerFactory.CreateLogger<IContinueHandler>();
2626
_debugService = debugService;
2727
}
2828

‎src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace Microsoft.PowerShell.EditorServices.Handlers
2424
{
25-
internal class PsesLaunchRequestArguments : LaunchRequestArguments
25+
internal record PsesLaunchRequestArguments : LaunchRequestArguments
2626
{
2727
/// <summary>
2828
/// Gets or sets the absolute path to the script to debug.
@@ -70,7 +70,7 @@ internal class PsesLaunchRequestArguments : LaunchRequestArguments
7070
public Dictionary<string, string> Env { get; set; }
7171
}
7272

73-
internal class PsesAttachRequestArguments : AttachRequestArguments
73+
internal record PsesAttachRequestArguments : AttachRequestArguments
7474
{
7575
public string ComputerName { get; set; }
7676

‎src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ public Task<ThreadsResponse> Handle(ThreadsArguments request, CancellationToken
1616
{
1717
return Task.FromResult(new ThreadsResponse
1818
{
19-
// TODO: What do I do with these?
20-
Threads = new Container<OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread>(
21-
new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread
22-
{
23-
Id = 1,
24-
Name = "Main Thread"
25-
})
19+
// TODO: This is an empty container of threads...do we need to make a thread?
20+
Threads = new Container<System.Threading.Thread>()
2621
});
2722
}
2823
}

‎src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919

2020
namespace Microsoft.PowerShell.EditorServices.Handlers
2121
{
22-
internal class PsesCodeActionHandler : ICodeActionHandler
22+
internal class PsesCodeActionHandler : CodeActionHandlerBase
2323
{
2424
private static readonly CodeActionKind[] s_supportedCodeActions = new[]
2525
{
2626
CodeActionKind.QuickFix
2727
};
2828

29-
private readonly CodeActionRegistrationOptions _registrationOptions;
30-
3129
private readonly ILogger _logger;
3230

3331
private readonly AnalysisService _analysisService;
@@ -41,24 +39,31 @@ public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisSer
4139
_logger = factory.CreateLogger<PsesCodeActionHandler>();
4240
_analysisService = analysisService;
4341
_workspaceService = workspaceService;
44-
_registrationOptions = new CodeActionRegistrationOptions
42+
}
43+
44+
protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions
4545
{
46-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
46+
// TODO: What do we do with the arguments?
47+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
4748
CodeActionKinds = s_supportedCodeActions
48-
};
49-
}
49+
};
5050

51-
public CodeActionRegistrationOptionsGetRegistrationOptions()
51+
public voidSetCapability(CodeActionCapabilitycapability)
5252
{
53-
return_registrationOptions;
53+
_capability=capability;
5454
}
5555

56-
public voidSetCapability(CodeActionCapabilitycapability)
56+
public overrideasyncTask<CodeAction>Handle(CodeActionrequest,CancellationTokencancellationToken)
5757
{
58-
_capability = capability;
58+
// TODO: How on earth do we handle a CodeAction? This is new...
59+
if (cancellationToken.IsCancellationRequested)
60+
{
61+
_logger.LogDebug("CodeAction request canceled for: {0}", request.Title);
62+
}
63+
return request;
5964
}
6065

61-
public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
66+
public overrideasync Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
6267
{
6368
if (cancellationToken.IsCancellationRequested)
6469
{
@@ -101,7 +106,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
101106
new WorkspaceEditDocumentChange(
102107
new TextDocumentEdit
103108
{
104-
TextDocument = new VersionedTextDocumentIdentifier
109+
TextDocument = new OptionalVersionedTextDocumentIdentifier
105110
{
106111
Uri = request.TextDocument.Uri
107112
},

‎src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using Microsoft.PowerShell.EditorServices.Services;
1616
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1717
using Microsoft.PowerShell.EditorServices.Utility;
18-
using OmniSharp.Extensions.LanguageServer.Protocol;
1918
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
2019
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
2120
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
@@ -39,13 +38,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic
3938
_symbolsService = symbolsService;
4039
}
4140

42-
CodeLensRegistrationOptionsIRegistration<CodeLensRegistrationOptions>.GetRegistrationOptions()
41+
publicCodeLensRegistrationOptionsGetRegistrationOptions(CodeLensCapabilitycapability,ClientCapabilitiesclientCapabilities)=>newCodeLensRegistrationOptions
4342
{
44-
return new CodeLensRegistrationOptions
45-
{
46-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
47-
ResolveProvider = true
48-
};
43+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
44+
ResolveProvider = true
45+
};
46+
47+
public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities)
48+
{
49+
_capability = capability;
4950
}
5051

5152
public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken cancellationToken)
@@ -57,14 +58,6 @@ public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken
5758
return Task.FromResult(new CodeLensContainer(codeLensResults));
5859
}
5960

60-
public TextDocumentRegistrationOptions GetRegistrationOptions()
61-
{
62-
return new TextDocumentRegistrationOptions
63-
{
64-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
65-
};
66-
}
67-
6861
public bool CanResolve(CodeLens value)
6962
{
7063
CodeLensData codeLensData = value.Data.ToObject<CodeLensData>();

‎src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace Microsoft.PowerShell.EditorServices.Handlers
2323
{
24-
internal class PsesCompletionHandler : ICompletionHandler,ICompletionResolveHandler
24+
internal class PsesCompletionHandler : CompletionHandlerBase
2525
{
2626
const int DefaultWaitTimeoutMilliseconds = 5000;
2727
private readonly SemaphoreSlim _completionLock = AsyncUtils.CreateSimpleLockingSemaphore();
@@ -51,17 +51,14 @@ public PsesCompletionHandler(
5151
_workspaceService = workspaceService;
5252
}
5353

54-
publicCompletionRegistrationOptions GetRegistrationOptions()
54+
protectedoverrideCompletionRegistrationOptions CreateRegistrationOptions(CompletionCapabilitycapability,ClientCapabilitiesclientCapabilities)=>newCompletionRegistrationOptions
5555
{
56-
return new CompletionRegistrationOptions
57-
{
58-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
59-
ResolveProvider = true,
60-
TriggerCharacters = new[] { ".", "-", ":", "\\" }
61-
};
62-
}
56+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
57+
ResolveProvider = true,
58+
TriggerCharacters = new[] { ".", "-", ":", "\\" }
59+
};
6360

64-
public async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken)
61+
public overrideasync Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken)
6562
{
6663
int cursorLine = request.Position.Line + 1;
6764
int cursorColumn = request.Position.Character + 1;
@@ -117,7 +114,7 @@ public bool CanResolve(CompletionItem value)
117114
}
118115

119116
// Handler for "completionItem/resolve". In VSCode this is fired when a completion item is highlighted in the completion list.
120-
public async Task<CompletionItem> Handle(CompletionItem request, CancellationToken cancellationToken)
117+
public async overrideTask<CompletionItem> Handle(CompletionItem request, CancellationToken cancellationToken)
121118
{
122119
// We currently only support this request for anything that returns a CommandInfo: functions, cmdlets, aliases.
123120
if (request.Kind != CompletionItemKind.Function)
@@ -145,10 +142,11 @@ await CommandHelpers.GetCommandInfoAsync(
145142

146143
if (commandInfo != null)
147144
{
148-
request.Documentation =
149-
await CommandHelpers.GetCommandSynopsisAsync(
150-
commandInfo,
151-
_powerShellContextService).ConfigureAwait(false);
145+
return new CompletionItem()
146+
{
147+
// TODO: Do we need to fill in the rest of the fields?
148+
Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false)
149+
};
152150
}
153151

154152
// Send back the updated CompletionItem

‎src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ public PsesDefinitionHandler(
3636
_workspaceService = workspaceService;
3737
}
3838

39-
public DefinitionRegistrationOptions GetRegistrationOptions()
39+
public DefinitionRegistrationOptions GetRegistrationOptions(DefinitionCapabilitycapability,ClientCapabilitiesclientCapabilities)=>newDefinitionRegistrationOptions
4040
{
41-
return new DefinitionRegistrationOptions
42-
{
43-
DocumentSelector = LspUtils.PowerShellDocumentSelector
44-
};
45-
}
41+
DocumentSelector = LspUtils.PowerShellDocumentSelector
42+
};
4643

4744
public async Task<LocationOrLocationLinks> Handle(DefinitionParams request, CancellationToken cancellationToken)
4845
{

‎src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ public PsesDocumentHighlightHandler(
4040
_logger.LogInformation("highlight handler loaded");
4141
}
4242

43-
public DocumentHighlightRegistrationOptions GetRegistrationOptions()
43+
public DocumentHighlightRegistrationOptions GetRegistrationOptions(DocumentHighlightCapabilitycapab,ClientCapabilitiesclientCapabilities)=>newDocumentHighlightRegistrationOptions
4444
{
45-
return new DocumentHighlightRegistrationOptions
46-
{
47-
DocumentSelector = LspUtils.PowerShellDocumentSelector
48-
};
49-
}
45+
DocumentSelector = LspUtils.PowerShellDocumentSelector
46+
};
5047

5148
public Task<DocumentHighlightContainer> Handle(
5249
DocumentHighlightParams request,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /