diff --git a/PowerShellEditorServices.Common.props b/PowerShellEditorServices.Common.props index 50222ec97..49777cc88 100644 --- a/PowerShellEditorServices.Common.props +++ b/PowerShellEditorServices.Common.props @@ -4,6 +4,7 @@ preview.1 Microsoft © Microsoft Corporation. All rights reserved. + 9.0 PowerShell;editor;development;language;debugging https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE true diff --git a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj index 72f621c02..6b6771390 100644 --- a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj +++ b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj @@ -1,9 +1,9 @@  + netcoreapp3.1;net461 Microsoft.PowerShell.EditorServices.Hosting - latest diff --git a/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj b/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj index fc5fc85dd..b6022679f 100644 --- a/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj +++ b/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj @@ -17,7 +17,7 @@ - + All diff --git a/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs b/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs index 4d55320be..0ee68b9e2 100644 --- a/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs +++ b/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs @@ -9,10 +9,10 @@ namespace Microsoft.PowerShell.EditorServices.Logging { // This inheirits from Dictionary so that it can be passed in to SendTelemetryEvent() - // which takes in an IDictionary + // which takes in an IDictionary // However, I wanted creation to be easy so you can do // new PsesTelemetryEvent { EventName = "eventName", Data = data } - internal class PsesTelemetryEvent : Dictionary + internal class PsesTelemetryEvent : Dictionary { public string EventName { diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 345e928c1..5f04edec0 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -7,19 +7,9 @@ Provides common PowerShell editor capabilities as a .NET library. netstandard2.0 Microsoft.PowerShell.EditorServices - Latest Debug;Release - - latest - - - - - latest - - <_Parameter1>Microsoft.PowerShell.EditorServices.Hosting @@ -39,8 +29,8 @@ - - + + diff --git a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs index 52eb2dec4..ebe936792 100644 --- a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs +++ b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs @@ -67,7 +67,7 @@ public async Task StartAsync() .AddPsesLanguageServices(_hostDetails)) .ConfigureLogging(builder => builder .AddSerilog(Log.Logger) - .AddLanguageProtocolLogging(_minimumLogLevel) + .AddLanguageProtocolLogging() .SetMinimumLevel(_minimumLogLevel)) .WithHandler() .WithHandler() @@ -94,6 +94,7 @@ public async Task StartAsync() .WithHandler() .WithHandler() .OnInitialize( + // TODO: Either fix or ignore "method lacks 'await'" warning. async (languageServer, request, cancellationToken) => { var serviceProvider = languageServer.Services; diff --git a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs index e6e025286..5aa1a349c 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs @@ -55,7 +55,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile Data = JToken.FromObject(new { Uri = scriptFile.DocumentUri, ProviderId = nameof(PesterCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Command = new Command() { Name = "PowerShell.RunPesterTests", @@ -66,7 +66,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile false /* No debug */, pesterSymbol.TestName, pesterSymbol.ScriptRegion?.StartLineNumber - }, Serializer.Instance.JsonSerializer) + }, LspSerializer.Instance.JsonSerializer) } }, @@ -76,7 +76,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile Data = JToken.FromObject(new { Uri = scriptFile.DocumentUri, ProviderId = nameof(PesterCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Command = new Command() { Name = "PowerShell.RunPesterTests", @@ -88,7 +88,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile pesterSymbol.TestName, pesterSymbol.ScriptRegion?.StartLineNumber }, - Serializer.Instance.JsonSerializer) + LspSerializer.Instance.JsonSerializer) } } }; diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index f630c7979..1277bcb7f 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs @@ -68,7 +68,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile) { Uri = scriptFile.DocumentUri, ProviderId = nameof(ReferencesCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Range = sym.ScriptRegion.ToRange() }); } @@ -145,7 +145,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) codeLens.Range.Start, referenceLocations }, - Serializer.Instance.JsonSerializer) + LspSerializer.Instance.JsonSerializer) } }; } diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs b/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs index d91295d76..1a49277fc 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs @@ -146,7 +146,11 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven break; } - OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint; + var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint + { + Verified = e.UpdateType != BreakpointUpdateType.Disabled + }; + if (e.Breakpoint is LineBreakpoint) { breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint)); @@ -162,8 +166,6 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven return; } - breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled; - _debugAdapterServer.SendNotification(EventNames.Breakpoint, new BreakpointEvent { diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs index fd5a4f9ba..1f3322e88 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs @@ -13,6 +13,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Inherit from ABCs instead of satisfying interfaces. internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler { private readonly ILogger _logger; @@ -22,7 +23,7 @@ public DebuggerActionHandlers( ILoggerFactory loggerFactory, DebugService debugService) { - _logger = loggerFactory.CreateLogger(); + _logger = loggerFactory.CreateLogger(); _debugService = debugService; } diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs index 0f065baa8..954dc6b0e 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs @@ -22,7 +22,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesLaunchRequestArguments : LaunchRequestArguments + internal record PsesLaunchRequestArguments : LaunchRequestArguments { /// /// Gets or sets the absolute path to the script to debug. @@ -70,7 +70,7 @@ internal class PsesLaunchRequestArguments : LaunchRequestArguments public Dictionary Env { get; set; } } - internal class PsesAttachRequestArguments : AttachRequestArguments + internal record PsesAttachRequestArguments : AttachRequestArguments { public string ComputerName { get; set; } diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs index 800494a2a..f788f3b9c 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs @@ -16,13 +16,8 @@ public Task Handle(ThreadsArguments request, CancellationToken { return Task.FromResult(new ThreadsResponse { - // TODO: What do I do with these? - Threads = new Container( - new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread - { - Id = 1, - Name = "Main Thread" - }) + // TODO: This is an empty container of threads...do we need to make a thread? + Threads = new Container() }); } } diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs index fc57045dd..23214989f 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs @@ -19,46 +19,38 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesCodeActionHandler : ICodeActionHandler + internal class PsesCodeActionHandler : CodeActionHandlerBase { - private static readonly CodeActionKind[] s_supportedCodeActions = new[] - { - CodeActionKind.QuickFix - }; - - private readonly CodeActionRegistrationOptions _registrationOptions; - private readonly ILogger _logger; - private readonly AnalysisService _analysisService; - private readonly WorkspaceService _workspaceService; - private CodeActionCapability _capability; - public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisService, WorkspaceService workspaceService) { _logger = factory.CreateLogger(); _analysisService = analysisService; _workspaceService = workspaceService; - _registrationOptions = new CodeActionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - CodeActionKinds = s_supportedCodeActions - }; } - public CodeActionRegistrationOptions GetRegistrationOptions() - { - return _registrationOptions; - } + protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions + { + // TODO: What do we do with the arguments? + DocumentSelector = LspUtils.PowerShellDocumentSelector, + CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix } + }; - public void SetCapability(CodeActionCapability capability) + // TODO: Either fix or ignore "method lacks 'await'" warning. + public override async Task Handle(CodeAction request, CancellationToken cancellationToken) { - _capability = capability; + // TODO: How on earth do we handle a CodeAction? This is new... + if (cancellationToken.IsCancellationRequested) + { + _logger.LogDebug("CodeAction request canceled for: {0}", request.Title); + } + return request; } - public async Task Handle(CodeActionParams request, CancellationToken cancellationToken) + public override async Task Handle(CodeActionParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -101,7 +93,7 @@ public async Task Handle(CodeActionParams request, new WorkspaceEditDocumentChange( new TextDocumentEdit { - TextDocument = new VersionedTextDocumentIdentifier + TextDocument = new OptionalVersionedTextDocumentIdentifier { Uri = request.TextDocument.Uri }, diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs index 4bcd45a91..871ae90b6 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs @@ -15,22 +15,21 @@ using Microsoft.PowerShell.EditorServices.Services; using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Utility; -using OmniSharp.Extensions.LanguageServer.Protocol; using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler { - private readonly Guid _id = new Guid(); private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private CodeLensCapability _capability; - public Guid Id => _id; + private readonly Guid _id = Guid.NewGuid(); + Guid ICanBeIdentifiedHandler.Id => _id; public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService, ConfigurationService configurationService) { @@ -39,13 +38,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic _symbolsService = symbolsService; } - CodeLensRegistrationOptions IRegistration.GetRegistrationOptions() + public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions { - return new CodeLensRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - ResolveProvider = true - }; + DocumentSelector = LspUtils.PowerShellDocumentSelector, + ResolveProvider = true + }; + + public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities) + { + _capability = capability; } public Task Handle(CodeLensParams request, CancellationToken cancellationToken) @@ -57,14 +58,6 @@ public Task Handle(CodeLensParams request, CancellationToken return Task.FromResult(new CodeLensContainer(codeLensResults)); } - public TextDocumentRegistrationOptions GetRegistrationOptions() - { - return new TextDocumentRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - }; - } - public bool CanResolve(CodeLens value) { CodeLensData codeLensData = value.Data.ToObject(); diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs index c123da8fb..de5d01636 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs @@ -21,25 +21,22 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler { const int DefaultWaitTimeoutMilliseconds = 5000; private readonly SemaphoreSlim _completionLock = AsyncUtils.CreateSimpleLockingSemaphore(); private readonly SemaphoreSlim _completionResolveLock = AsyncUtils.CreateSimpleLockingSemaphore(); - private readonly ILogger _logger; private readonly PowerShellContextService _powerShellContextService; private readonly WorkspaceService _workspaceService; - private CompletionResults _mostRecentCompletions; - private int _mostRecentRequestLine; - private int _mostRecentRequestOffest; - private string _mostRecentRequestFile; - private CompletionCapability _capability; + private readonly Guid _id = Guid.NewGuid(); + Guid ICanBeIdentifiedHandler.Id => _id; public PsesCompletionHandler( ILoggerFactory factory, @@ -51,15 +48,12 @@ public PsesCompletionHandler( _workspaceService = workspaceService; } - public CompletionRegistrationOptions GetRegistrationOptions() + public CompletionRegistrationOptions GetRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions { - return new CompletionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - ResolveProvider = true, - TriggerCharacters = new[] { ".", "-", ":", "\\", "$" } - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + ResolveProvider = true, + TriggerCharacters = new[] { ".", "-", ":", "\\", "$" } + }; public async Task Handle(CompletionParams request, CancellationToken cancellationToken) { @@ -145,10 +139,10 @@ await CommandHelpers.GetCommandInfoAsync( if (commandInfo != null) { - request.Documentation = - await CommandHelpers.GetCommandSynopsisAsync( - commandInfo, - _powerShellContextService).ConfigureAwait(false); + request = request with + { + Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false) + }; } // Send back the updated CompletionItem @@ -160,7 +154,7 @@ await CommandHelpers.GetCommandSynopsisAsync( } } - public void SetCapability(CompletionCapability capability) + public void SetCapability(CompletionCapability capability, ClientCapabilities clientCapabilities) { _capability = capability; } diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs index 29d519e12..52d0d74d8 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs @@ -18,14 +18,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDefinitionHandler : IDefinitionHandler + internal class PsesDefinitionHandler : DefinitionHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private DefinitionCapability _capability; - public PsesDefinitionHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -36,15 +34,12 @@ public PsesDefinitionHandler( _workspaceService = workspaceService; } - public DefinitionRegistrationOptions GetRegistrationOptions() + protected override DefinitionRegistrationOptions CreateRegistrationOptions(DefinitionCapability capability, ClientCapabilities clientCapabilities) => new DefinitionRegistrationOptions { - return new DefinitionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public async Task Handle(DefinitionParams request, CancellationToken cancellationToken) + public override async Task Handle(DefinitionParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -76,11 +71,6 @@ public async Task Handle(DefinitionParams request, Canc return new LocationOrLocationLinks(definitionLocations); } - public void SetCapability(DefinitionCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs index 5daa111f5..3501b8dec 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs @@ -17,18 +17,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDocumentHighlightHandler : IDocumentHighlightHandler + internal class PsesDocumentHighlightHandler : DocumentHighlightHandlerBase { private static readonly DocumentHighlightContainer s_emptyHighlightContainer = new DocumentHighlightContainer(); - private readonly ILogger _logger; - private readonly WorkspaceService _workspaceService; - private readonly SymbolsService _symbolsService; - private DocumentHighlightCapability _capability; - public PsesDocumentHighlightHandler( ILoggerFactory loggerFactory, WorkspaceService workspaceService, @@ -40,15 +35,12 @@ public PsesDocumentHighlightHandler( _logger.LogInformation("highlight handler loaded"); } - public DocumentHighlightRegistrationOptions GetRegistrationOptions() + protected override DocumentHighlightRegistrationOptions CreateRegistrationOptions(DocumentHighlightCapability capability, ClientCapabilities clientCapabilities) => new DocumentHighlightRegistrationOptions { - return new DocumentHighlightRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle( + public override Task Handle( DocumentHighlightParams request, CancellationToken cancellationToken) { @@ -76,10 +68,5 @@ public Task Handle( return Task.FromResult(new DocumentHighlightContainer(highlights)); } - - public void SetCapability(DocumentHighlightCapability capability) - { - _capability = capability; - } } } diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs index a62985be5..a75271e37 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs @@ -23,15 +23,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDocumentSymbolHandler : IDocumentSymbolHandler + internal class PsesDocumentSymbolHandler : DocumentSymbolHandlerBase { private readonly ILogger _logger; private readonly WorkspaceService _workspaceService; - private readonly IDocumentSymbolProvider[] _providers; - private DocumentSymbolCapability _capability; - public PsesDocumentSymbolHandler(ILoggerFactory factory, ConfigurationService configurationService, WorkspaceService workspaceService) { _logger = factory.CreateLogger(); @@ -44,15 +41,12 @@ public PsesDocumentSymbolHandler(ILoggerFactory factory, ConfigurationService co }; } - public DocumentSymbolRegistrationOptions GetRegistrationOptions() + protected override DocumentSymbolRegistrationOptions CreateRegistrationOptions(DocumentSymbolCapability capability, ClientCapabilities clientCapabilities) => new DocumentSymbolRegistrationOptions { - return new DocumentSymbolRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle(DocumentSymbolParams request, CancellationToken cancellationToken) + public override Task Handle(DocumentSymbolParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -92,11 +86,6 @@ public Task Handle(DocumentSymbolPar return Task.FromResult(new SymbolInformationOrDocumentSymbolContainer(symbols)); } - public void SetCapability(DocumentSymbolCapability capability) - { - _capability = capability; - } - private IEnumerable ProvideDocumentSymbols( ScriptFile scriptFile) { diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs index 6ec951691..daf0c70dc 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs @@ -16,30 +16,25 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesFoldingRangeHandler : IFoldingRangeHandler + internal class PsesFoldingRangeHandler : FoldingRangeHandlerBase { private readonly ILogger _logger; private readonly ConfigurationService _configurationService; private readonly WorkspaceService _workspaceService; - private FoldingRangeCapability _capability; - public PsesFoldingRangeHandler(ILoggerFactory factory, ConfigurationService configurationService, WorkspaceService workspaceService) { - _logger = factory.CreateLogger(); + _logger = factory.CreateLogger(); _configurationService = configurationService; _workspaceService = workspaceService; } - public FoldingRangeRegistrationOptions GetRegistrationOptions() + protected override FoldingRangeRegistrationOptions CreateRegistrationOptions(FoldingRangeCapability capability, ClientCapabilities clientCapabilities) => new FoldingRangeRegistrationOptions { - return new FoldingRangeRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task> Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) + public override Task> Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -75,10 +70,5 @@ public Task> Handle(FoldingRangeRequestParam request, Ca return Task.FromResult(new Container(result)); } - - public void SetCapability(FoldingRangeCapability capability) - { - _capability = capability; - } } } diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs index a229fbea9..71a4da380 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs @@ -17,6 +17,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { // TODO: Add IDocumentOnTypeFormatHandler to support on-type formatting. + // TODO: Use ABCs. internal class PsesDocumentFormattingHandlers : IDocumentFormattingHandler, IDocumentRangeFormattingHandler { private readonly ILogger _logger; @@ -39,21 +40,15 @@ public PsesDocumentFormattingHandlers( _workspaceService = workspaceService; } - public DocumentFormattingRegistrationOptions GetRegistrationOptions() + public DocumentFormattingRegistrationOptions GetRegistrationOptions(DocumentFormattingCapability capability, ClientCapabilities clientCapabilities) => new DocumentFormattingRegistrationOptions { - return new DocumentFormattingRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - DocumentRangeFormattingRegistrationOptions IRegistration.GetRegistrationOptions() + public DocumentRangeFormattingRegistrationOptions GetRegistrationOptions(DocumentRangeFormattingCapability capability, ClientCapabilities clientCapabilities) => new DocumentRangeFormattingRegistrationOptions { - return new DocumentRangeFormattingRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; public async Task Handle(DocumentFormattingParams request, CancellationToken cancellationToken) { diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs index 6f2c83d79..031b40371 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs @@ -17,14 +17,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesHoverHandler : IHoverHandler + internal class PsesHoverHandler : HoverHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private HoverCapability _capability; - public PsesHoverHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -35,15 +33,12 @@ public PsesHoverHandler( _workspaceService = workspaceService; } - public HoverRegistrationOptions GetRegistrationOptions() + protected override HoverRegistrationOptions CreateRegistrationOptions(HoverCapability capability, ClientCapabilities clientCapabilities) => new HoverRegistrationOptions { - return new HoverRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public async Task Handle(HoverParams request, CancellationToken cancellationToken) + public override async Task Handle(HoverParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -81,11 +76,6 @@ await _symbolsService.FindSymbolDetailsAtLocationAsync( }; } - public void SetCapability(HoverCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs index eacd4665e..48658185d 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs @@ -13,15 +13,14 @@ using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Utility; using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; -using OmniSharp.Extensions.LanguageServer.Protocol.Document.Proposals; +using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; namespace Microsoft.PowerShell.EditorServices.Handlers { internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase { - private static readonly SemanticTokensRegistrationOptions s_registrationOptions = new SemanticTokensRegistrationOptions + protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(SemanticTokensCapability capability, ClientCapabilities clientCapabilities) => new SemanticTokensRegistrationOptions { DocumentSelector = LspUtils.PowerShellDocumentSelector, Legend = new SemanticTokensLegend(), @@ -36,7 +35,6 @@ internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase private readonly WorkspaceService _workspaceService; public PsesSemanticTokensHandler(ILogger logger, WorkspaceService workspaceService) - : base(s_registrationOptions) { _logger = logger; _workspaceService = workspaceService; @@ -161,7 +159,7 @@ protected override Task GetSemanticTokensDocument( ITextDocumentIdentifierParams @params, CancellationToken cancellationToken) { - return Task.FromResult(new SemanticTokensDocument(GetRegistrationOptions().Legend)); + return Task.FromResult(new SemanticTokensDocument(RegistrationOptions.Legend)); } } } diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs index 2801a4d86..25af2a264 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs @@ -18,12 +18,11 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - class PsesReferencesHandler : IReferencesHandler + class PsesReferencesHandler : ReferencesHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private ReferenceCapability _capability; public PsesReferencesHandler(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService) { @@ -32,15 +31,12 @@ public PsesReferencesHandler(ILoggerFactory factory, SymbolsService symbolsServi _workspaceService = workspaceService; } - public ReferenceRegistrationOptions GetRegistrationOptions() + protected override ReferenceRegistrationOptions CreateRegistrationOptions(ReferenceCapability capability, ClientCapabilities clientCapabilities) => new ReferenceRegistrationOptions { - return new ReferenceRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle(ReferenceParams request, CancellationToken cancellationToken) + public override Task Handle(ReferenceParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -73,11 +69,6 @@ public Task Handle(ReferenceParams request, CancellationToken return Task.FromResult(new LocationContainer(locations)); } - public void SetCapability(ReferenceCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs index 688e5aba7..751152a5b 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs @@ -17,15 +17,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesSignatureHelpHandler : ISignatureHelpHandler + internal class PsesSignatureHelpHandler : SignatureHelpHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; private readonly PowerShellContextService _powerShellContextService; - private SignatureHelpCapability _capability; - public PsesSignatureHelpHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -38,17 +36,14 @@ public PsesSignatureHelpHandler( _powerShellContextService = powerShellContextService; } - public SignatureHelpRegistrationOptions GetRegistrationOptions() + protected override SignatureHelpRegistrationOptions CreateRegistrationOptions(SignatureHelpCapability capability, ClientCapabilities clientCapabilities) => new SignatureHelpRegistrationOptions { - return new SignatureHelpRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - // A sane default of " ". We may be able to include others like "-". - TriggerCharacters = new Container(" ") - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + // A sane default of " ". We may be able to include others like "-". + TriggerCharacters = new Container(" ") + }; - public async Task Handle(SignatureHelpParams request, CancellationToken cancellationToken) + public override async Task Handle(SignatureHelpParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -95,11 +90,6 @@ await _symbolsService.FindParameterSetsInFileAsync( }; } - public void SetCapability(SignatureHelpCapability capability) - { - _capability = capability; - } - private static ParameterInformation CreateParameterInfo(ParameterInfo parameterInfo) { return new ParameterInformation diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs index e5961c9a8..061dab98d 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs @@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - class PsesTextDocumentHandler : ITextDocumentSyncHandler + class PsesTextDocumentHandler : TextDocumentSyncHandlerBase { private static readonly Uri s_fakeUri = new Uri("Untitled:fake"); @@ -27,7 +27,6 @@ class PsesTextDocumentHandler : ITextDocumentSyncHandler private readonly AnalysisService _analysisService; private readonly WorkspaceService _workspaceService; private readonly RemoteFileManagerService _remoteFileManagerService; - private SynchronizationCapability _capability; public TextDocumentSyncKind Change => TextDocumentSyncKind.Incremental; @@ -43,7 +42,7 @@ public PsesTextDocumentHandler( _remoteFileManagerService = remoteFileManagerService; } - public Task Handle(DidChangeTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidChangeTextDocumentParams notification, CancellationToken token) { ScriptFile changedFile = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -62,21 +61,14 @@ public Task Handle(DidChangeTextDocumentParams notification, CancellationT return Unit.Task; } - TextDocumentChangeRegistrationOptions IRegistration.GetRegistrationOptions() + protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities) => new TextDocumentSyncRegistrationOptions() { - return new TextDocumentChangeRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - SyncKind = Change - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + Change = Change, + Save = new SaveOptions { IncludeText = true } + }; - public void SetCapability(SynchronizationCapability capability) - { - _capability = capability; - } - - public Task Handle(DidOpenTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidOpenTextDocumentParams notification, CancellationToken token) { ScriptFile openedFile = _workspaceService.GetFileBuffer( @@ -98,15 +90,7 @@ public Task Handle(DidOpenTextDocumentParams notification, CancellationTok return Unit.Task; } - TextDocumentRegistrationOptions IRegistration.GetRegistrationOptions() - { - return new TextDocumentRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - }; - } - - public Task Handle(DidCloseTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidCloseTextDocumentParams notification, CancellationToken token) { // Find and close the file in the current session var fileToClose = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -121,7 +105,7 @@ public Task Handle(DidCloseTextDocumentParams notification, CancellationTo return Unit.Task; } - public async Task Handle(DidSaveTextDocumentParams notification, CancellationToken token) + public override async Task Handle(DidSaveTextDocumentParams notification, CancellationToken token) { ScriptFile savedFile = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -135,18 +119,7 @@ public async Task Handle(DidSaveTextDocumentParams notification, Cancellat return Unit.Value; } - TextDocumentSaveRegistrationOptions IRegistration.GetRegistrationOptions() - { - return new TextDocumentSaveRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - IncludeText = true - }; - } - public TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri) - { - return new TextDocumentAttributes(uri, "powershell"); - } + public override TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri) => new TextDocumentAttributes(uri, "powershell"); private static FileChange GetFileChangeDetails(Range changeRange, string insertString) { diff --git a/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs b/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs index a687690b2..c777af4f5 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; +using OmniSharp.Extensions.LanguageServer.Protocol.Models; namespace Microsoft.PowerShell.EditorServices.Services.TextDocument { diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index f5fcdf84a..5d47f31fb 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -22,14 +22,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesConfigurationHandler : IDidChangeConfigurationHandler + internal class PsesConfigurationHandler : DidChangeConfigurationHandlerBase { private readonly ILogger _logger; private readonly WorkspaceService _workspaceService; private readonly ConfigurationService _configurationService; private readonly PowerShellContextService _powerShellContextService; private readonly ILanguageServerFacade _languageServer; - private DidChangeConfigurationCapability _capability; private bool _profilesLoaded; private bool _consoleReplStarted; private bool _cwdSet; @@ -50,12 +49,7 @@ public PsesConfigurationHandler( ConfigurationUpdated += analysisService.OnConfigurationUpdated; } - public object GetRegistrationOptions() - { - return null; - } - - public async Task Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) + public override async Task Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject(); if(incomingSettings == null) @@ -199,7 +193,7 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS _languageServer.Window.SendTelemetryEvent(new TelemetryEventParams { - Data = new PsesTelemetryEvent + ExtensionData = new PsesTelemetryEvent { EventName = "NonDefaultPsesFeatureConfiguration", Data = JObject.FromObject(configChanges) @@ -207,11 +201,6 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS }); } - public void SetCapability(DidChangeConfigurationCapability capability) - { - _capability = capability; - } - public event EventHandler ConfigurationUpdated; } } diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs index 6c972d4e5..d87a22a7b 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs @@ -19,12 +19,11 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesWorkspaceSymbolsHandler : IWorkspaceSymbolsHandler + internal class PsesWorkspaceSymbolsHandler : WorkspaceSymbolsHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private WorkspaceSymbolCapability _capability; public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService symbols, WorkspaceService workspace) { _logger = loggerFactory.CreateLogger(); @@ -32,12 +31,9 @@ public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService _workspaceService = workspace; } - public WorkspaceSymbolRegistrationOptions GetRegistrationOptions() - { - return new WorkspaceSymbolRegistrationOptions(); - } + protected override WorkspaceSymbolRegistrationOptions CreateRegistrationOptions(WorkspaceSymbolCapability capability, ClientCapabilities clientCapabilities) => new WorkspaceSymbolRegistrationOptions { }; - public Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken) + public override Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken) { var symbols = new List(); @@ -77,11 +73,6 @@ public Task> Handle(WorkspaceSymbolParams request, return Task.FromResult(new Container(symbols)); } - public void SetCapability(WorkspaceSymbolCapability capability) - { - _capability = capability; - } - #region private Methods private bool IsQueryMatch(string query, string symbolName) diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs index e3fc8c0cd..91d6f8fac 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs @@ -4,19 +4,11 @@ // using System; -using System.IO; -using System.Reflection; using System.Threading.Tasks; using Microsoft.PowerShell.EditorServices.Handlers; -using Xunit; using OmniSharp.Extensions.DebugAdapter.Client; using OmniSharp.Extensions.DebugAdapter.Protocol.Requests; using System.Threading; -using System.Text; -using System.Linq; -using Xunit.Abstractions; -using Microsoft.Extensions.Logging; -using OmniSharp.Extensions.DebugAdapter.Protocol.Models; namespace PowerShellEditorServices.Test.E2E { @@ -24,7 +16,7 @@ public static class DebugAdapterClientExtensions { public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string filePath, TaskCompletionSource started) { - LaunchResponse launchResponse = await debugAdapterClient.RequestLaunch(new PsesLaunchRequestArguments + LaunchResponse launchResponse = await debugAdapterClient.Launch(new PsesLaunchRequestArguments { NoDebug = false, Script = filePath, diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index a70f570f5..bd8865d5e 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -182,7 +182,7 @@ public async Task CanSetBreakpointsAsync() await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); // {"command":"setBreakpoints","arguments":{"source":{"name":"dfsdfg.ps1","path":"/Users/tyleonha/Code/PowerShell/Misc/foo/dfsdfg.ps1"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false},"type":"request","seq":3} - SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.RequestSetBreakpoints(new SetBreakpointsArguments + SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.SetBreakpoints(new SetBreakpointsArguments { Source = new Source { diff --git a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs index ebf2c4692..fb283f775 100644 --- a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs +++ b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs @@ -63,8 +63,8 @@ public async Task InitializeAsync() .OnTelemetryEvent(telemetryEventParams => TelemetryEvents.Add( new PsesTelemetryEvent { - EventName = (string) telemetryEventParams.Data["eventName"], - Data = telemetryEventParams.Data["data"] as JObject + EventName = (string)telemetryEventParams.ExtensionData["eventName"], + Data = telemetryEventParams.ExtensionData["data"] as JObject })); // Enable all capabilities this this is for testing. diff --git a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs index d2b68d302..4fc22b58c 100644 --- a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs @@ -21,7 +21,6 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Workspace; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; using Xunit; using Xunit.Abstractions; using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; @@ -216,7 +215,7 @@ public async Task CanReceiveDiagnosticsFromFileChangedAsync() Text = "$a = 7" } }), - TextDocument = new VersionedTextDocumentIdentifier + TextDocument = new OptionalVersionedTextDocumentIdentifier { Version = 4, Uri = new Uri(filePath) diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 837a6a8fd..e78a9d322 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -1,4 +1,5 @@ + net6.0;netcoreapp3.1 @@ -9,9 +10,9 @@ - - - + + + diff --git a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs index 7d074557d..6414d4495 100644 --- a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs +++ b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs @@ -11,7 +11,7 @@ using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Handlers; using OmniSharp.Extensions.LanguageServer.Protocol; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; +using OmniSharp.Extensions.LanguageServer.Protocol.Models; using Xunit; namespace Microsoft.PowerShell.EditorServices.Test.Language diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 6f47ad923..aff271a6a 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -24,10 +24,10 @@ - + - +