From 3069b082eda9c463fca2e7554d5a90a342c18a59 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 19 Apr 2017 19:48:41 -0700 Subject: [PATCH 01/54] Add TextDocumentItem type for didOpen notification --- .../LanguageServer/TextDocument.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 92d516817..173f0ecca 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -8,6 +8,38 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer { + + /// + /// An item to transfer a text document from the client to the server + /// + public class TextDocumentItem + { + /// + /// Gets or sets the URI which identifies the path of the + /// text document. + /// + public string Uri { get; set; } + + /// + /// The text document's language identifier. + /// + /// + public string LanguageId { get; set; } + + /// + /// The version number of this document, which will strictly increase after each change, including + /// undo/redo. + /// + /// + public int Version { get; set;} + + /// + /// The content of the opened text document. + /// + /// + public string Text { get; set;} + } + /// /// Defines a base parameter class for identifying a text document. /// From f56770b419a1a30cb284cb007a13d93de8871b62 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 19 Apr 2017 19:50:36 -0700 Subject: [PATCH 02/54] Use TextDocumentItem type for didOpen notification --- .../LanguageServer/TextDocument.cs | 4 ++-- .../Server/LanguageServer.cs | 2 +- .../LanguageServerTests.cs | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 173f0ecca..aba0df89b 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -68,8 +68,8 @@ public class TextDocumentPosition : TextDocumentIdentifier public class DidOpenTextDocumentNotification : TextDocumentIdentifier { public static readonly - EventType Type = - EventType.Create("textDocument/didOpen"); + EventType Type = + EventType.Create("textDocument/didOpen"); /// /// Gets or sets the full content of the opened document. diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 629d2f0bb..cf0acd1ed 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -483,7 +483,7 @@ private async Task HandleFindModuleRequest( } protected Task HandleDidOpenTextDocumentNotification( - DidOpenTextDocumentNotification openParams, + TextDocumentItem openParams, EventContext eventContext) { ScriptFile openedFile = diff --git a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs index 4b6c0e527..390a9273d 100644 --- a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs +++ b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs @@ -746,11 +746,13 @@ private async Task SendOpenFileEvent(string filePath, bool waitForDiagnostics = await this.SendEvent( DidOpenTextDocumentNotification.Type, - new DidOpenTextDocumentNotification() + new TextDocumentItem() { Uri = filePath, - Text = fileContents - }); + Text = fileContents, + LanguageId = "PowerShell", + Version = 0 + }); if (diagnosticWaitTask != null) { @@ -758,4 +760,4 @@ await this.SendEvent( } } } -} \ No newline at end of file +} From eb8f44670f843e3ee6b1a2677ccf49bab441ba1c Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Fri, 21 Apr 2017 17:58:00 -0700 Subject: [PATCH 03/54] Add debugger display attribute to TextDocumentItem class --- .../LanguageServer/TextDocument.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index aba0df89b..10e58ad6f 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -12,6 +12,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer /// /// An item to transfer a text document from the client to the server /// + [DebuggerDisplay("TextDocumentItem = {Uri}:{LanguageId}:{Version}:{Text}")] public class TextDocumentItem { /// From f7e05e33f9b3051f40f32e58a483075cb4fd9f2e Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Fri, 21 Apr 2017 18:51:03 -0700 Subject: [PATCH 04/54] Add VersionedTextDocumentIdentifier type --- .../LanguageServer/TextDocument.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 10e58ad6f..50fe24007 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -54,6 +54,17 @@ public class TextDocumentIdentifier public string Uri { get; set; } } + /// + /// An identifier to denote a specific version of a text document. + /// + public class VersionedTextDocumentIdentifier : TextDocumentIdentifier + { + /// + /// The version number of this document. + /// + public int Version { get; set; } + } + /// /// Defines a position in a text document. /// From 3bf58da964c51539064af57398cf16579eb75693 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Fri, 21 Apr 2017 18:51:37 -0700 Subject: [PATCH 05/54] Update DidSaveTextDocumentParams type --- .../LanguageServer/TextDocument.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 50fe24007..35b910ae7 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -32,13 +32,13 @@ public class TextDocumentItem /// undo/redo. /// /// - public int Version { get; set;} + public int Version { get; set; } /// /// The content of the opened text document. /// /// - public string Text { get; set;} + public string Text { get; set; } } /// @@ -103,9 +103,21 @@ public static readonly EventType.Create("textDocument/didSave"); } + /// + /// The parameters sent in a save text document notification. + /// public class DidSaveTextDocumentParams { - public TextDocumentIdentifier TextDocument { get; set; } + /// + /// The document that was closed. + /// + public VersionedTextDocumentIdentifier TextDocument { get; set; } + + /// + /// Optional content when saved. Depends on the includeText value when the save notification was + /// included. + /// + public string Text { get; set; } } public class DidChangeTextDocumentNotification @@ -133,7 +145,7 @@ public class TextDocumentChangeEvent /// /// Gets or sets the length of the Range being replaced in the - /// document. Will be null if the server's TextDocumentSyncKind is + /// document. Will be null if the server's TextDocumentSyncKind is /// Full. /// public int? RangeLength { get; set; } From a4c4bb1bd2b240c966b7522143283e59e93cd546 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Fri, 21 Apr 2017 18:51:57 -0700 Subject: [PATCH 06/54] Update DidChangeTextDocumentParams type --- .../LanguageServer/TextDocument.cs | 11 ++++++++++- .../Server/LanguageServer.cs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 35b910ae7..d4b057a26 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -127,8 +127,17 @@ public static readonly EventType.Create("textDocument/didChange"); } - public class DidChangeTextDocumentParams : TextDocumentIdentifier + /// + /// The change text document notification's paramters. + /// + public class DidChangeTextDocumentParams { + /// + /// The document that did change. The version number points to the version after + /// all provided content changes have been applied. + /// + public VersionedTextDocumentIdentifier TextDocument; + /// /// Gets or sets the list of changes to the document content. /// diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index cf0acd1ed..e9306d53f 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -544,7 +544,7 @@ protected Task HandleDidChangeTextDocumentNotification( // A text change notification can batch multiple change requests foreach (var textChange in textChangeParams.ContentChanges) { - ScriptFile changedFile = editorSession.Workspace.GetFile(textChangeParams.Uri); + ScriptFile changedFile = editorSession.Workspace.GetFile(textChangeParams.TextDocument.Uri); changedFile.ApplyChange( GetFileChangeDetails( From 43aeebba532f5a735a6e5db27c68b149fd492b2c Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Fri, 21 Apr 2017 19:31:22 -0700 Subject: [PATCH 07/54] Update CompletionItem type --- .../LanguageServer/Completion.cs | 70 ++++++++++++++----- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs index 72d4a6ded..297de0323 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs @@ -24,25 +24,25 @@ public static readonly public enum CompletionItemKind { - Text = 1, - Method = 2, - Function = 3, - Constructor = 4, - Field = 5, - Variable = 6, - Class = 7, - Interface = 8, - Module = 9, - Property = 10, - Unit = 11, - Value = 12, - Enum = 13, - Keyword = 14, - Snippet = 15, - Color = 16, - File = 17, - Reference = 18, - Folder = 19 + Text = 1, + Method = 2, + Function = 3, + Constructor = 4, + Field = 5, + Variable = 6, + Class = 7, + Interface = 8, + Module = 9, + Property = 10, + Unit = 11, + Value = 12, + Enum = 13, + Keyword = 14, + Snippet = 15, + Color = 16, + File = 17, + Reference = 18, + Folder = 19 } [DebuggerDisplay("NewText = {NewText}, Range = {Range.Start.Line}:{Range.Start.Character} - {Range.End.Line}:{Range.End.Character}")] @@ -73,8 +73,16 @@ public class CompletionItem public string InsertText { get; set; } + public Range Range { get; set; } + + public string[] CommitCharacters { get; set; } + public TextEdit TextEdit { get; set; } + public TextEdit[] AdditionalTextEdits { get; set; } + + public Command Command { get; set; } + /// /// Gets or sets a custom data field that allows the server to mark /// each completion item with an identifier that will help correlate @@ -83,5 +91,29 @@ public class CompletionItem /// public object Data { get; set; } } + + /// + /// Represents a reference to a command. Provides a title which will be used to + /// represent a command in the UI and, optionally, an array of arguments which + /// will be passed to the command handler function when invoked. + /// + public class Command + { + /// + /// Title of the command. + /// + /// + public string Title { get; set; } + + /// + /// The identifier of the actual command handler. + /// + public string command { get; set; } + + /// + /// Arguments that the command handler should be invoked with. + /// + public object[] arguments { get; set; } + } } From 2cf5c18b97b73a0f88636516c5c4dcf7d3adc0b1 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 16:49:06 -0700 Subject: [PATCH 08/54] Add TextDocumentPositionParams type --- .../LanguageServer/TextDocument.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index d4b057a26..a6930d517 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -77,6 +77,23 @@ public class TextDocumentPosition : TextDocumentIdentifier public Position Position { get; set; } } + /// + /// A parameter literal used in requests to pass a text document and a position inside that document. + /// + public class TextDocumentPositionParams { + /// + /// The text document. + /// + /// + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// The position inside the text document. + /// + /// + public Position Position { get; set; } + } + public class DidOpenTextDocumentNotification : TextDocumentIdentifier { public static readonly From 4592484121db31b7546331c17ee77403c5b3af54 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 16:49:26 -0700 Subject: [PATCH 09/54] Use TextDocumentPositionParams for signature help --- .../LanguageServer/SignatureHelp.cs | 4 ++-- .../Server/LanguageServer.cs | 8 ++++---- .../LanguageServerTests.cs | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs index 6387461dc..002febf43 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class SignatureHelpRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/signatureHelp"); + RequestType Type = + RequestType.Create("textDocument/signatureHelp"); } public class ParameterInformation diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index e9306d53f..93db77dd7 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -773,18 +773,18 @@ await CommandHelpers.GetCommandSynopsis( } protected async Task HandleSignatureHelpRequest( - TextDocumentPosition textDocumentPosition, + TextDocumentPositionParams textDocumentPositionParams, RequestContext requestContext) { ScriptFile scriptFile = editorSession.Workspace.GetFile( - textDocumentPosition.Uri); + textDocumentPositionParams.TextDocument.Uri); ParameterSetSignatures parameterSets = await editorSession.LanguageService.FindParameterSetsInFile( scriptFile, - textDocumentPosition.Position.Line + 1, - textDocumentPosition.Position.Character + 1); + textDocumentPositionParams.Position.Line + 1, + textDocumentPositionParams.Position.Character + 1); SignatureInformation[] signatures = null; int? activeParameter = null; diff --git a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs index 390a9273d..efe09f878 100644 --- a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs +++ b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs @@ -453,9 +453,12 @@ public async Task GetsParameterHintsOnCommand() SignatureHelp signatureHelp = await this.SendRequest( SignatureHelpRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\FindReferences.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\FindReferences.ps1" + }, Position = new Position { Line = 12, From c9256a8985952f35c9b42b6c8752a36bd09dc71a Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 16:59:26 -0700 Subject: [PATCH 10/54] Update document highlight request --- .../LanguageServer/DocumentHighlight.cs | 8 ++++---- .../Server/LanguageServer.cs | 8 ++++---- .../LanguageServerTests.cs | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs index c169acc44..ca9791bf9 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs @@ -7,14 +7,14 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer { - public enum DocumentHighlightKind + public enum DocumentHighlightKind { Text = 1, Read = 2, Write = 3 } - public class DocumentHighlight + public class DocumentHighlight { public Range Range { get; set; } @@ -24,8 +24,8 @@ public class DocumentHighlight public class DocumentHighlightRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentHighlight"); + RequestType Type = + RequestType.Create("textDocument/documentHighlight"); } } diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 93db77dd7..c600ee63a 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -824,18 +824,18 @@ await requestContext.SendResult( } protected async Task HandleDocumentHighlightRequest( - TextDocumentPosition textDocumentPosition, + TextDocumentPositionParams textDocumentPositionParams, RequestContext requestContext) { ScriptFile scriptFile = editorSession.Workspace.GetFile( - textDocumentPosition.Uri); + textDocumentPositionParams.TextDocument.Uri); FindOccurrencesResult occurrencesResult = editorSession.LanguageService.FindOccurrencesInFile( scriptFile, - textDocumentPosition.Position.Line + 1, - textDocumentPosition.Position.Character + 1); + textDocumentPositionParams.Position.Line + 1, + textDocumentPositionParams.Position.Character + 1); DocumentHighlight[] documentHighlights = null; diff --git a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs index efe09f878..b8c1c3dd6 100644 --- a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs +++ b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs @@ -430,9 +430,12 @@ public async Task FindsOccurencesOnFunctionDefinition() DocumentHighlight[] highlights = await this.SendRequest( DocumentHighlightRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\FindReferences.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\FindReferences.ps1" + }, Position = new Position { Line = 0, From b25265b009a1b1d2dedbdc726f837a76628f540c Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:04:20 -0700 Subject: [PATCH 11/54] Update hover request --- .../LanguageServer/Hover.cs | 4 ++-- .../Server/LanguageServer.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs index 2af60e515..bb9582338 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs @@ -29,8 +29,8 @@ public class Hover public class HoverRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/hover"); + RequestType Type = + RequestType.Create("textDocument/hover"); } } diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index c600ee63a..4092ee3c3 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -863,20 +863,20 @@ protected async Task HandleDocumentHighlightRequest( } protected async Task HandleHoverRequest( - TextDocumentPosition textDocumentPosition, + TextDocumentPositionParams textDocumentPositionParams, RequestContext requestContext) { ScriptFile scriptFile = editorSession.Workspace.GetFile( - textDocumentPosition.Uri); + textDocumentPositionParams.TextDocument.Uri); SymbolDetails symbolDetails = await editorSession .LanguageService .FindSymbolDetailsAtLocation( scriptFile, - textDocumentPosition.Position.Line + 1, - textDocumentPosition.Position.Character + 1); + textDocumentPositionParams.Position.Line + 1, + textDocumentPositionParams.Position.Character + 1); List symbolInfo = new List(); Range? symbolRange = null; From d8db23871ef57bcde24da0713ec588b5dc3fcfc1 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:09:39 -0700 Subject: [PATCH 12/54] Add DocumentSymbolParams type --- .../LanguageServer/WorkspaceSymbols.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs index 405d6e98e..f7b2813f4 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs @@ -7,7 +7,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer { - public enum SymbolKind + public enum SymbolKind { File = 1, Module = 2, @@ -29,7 +29,7 @@ public enum SymbolKind Array = 18, } - public class SymbolInformation + public class SymbolInformation { public string Name { get; set; } @@ -43,8 +43,19 @@ public class SymbolInformation public class DocumentSymbolRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentSymbol"); + RequestType Type = + RequestType.Create("textDocument/documentSymbol"); + } + + /// + /// Parameters for a DocumentSymbolRequest + /// + public class DocumentSymbolParams + { + /// + /// The text document. + /// + public TextDocumentIdentifier TextDocument { get; set; } } public class WorkspaceSymbolRequest From 2d69674008fed87798482fd27fca470edab9b463 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:10:49 -0700 Subject: [PATCH 13/54] Update DocumentSymbolRequest --- .../Server/LanguageServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 4092ee3c3..2246089de 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -912,12 +912,12 @@ await requestContext.SendResult( } protected async Task HandleDocumentSymbolRequest( - TextDocumentIdentifier textDocumentIdentifier, + DocumentSymbolParams documentSymbolParams, RequestContext requestContext) { ScriptFile scriptFile = editorSession.Workspace.GetFile( - textDocumentIdentifier.Uri); + documentSymbolParams.TextDocument.Uri); FindOccurrencesResult foundSymbols = editorSession.LanguageService.FindSymbolsInFile( From 7188025b14da90495f1bc659f2ca5c0070379b32 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:27:53 -0700 Subject: [PATCH 14/54] Add CodeActionParams for CodeActionRequest --- .../LanguageServer/CodeAction.cs | 19 +++++++++++++++++-- .../Server/LanguageServer.cs | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs index deb0cb17f..e40c2e92d 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs @@ -6,13 +6,28 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CodeActionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/codeAction"); + RequestType Type = + RequestType.Create("textDocument/codeAction"); + } + /// + /// Parameters for CodeActionRequest. + /// + public class CodeActionParams + { + /// + /// The document in which the command was invoked. + /// public TextDocumentIdentifier TextDocument { get; set; } + /// + /// The range for which the command was invoked. + /// public Range Range { get; set; } + /// + /// Context carrying additional information. + /// public CodeActionContext Context { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 2246089de..6d3b368b1 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1078,7 +1078,7 @@ private bool IsQueryMatch(string query, string symbolName) } protected async Task HandleCodeActionRequest( - CodeActionRequest codeActionParams, + CodeActionParams codeActionParams, RequestContext requestContext) { MarkerCorrection correction = null; From da4b5735101c111eee9d17dc307a99bb5b68a1dc Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:39:52 -0700 Subject: [PATCH 15/54] Update DidOpenTextDocumentNotification --- .../LanguageServer/TextDocument.cs | 16 +++++++++++----- .../Server/LanguageServer.cs | 6 +++--- .../LanguageServerTests.cs | 15 +++++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index a6930d517..294a3c110 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -94,16 +94,22 @@ public class TextDocumentPositionParams { public Position Position { get; set; } } - public class DidOpenTextDocumentNotification : TextDocumentIdentifier + public class DidOpenTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didOpen"); + EventType Type = + EventType.Create("textDocument/didOpen"); + } + /// + /// The parameters sent in an open text document notification + /// + public class DidOpenTextDocumentParams + { /// - /// Gets or sets the full content of the opened document. + /// The document that was opened. /// - public string Text { get; set; } + public TextDocumentItem TextDocument { get; set; } } public class DidCloseTextDocumentNotification diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 6d3b368b1..6dad4b0da 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -483,13 +483,13 @@ private async Task HandleFindModuleRequest( } protected Task HandleDidOpenTextDocumentNotification( - TextDocumentItem openParams, + DidOpenTextDocumentParams openParams, EventContext eventContext) { ScriptFile openedFile = editorSession.Workspace.GetFileBuffer( - openParams.Uri, - openParams.Text); + openParams.TextDocument.Uri, + openParams.TextDocument.Text); // TODO: Get all recently edited files in the workspace this.RunScriptDiagnostics( diff --git a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs index b8c1c3dd6..88f8cdf30 100644 --- a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs +++ b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs @@ -752,13 +752,16 @@ private async Task SendOpenFileEvent(string filePath, bool waitForDiagnostics = await this.SendEvent( DidOpenTextDocumentNotification.Type, - new TextDocumentItem() + new DidOpenTextDocumentParams { - Uri = filePath, - Text = fileContents, - LanguageId = "PowerShell", - Version = 0 - }); + TextDocument = new TextDocumentItem + { + Uri = filePath, + Text = fileContents, + LanguageId = "PowerShell", + Version = 0 + } + }); if (diagnosticWaitTask != null) { From 5eaa247111045f469913b0689416a8792d059246 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Mon, 24 Apr 2017 17:49:04 -0700 Subject: [PATCH 16/54] Update DidCloseTextDocumentNotification --- .../LanguageServer/TextDocument.cs | 18 +++++++++++++++--- .../Server/LanguageServer.cs | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 294a3c110..bd4b11d05 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -80,7 +80,8 @@ public class TextDocumentPosition : TextDocumentIdentifier /// /// A parameter literal used in requests to pass a text document and a position inside that document. /// - public class TextDocumentPositionParams { + public class TextDocumentPositionParams + { /// /// The text document. /// @@ -115,8 +116,19 @@ public class DidOpenTextDocumentParams public class DidCloseTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didClose"); + EventType Type = + EventType.Create("textDocument/didClose"); + } + + /// + /// The parameters sent in a close text document notification. + /// + public class DidCloseTextDocumentParams + { + /// + /// The document that was closed. + /// + public TextDocumentIdentifier TextDocument { get; set; } } public class DidSaveTextDocumentNotification diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 6dad4b0da..bfc0dad5b 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -503,11 +503,11 @@ protected Task HandleDidOpenTextDocumentNotification( } protected async Task HandleDidCloseTextDocumentNotification( - TextDocumentIdentifier closeParams, + DidCloseTextDocumentParams closeParams, EventContext eventContext) { // Find and close the file in the current session - var fileToClose = editorSession.Workspace.GetFile(closeParams.Uri); + var fileToClose = editorSession.Workspace.GetFile(closeParams.TextDocument.Uri); if (fileToClose != null) { From e35449498e3efdac2adb9aee6a4dd428c0f2cb32 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 15:33:52 -0700 Subject: [PATCH 17/54] Add AbstractMessageType base class for request types --- .../MessageProtocol/AbstractMessageType.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/MessageProtocol/AbstractMessageType.cs diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/AbstractMessageType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/AbstractMessageType.cs new file mode 100644 index 000000000..1b2fc37f9 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/AbstractMessageType.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol +{ + /// + /// Defines an event type with a particular method name. + /// + /// The parameter type for this event. + public class AbstractMessageType + { + private string _method; + private int _numberOfParams; + + /// + /// Gets the method name for the event type. + /// + public string Method { get { return _method; } } + + /// + /// Gets the number of parameters. + /// + public int NumberOfParams { get; } + + public AbstractMessageType(string method, int numberOfParams) + { + _method = method; + _numberOfParams = numberOfParams; + } + } +} + + From 9de82e31fa643a039faa501f08a8eeb12d0f4d65 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 15:34:09 -0700 Subject: [PATCH 18/54] Add RequestType0 type and update related code --- .../LanguageServer/Shutdown.cs | 4 ++-- .../MessageProtocol/ProtocolEndpoint.cs | 21 +++++++++++++++++++ .../MessageProtocol/RequestType.cs | 10 +++++++++ .../Server/LanguageServerBase.cs | 1 - 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs index 519719015..1db69df05 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs @@ -14,8 +14,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ShutdownRequest { public static readonly - RequestType Type = - RequestType.Create("shutdown"); + RequestType0 Type = + RequestType0.Create("shutdown"); } /// diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index 92aed5ecb..705ac98c6 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -132,6 +132,15 @@ public async Task Stop() #region Message Sending + public Task SendRequest( + RequestType0 requestType0) + { + return this.SendRequest( + RequestType.ConvertToReqestType(requestType0), + null); + } + + /// /// Sends a request to the server /// @@ -254,6 +263,18 @@ await this.protocolChannel.MessageWriter.WriteEvent( #region Message Handling + public void SetRequestHandler( + RequestType0 requestType0, + Func, Task> requestHandler) + { + SetRequestHandler( + RequestType.ConvertToReqestType(requestType0), + (param1, requestContext) => + { + return requestHandler(requestContext); + }); + } + public void SetRequestHandler( RequestType requestType, Func, Task> requestHandler) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs index e5d0cea08..0a7f83ade 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs @@ -12,8 +12,18 @@ public class RequestType { public string MethodName { get; private set; } + public static RequestType ConvertToReqestType( + RequestType0 requestType0) + { + return RequestType.Create(requestType0.Method); + } public static RequestType Create(string typeName) { + if (typeName == null) + { + throw new System.ArgumentNullException(nameof(typeName)); + } + return new RequestType() { MethodName = typeName diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs index d23391785..ae70f0136 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs @@ -55,7 +55,6 @@ protected virtual Task Shutdown() } private async Task HandleShutdownRequest( - object shutdownParams, RequestContext requestContext) { // Allow the implementor to shut down gracefully From 26db6055d7b9f933d0e425b2ad5649456cfe7cbb Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 15:48:16 -0700 Subject: [PATCH 19/54] Parameterize calls to sendrequest --- .../Client/DebugAdapterClientBase.cs | 6 +++--- .../Client/LanguageClientBase.cs | 2 +- .../Client/LanguageServiceClient.cs | 4 ++-- test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs index 91e4e92e1..55c78d36f 100644 --- a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs +++ b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs @@ -19,13 +19,13 @@ public DebugAdapterClient(ChannelBase clientChannel) public async Task LaunchScript(string scriptFilePath) { - await this.SendRequest( + await this.SendRequest( LaunchRequest.Type, new LaunchRequestArguments { Script = scriptFilePath }); - await this.SendRequest(ConfigurationDoneRequest.Type, null); + await this.SendRequest(ConfigurationDoneRequest.Type, null); } protected override Task OnStart() @@ -36,7 +36,7 @@ protected override Task OnStart() protected override Task OnConnect() { // Initialize the debug adapter - return this.SendRequest( + return this.SendRequest( InitializeRequest.Type, new InitializeRequestArguments { diff --git a/src/PowerShellEditorServices.Protocol/Client/LanguageClientBase.cs b/src/PowerShellEditorServices.Protocol/Client/LanguageClientBase.cs index 665383d0d..4cbd62aa0 100644 --- a/src/PowerShellEditorServices.Protocol/Client/LanguageClientBase.cs +++ b/src/PowerShellEditorServices.Protocol/Client/LanguageClientBase.cs @@ -34,7 +34,7 @@ protected override Task OnStart() protected override async Task OnStop() { // First, notify the language server that we're stopping - var response = await this.SendRequest(ShutdownRequest.Type, new object()); + var response = await this.SendRequest(ShutdownRequest.Type); await this.SendEvent(ExitNotification.Type, new object()); } diff --git a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs index 67d769ed3..5f5375173 100644 --- a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs +++ b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs @@ -40,8 +40,8 @@ protected override Task OnConnect() Capabilities = new ClientCapabilities() }; - return this.SendRequest( - InitializeRequest.Type, + return this.SendRequest( + InitializeRequest.Type, initializeRequest); } diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index d7e7f3e2a..95c068b9e 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -139,7 +139,7 @@ protected Task SendRequest( TParams requestParams) { return - this.protocolClient.SendRequest( + this.protocolClient.SendRequest( requestType, requestParams); } From a2e9f90c3d88496f7217ff7acc4256c4606150ab Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 16:00:31 -0700 Subject: [PATCH 20/54] Separate test task in build script into separate components --- PowerShellEditorServices.build.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 5b99a9fb7..861f5d368 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -18,7 +18,7 @@ if ($PSVersionTable.PSEdition -ne "Core") { Add-Type -Assembly System.IO.Compression.FileSystem } -task SetupDotNet -Before Restore, Clean, Build, Test, TestPowerShellApi, PackageNuGet { +task SetupDotNet -Before Restore, Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi, PackageNuGet { $requiredSdkVersion = "1.0.0" @@ -157,9 +157,17 @@ function UploadTestLogs { } } -task Test -If { !$script:IsUnix } { +task Test TestServer,TestProtocol,TestHost + +task TestServer -If { !$script:IsUnix } { exec { & $script:dotnetExe test -c $Configuration -f net452 .\test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj } +} + +task TestProtocol -If { !$script:IsUnix} { exec { & $script:dotnetExe test -c $Configuration -f net452 .\test\PowerShellEditorServices.Test.Protocol\PowerShellEditorServices.Test.Protocol.csproj } +} + +task TestHost -If { !$script:IsUnix} { exec { & $script:dotnetExe test -c $Configuration -f net452 .\test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj } } From 424e23ca1f8e9213e794b64e99eae82c28eec169 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 16:10:05 -0700 Subject: [PATCH 21/54] Remove while loop used for reading error stream Whenever EditorServices fails to start up, ServerTestsBase.LaunchService goes into a while loop where it reads from the error stream line by line in an async manner, till the end of the stream. This causes the method to wait indefinitely in certain situations. Hence, we replace it with ReadToEndAsync method and time out on the task if it takes too long. This avoids the test cases from hanging at that point. --- .../ServerTestsBase.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index 95c068b9e..c74fc35bb 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -102,19 +102,16 @@ protected async Task> LaunchService( { // Must have read an error? Keep reading from error stream string errorString = completedRead.Result; + Task errorRead = this.serviceProcess.StandardError.ReadToEndAsync(); - while (true) + // Lets give the read operation 5 seconds to complete. Ideally, it shouldn't + // take that long at all, but just in case... + if (errorRead.Wait(5000)) { - Task errorRead = this.serviceProcess.StandardError.ReadLineAsync(); - if (!string.IsNullOrEmpty(errorRead.Result)) { errorString += errorRead.Result + Environment.NewLine; } - else - { - break; - } } throw new Exception("Could not launch powershell.exe:\r\n\r\n" + errorString); From 29df2623decf5dfe991d1a6ed21368b505a31d34 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 16:29:03 -0700 Subject: [PATCH 22/54] Remove trailing whitespace --- .../Client/LanguageServiceClient.cs | 6 +++--- .../MessageProtocol/ProtocolEndpoint.cs | 12 ++++++------ .../Server/LanguageServerBase.cs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs index 5f5375173..ef9c9c1fa 100644 --- a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs +++ b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs @@ -15,7 +15,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.Client { public class LanguageServiceClient : LanguageClientBase { - private Dictionary cachedDiagnostics = + private Dictionary cachedDiagnostics = new Dictionary(); public LanguageServiceClient(ChannelBase clientChannel) @@ -62,7 +62,7 @@ protected void OnDiagnosticsReceived(string filePath) #region Private Methods private Task HandlePublishDiagnosticsEvent( - PublishDiagnosticsNotification diagnostics, + PublishDiagnosticsNotification diagnostics, EventContext eventContext) { string normalizedPath = diagnostics.Uri.ToLower(); @@ -79,7 +79,7 @@ private Task HandlePublishDiagnosticsEvent( private static ScriptFileMarker GetMarkerFromDiagnostic(Diagnostic diagnostic) { - DiagnosticSeverity severity = + DiagnosticSeverity severity = diagnostic.Severity.GetValueOrDefault( DiagnosticSeverity.Error); diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index 705ac98c6..bc6579391 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -59,7 +59,7 @@ public ProtocolEndpoint( this.messageProtocolType = messageProtocolType; this.originalSynchronizationContext = SynchronizationContext.Current; } - + /// /// Starts the language server client and sends the Initialize method. /// @@ -150,14 +150,14 @@ public Task SendRequest( /// /// public Task SendRequest( - RequestType requestType, + RequestType requestType, TParams requestParams) { return this.SendRequest(requestType, requestParams, true); } public async Task SendRequest( - RequestType requestType, + RequestType requestType, TParams requestParams, bool waitForResponse) { @@ -182,13 +182,13 @@ public async Task SendRequest( { responseTask = new TaskCompletionSource(); this.pendingRequests.Add( - this.currentMessageId.ToString(), + this.currentMessageId.ToString(), responseTask); } await this.protocolChannel.MessageWriter.WriteRequest( - requestType, - requestParams, + requestType, + requestParams, this.currentMessageId); if (responseTask != null) diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs index ae70f0136..7f912cfba 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs @@ -14,7 +14,7 @@ public abstract class LanguageServerBase : ProtocolEndpoint { private ChannelBase serverChannel; - public LanguageServerBase(ChannelBase serverChannel) : + public LanguageServerBase(ChannelBase serverChannel) : base(serverChannel, MessageProtocolType.LanguageServer) { this.serverChannel = serverChannel; From 96191a97a5caa8e8b6f529d3eebd07ac7c4205e9 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:05:08 -0700 Subject: [PATCH 23/54] Update RequestType parametrization --- .../Client/DebugAdapterClientBase.cs | 6 +-- .../Client/LanguageServiceClient.cs | 2 +- .../DebugAdapter/AttachRequest.cs | 4 +- .../DebugAdapter/ConfigurationDoneRequest.cs | 4 +- .../DebugAdapter/ContinueRequest.cs | 4 +- .../DebugAdapter/DisconnectRequest.cs | 6 +-- .../DebugAdapter/EvaluateRequest.cs | 4 +- .../DebugAdapter/InitializeRequest.cs | 4 +- .../DebugAdapter/LaunchRequest.cs | 10 ++--- .../DebugAdapter/NextRequest.cs | 4 +- .../DebugAdapter/PauseRequest.cs | 4 +- .../DebugAdapter/ScopesRequest.cs | 4 +- .../DebugAdapter/SetBreakpointsRequest.cs | 4 +- .../SetExceptionBreakpointsRequest.cs | 4 +- .../SetFunctionBreakpointsRequest.cs | 4 +- .../DebugAdapter/SetVariableRequest.cs | 4 +- .../DebugAdapter/SourceRequest.cs | 4 +- .../DebugAdapter/StackTraceRequest.cs | 4 +- .../DebugAdapter/StepInRequest.cs | 4 +- .../DebugAdapter/StepOutRequest.cs | 4 +- .../DebugAdapter/ThreadsRequest.cs | 4 +- .../DebugAdapter/VariablesRequest.cs | 4 +- .../LanguageServer/CodeAction.cs | 4 +- .../LanguageServer/Completion.cs | 8 ++-- .../LanguageServer/Definition.cs | 4 +- .../LanguageServer/DocumentHighlight.cs | 4 +- .../LanguageServer/EditorCommands.cs | 44 +++++++++---------- .../LanguageServer/ExpandAliasRequest.cs | 4 +- .../LanguageServer/FindModuleRequest.cs | 4 +- .../GetPSHostProcessesRequest.cs | 4 +- .../LanguageServer/GetPSSARulesRequest.cs | 4 +- .../LanguageServer/Hover.cs | 4 +- .../LanguageServer/Initialize.cs | 4 +- .../LanguageServer/InstallModuleRequest.cs | 4 +- .../PowerShellVersionRequest.cs | 4 +- .../LanguageServer/ProjectTemplate.cs | 8 ++-- .../LanguageServer/References.cs | 4 +- .../ScriptFileMarkersRequest.cs | 4 +- .../LanguageServer/ScriptRegionRequest.cs | 4 +- .../LanguageServer/SetPSSARulesRequest.cs | 4 +- .../LanguageServer/ShowOnlineHelpRequest.cs | 6 +-- .../LanguageServer/SignatureHelp.cs | 4 +- .../LanguageServer/WorkspaceSymbols.cs | 8 ++-- .../MessageProtocol/IMessageSender.cs | 4 +- .../MessageProtocol/MessageDispatcher.cs | 10 ++--- .../MessageProtocol/MessageWriter.cs | 10 ++--- .../MessageProtocol/ProtocolEndpoint.cs | 20 ++++----- .../MessageProtocol/RequestType.cs | 11 ++--- .../Messages/PromptEvents.cs | 8 ++-- .../WebSocketChannelTest.cs | 2 +- .../ServerTestsBase.cs | 8 ++-- .../Server/OutputDebouncerTests.cs | 4 +- 52 files changed, 156 insertions(+), 155 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs index 55c78d36f..91e4e92e1 100644 --- a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs +++ b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs @@ -19,13 +19,13 @@ public DebugAdapterClient(ChannelBase clientChannel) public async Task LaunchScript(string scriptFilePath) { - await this.SendRequest( + await this.SendRequest( LaunchRequest.Type, new LaunchRequestArguments { Script = scriptFilePath }); - await this.SendRequest(ConfigurationDoneRequest.Type, null); + await this.SendRequest(ConfigurationDoneRequest.Type, null); } protected override Task OnStart() @@ -36,7 +36,7 @@ protected override Task OnStart() protected override Task OnConnect() { // Initialize the debug adapter - return this.SendRequest( + return this.SendRequest( InitializeRequest.Type, new InitializeRequestArguments { diff --git a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs index ef9c9c1fa..c218b4ef5 100644 --- a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs +++ b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs @@ -40,7 +40,7 @@ protected override Task OnConnect() Capabilities = new ClientCapabilities() }; - return this.SendRequest( + return this.SendRequest( InitializeRequest.Type, initializeRequest); } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/AttachRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/AttachRequest.cs index 4699a4315..e9734e002 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/AttachRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/AttachRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class AttachRequest { public static readonly - RequestType Type = - RequestType.Create("attach"); + RequestType Type = + RequestType.Create("attach"); } public class AttachRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ConfigurationDoneRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ConfigurationDoneRequest.cs index ef5e0c8ef..11cbc4ded 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ConfigurationDoneRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ConfigurationDoneRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ConfigurationDoneRequest { public static readonly - RequestType Type = - RequestType.Create("configurationDone"); + RequestType Type = + RequestType.Create("configurationDone"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinueRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinueRequest.cs index 5ee5b2ec9..3f9dbc59c 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinueRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinueRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ContinueRequest { public static readonly - RequestType Type = - RequestType.Create("continue"); + RequestType Type = + RequestType.Create("continue"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/DisconnectRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/DisconnectRequest.cs index 7f7036b0c..2235206cd 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/DisconnectRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/DisconnectRequest.cs @@ -7,11 +7,11 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter { - public class DisconnectRequest + public class DisconnectRequest { public static readonly - RequestType Type = - RequestType.Create("disconnect"); + RequestType Type = + RequestType.Create("disconnect"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/EvaluateRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/EvaluateRequest.cs index b079f59ae..d45e7d44a 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/EvaluateRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/EvaluateRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class EvaluateRequest { public static readonly - RequestType Type = - RequestType.Create("evaluate"); + RequestType Type = + RequestType.Create("evaluate"); } public class EvaluateRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs index 52a8869d3..7904759d9 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class InitializeRequest { public static readonly - RequestType Type = - RequestType.Create("initialize"); + RequestType Type = + RequestType.Create("initialize"); } public class InitializeRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs index b81e56f8d..d0a2435ff 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs @@ -12,8 +12,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class LaunchRequest { public static readonly - RequestType Type = - RequestType.Create("launch"); + RequestType Type = + RequestType.Create("launch"); } public class LaunchRequestArguments @@ -36,7 +36,7 @@ public class LaunchRequestArguments public bool NoDebug { get; set; } /// - /// Gets or sets a boolean value that determines whether to automatically stop + /// Gets or sets a boolean value that determines whether to automatically stop /// target after launch. If not specified, target does not stop. /// public bool StopOnEntry { get; set; } @@ -53,7 +53,7 @@ public class LaunchRequestArguments public string Cwd { get; set; } /// - /// Gets or sets the absolute path to the runtime executable to be used. + /// Gets or sets the absolute path to the runtime executable to be used. /// Default is the runtime executable on the PATH. /// public string RuntimeExecutable { get; set; } @@ -64,7 +64,7 @@ public class LaunchRequestArguments public string[] RuntimeArgs { get; set; } /// - /// Gets or sets optional environment variables to pass to the debuggee. The string valued + /// Gets or sets optional environment variables to pass to the debuggee. The string valued /// properties of the 'environmentVariables' are used as key/value pairs. /// public Dictionary Env { get; set; } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/NextRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/NextRequest.cs index 5cb2e6acd..1a254b96f 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/NextRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/NextRequest.cs @@ -13,8 +13,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class NextRequest { public static readonly - RequestType Type = - RequestType.Create("next"); + RequestType Type = + RequestType.Create("next"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/PauseRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/PauseRequest.cs index 86ceee4f4..6fa67c584 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/PauseRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/PauseRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class PauseRequest { public static readonly - RequestType Type = - RequestType.Create("pause"); + RequestType Type = + RequestType.Create("pause"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ScopesRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ScopesRequest.cs index 044f5bf73..4905ffdfe 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ScopesRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ScopesRequest.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ScopesRequest { public static readonly - RequestType Type = - RequestType.Create("scopes"); + RequestType Type = + RequestType.Create("scopes"); } [DebuggerDisplay("FrameId = {FrameId}")] diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs index 5b0f88bf2..82d41ac53 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs @@ -16,8 +16,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class SetBreakpointsRequest { public static readonly - RequestType Type = - RequestType.Create("setBreakpoints"); + RequestType Type = + RequestType.Create("setBreakpoints"); } public class SetBreakpointsRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetExceptionBreakpointsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetExceptionBreakpointsRequest.cs index a586f27bf..6a7313324 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetExceptionBreakpointsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetExceptionBreakpointsRequest.cs @@ -14,8 +14,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class SetExceptionBreakpointsRequest { public static readonly - RequestType Type = - RequestType.Create("setExceptionBreakpoints"); + RequestType Type = + RequestType.Create("setExceptionBreakpoints"); } /// diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs index 73b75f82e..6fb951553 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class SetFunctionBreakpointsRequest { public static readonly - RequestType Type = - RequestType.Create("setFunctionBreakpoints"); + RequestType Type = + RequestType.Create("setFunctionBreakpoints"); } public class SetFunctionBreakpointsRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs index 333327454..47e41cb36 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs @@ -15,8 +15,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class SetVariableRequest { public static readonly - RequestType Type = - RequestType.Create("setVariable"); + RequestType Type = + RequestType.Create("setVariable"); } [DebuggerDisplay("VariablesReference = {VariablesReference}")] diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SourceRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SourceRequest.cs index 9d185af23..48a2b0a17 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SourceRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SourceRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class SourceRequest { public static readonly - RequestType Type = - RequestType.Create("source"); + RequestType Type = + RequestType.Create("source"); } public class SourceRequestArguments diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StackTraceRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StackTraceRequest.cs index 06929ba45..4188dcab6 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StackTraceRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StackTraceRequest.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StackTraceRequest { public static readonly - RequestType Type = - RequestType.Create("stackTrace"); + RequestType Type = + RequestType.Create("stackTrace"); } [DebuggerDisplay("ThreadId = {ThreadId}, Levels = {Levels}")] diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StepInRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StepInRequest.cs index cfd8f7648..ec825ebbd 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StepInRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StepInRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StepInRequest { public static readonly - RequestType Type = - RequestType.Create("stepIn"); + RequestType Type = + RequestType.Create("stepIn"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StepOutRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StepOutRequest.cs index 5b86f3f7c..be0a31807 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StepOutRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StepOutRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StepOutRequest { public static readonly - RequestType Type = - RequestType.Create("stepOut"); + RequestType Type = + RequestType.Create("stepOut"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ThreadsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ThreadsRequest.cs index e72fcc969..24432d671 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ThreadsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ThreadsRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ThreadsRequest { public static readonly - RequestType Type = - RequestType.Create("threads"); + RequestType Type = + RequestType.Create("threads"); } public class ThreadsResponseBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/VariablesRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/VariablesRequest.cs index 40dbaabb9..f387c500f 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/VariablesRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/VariablesRequest.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class VariablesRequest { public static readonly - RequestType Type = - RequestType.Create("variables"); + RequestType Type = + RequestType.Create("variables"); } [DebuggerDisplay("VariablesReference = {VariablesReference}")] diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs index e40c2e92d..31b52d996 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs @@ -6,8 +6,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CodeActionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/codeAction"); + RequestType Type = + RequestType.Create("textDocument/codeAction"); } /// diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs index 297de0323..4b2cc8976 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs @@ -11,15 +11,15 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CompletionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/completion"); + RequestType Type = + RequestType.Create("textDocument/completion"); } public class CompletionResolveRequest { public static readonly - RequestType Type = - RequestType.Create("completionItem/resolve"); + RequestType Type = + RequestType.Create("completionItem/resolve"); } public enum CompletionItemKind diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs index 37241dd63..52f6aba80 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class DefinitionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/definition"); + RequestType Type = + RequestType.Create("textDocument/definition"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs index ca9791bf9..da1bdb267 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs @@ -24,8 +24,8 @@ public class DocumentHighlight public class DocumentHighlightRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentHighlight"); + RequestType Type = + RequestType.Create("textDocument/documentHighlight"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs index ee39820bd..8ebcf632f 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs @@ -49,8 +49,8 @@ public class ClientEditorContext public class InvokeExtensionCommandRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/invokeExtensionCommand"); + RequestType Type = + RequestType.Create("powerShell/invokeExtensionCommand"); public string Name { get; set; } @@ -60,8 +60,8 @@ public static readonly public class GetEditorContextRequest { public static readonly - RequestType Type = - RequestType.Create("editor/getEditorContext"); + RequestType Type = + RequestType.Create("editor/getEditorContext"); } public enum EditorCommandResponse @@ -73,8 +73,8 @@ public enum EditorCommandResponse public class InsertTextRequest { public static readonly - RequestType Type = - RequestType.Create("editor/insertText"); + RequestType Type = + RequestType.Create("editor/insertText"); public string FilePath { get; set; } @@ -86,8 +86,8 @@ public static readonly public class SetSelectionRequest { public static readonly - RequestType Type = - RequestType.Create("editor/setSelection"); + RequestType Type = + RequestType.Create("editor/setSelection"); public Range SelectionRange { get; set; } } @@ -95,8 +95,8 @@ public static readonly public class SetCursorPositionRequest { public static readonly - RequestType Type = - RequestType.Create("editor/setCursorPosition"); + RequestType Type = + RequestType.Create("editor/setCursorPosition"); public Position CursorPosition { get; set; } } @@ -104,43 +104,43 @@ public static readonly public class OpenFileRequest { public static readonly - RequestType Type = - RequestType.Create("editor/openFile"); + RequestType Type = + RequestType.Create("editor/openFile"); } public class CloseFileRequest { public static readonly - RequestType Type = - RequestType.Create("editor/closeFile"); + RequestType Type = + RequestType.Create("editor/closeFile"); } public class ShowInformationMessageRequest { public static readonly - RequestType Type = - RequestType.Create("editor/showInformationMessage"); + RequestType Type = + RequestType.Create("editor/showInformationMessage"); } public class ShowWarningMessageRequest { public static readonly - RequestType Type = - RequestType.Create("editor/showWarningMessage"); + RequestType Type = + RequestType.Create("editor/showWarningMessage"); } public class ShowErrorMessageRequest { public static readonly - RequestType Type = - RequestType.Create("editor/showErrorMessage"); + RequestType Type = + RequestType.Create("editor/showErrorMessage"); } public class SetStatusBarMessageRequest { public static readonly - RequestType Type = - RequestType.Create("editor/setStatusBarMessage"); + RequestType Type = + RequestType.Create("editor/setStatusBarMessage"); } public class StatusBarMessageDetails diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ExpandAliasRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ExpandAliasRequest.cs index cd79c92f2..d5c2a9bc9 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ExpandAliasRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ExpandAliasRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ExpandAliasRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/expandAlias"); + RequestType Type = + RequestType.Create("powerShell/expandAlias"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/FindModuleRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/FindModuleRequest.cs index 12ac6cf96..fe14fdb65 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/FindModuleRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/FindModuleRequest.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class FindModuleRequest { public static readonly - RequestType, object> Type = - RequestType, object>.Create("powerShell/findModule"); + RequestType, object, object, object> Type = + RequestType, object, object, object>.Create("powerShell/findModule"); } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSHostProcessesRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSHostProcessesRequest.cs index 59d93ac6c..3c33a61d3 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSHostProcessesRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSHostProcessesRequest.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class GetPSHostProcessesRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getPSHostProcesses"); + RequestType Type = + RequestType.Create("powerShell/getPSHostProcesses"); } public class GetPSHostProcessesResponse diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSSARulesRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSSARulesRequest.cs index 617e89c6e..2199558c5 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSSARulesRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/GetPSSARulesRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer class GetPSSARulesRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getPSSARules"); + RequestType Type = + RequestType.Create("powerShell/getPSSARules"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs index bb9582338..f46d7fe29 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs @@ -29,8 +29,8 @@ public class Hover public class HoverRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/hover"); + RequestType Type = + RequestType.Create("textDocument/hover"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs index 40a9d1a23..bef99a30e 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class InitializeRequest { public static readonly - RequestType Type = - RequestType.Create("initialize"); + RequestType Type = + RequestType.Create("initialize"); /// /// Gets or sets the root path of the editor's open workspace. diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/InstallModuleRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/InstallModuleRequest.cs index 2be47ce90..096d0e461 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/InstallModuleRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/InstallModuleRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer class InstallModuleRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/installModule"); + RequestType Type = + RequestType.Create("powerShell/installModule"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs index 87a7ac20e..8f16b0abb 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class PowerShellVersionRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getVersion"); + RequestType Type = + RequestType.Create("powerShell/getVersion"); } public class PowerShellVersion diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ProjectTemplate.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ProjectTemplate.cs index 74878cd43..1b7441b28 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ProjectTemplate.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ProjectTemplate.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class NewProjectFromTemplateRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/newProjectFromTemplate"); + RequestType Type = + RequestType.Create("powerShell/newProjectFromTemplate"); public string DestinationPath { get; set; } @@ -27,8 +27,8 @@ public class NewProjectFromTemplateResponse public class GetProjectTemplatesRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getProjectTemplates"); + RequestType Type = + RequestType.Create("powerShell/getProjectTemplates"); public bool IncludeInstalledModules { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs index a55ebebf9..e08b4c9c3 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ReferencesRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/references"); + RequestType Type = + RequestType.Create("textDocument/references"); } public class ReferencesParams : TextDocumentPosition diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptFileMarkersRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptFileMarkersRequest.cs index 868f53ead..5394ddd4c 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptFileMarkersRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptFileMarkersRequest.cs @@ -15,8 +15,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer class ScriptFileMarkersRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getScriptFileMarkers"); + RequestType Type = + RequestType.Create("powerShell/getScriptFileMarkers"); } /// diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptRegionRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptRegionRequest.cs index 82791ec54..79b36161e 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptRegionRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ScriptRegionRequest.cs @@ -13,8 +13,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer class ScriptRegionRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/getScriptRegion"); + RequestType Type = + RequestType.Create("powerShell/getScriptRegion"); } /// diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/SetPSSARulesRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/SetPSSARulesRequest.cs index 49723f708..e3298cbd8 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/SetPSSARulesRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/SetPSSARulesRequest.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer class SetPSSARulesRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/setPSSARules"); + RequestType Type = + RequestType.Create("powerShell/setPSSARules"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ShowOnlineHelpRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ShowOnlineHelpRequest.cs index 49c571faf..1e65df93d 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ShowOnlineHelpRequest.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ShowOnlineHelpRequest.cs @@ -9,8 +9,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer { public class ShowOnlineHelpRequest { - public static readonly - RequestType Type = - RequestType.Create("powerShell/showOnlineHelp"); + public static readonly + RequestType Type = + RequestType.Create("powerShell/showOnlineHelp"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs index 002febf43..d793d63b6 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class SignatureHelpRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/signatureHelp"); + RequestType Type = + RequestType.Create("textDocument/signatureHelp"); } public class ParameterInformation diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs index f7b2813f4..4eb790235 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs @@ -43,8 +43,8 @@ public class SymbolInformation public class DocumentSymbolRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentSymbol"); + RequestType Type = + RequestType.Create("textDocument/documentSymbol"); } /// @@ -61,8 +61,8 @@ public class DocumentSymbolParams public class WorkspaceSymbolRequest { public static readonly - RequestType Type = - RequestType.Create("workspace/symbol"); + RequestType Type = + RequestType.Create("workspace/symbol"); } public class WorkspaceSymbolParams diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs index 804743573..5eb2f06b9 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs @@ -13,8 +13,8 @@ Task SendEvent( EventType eventType, TParams eventParams); - Task SendRequest( - RequestType requestType, + Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse); } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index cda98a884..683de37e9 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -92,8 +92,8 @@ public void Stop() } } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler) { this.SetRequestHandler( @@ -102,8 +102,8 @@ public void SetRequestHandler( false); } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler, bool overrideExisting) { @@ -263,7 +263,7 @@ await this.DispatchMessage( } protected async Task DispatchMessage( - Message messageToDispatch, + Message messageToDispatch, MessageWriter messageWriter) { Task handlerToAwait = null; diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index 28fbe1eb6..37f85dbad 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -21,7 +21,7 @@ public class MessageWriter private IMessageSerializer messageSerializer; private AsyncLock writeLock = new AsyncLock(); - private JsonSerializer contentSerializer = + private JsonSerializer contentSerializer = JsonSerializer.Create( Constants.JsonSerializerSettings); @@ -71,7 +71,7 @@ public async Task WriteMessage(Message messageToWrite) Constants.JsonSerializerSettings); byte[] messageBytes = Encoding.UTF8.GetBytes(serializedMessage); - byte[] headerBytes = + byte[] headerBytes = Encoding.ASCII.GetBytes( string.Format( Constants.ContentLengthFormatString, @@ -89,8 +89,8 @@ public async Task WriteMessage(Message messageToWrite) } } - public async Task WriteRequest( - RequestType requestType, + public async Task WriteRequest( + RequestType requestType, TParams requestParams, int requestId) { @@ -102,7 +102,7 @@ public async Task WriteRequest( await this.WriteMessage( Message.Request( - requestId.ToString(), + requestId.ToString(), requestType.MethodName, contentObject)); } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index bc6579391..da5e4fb98 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -135,8 +135,8 @@ public async Task Stop() public Task SendRequest( RequestType0 requestType0) { - return this.SendRequest( - RequestType.ConvertToReqestType(requestType0), + return this.SendRequest( + RequestType.ConvertToRequestType(requestType0), null); } @@ -149,15 +149,15 @@ public Task SendRequest( /// /// /// - public Task SendRequest( - RequestType requestType, + public Task SendRequest( + RequestType requestType, TParams requestParams) { return this.SendRequest(requestType, requestParams, true); } - public async Task SendRequest( - RequestType requestType, + public async Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse) { @@ -186,7 +186,7 @@ public async Task SendRequest( responseTask); } - await this.protocolChannel.MessageWriter.WriteRequest( + await this.protocolChannel.MessageWriter.WriteRequest( requestType, requestParams, this.currentMessageId); @@ -268,15 +268,15 @@ public void SetRequestHandler( Func, Task> requestHandler) { SetRequestHandler( - RequestType.ConvertToReqestType(requestType0), + RequestType.ConvertToRequestType(requestType0), (param1, requestContext) => { return requestHandler(requestContext); }); } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler) { this.MessageDispatcher.SetRequestHandler( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs index 0a7f83ade..ab9fecc47 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs @@ -8,23 +8,24 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { [DebuggerDisplay("RequestType MethodName = {MethodName}")] - public class RequestType + public class RequestType { public string MethodName { get; private set; } - public static RequestType ConvertToReqestType( + public static RequestType ConvertToRequestType( RequestType0 requestType0) { - return RequestType.Create(requestType0.Method); + return RequestType.Create(requestType0.Method); } - public static RequestType Create(string typeName) + + public static RequestType Create(string typeName) { if (typeName == null) { throw new System.ArgumentNullException(nameof(typeName)); } - return new RequestType() + return new RequestType() { MethodName = typeName }; diff --git a/src/PowerShellEditorServices.Protocol/Messages/PromptEvents.cs b/src/PowerShellEditorServices.Protocol/Messages/PromptEvents.cs index 031b996af..3a04eaf1e 100644 --- a/src/PowerShellEditorServices.Protocol/Messages/PromptEvents.cs +++ b/src/PowerShellEditorServices.Protocol/Messages/PromptEvents.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.Messages public class ShowChoicePromptRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/showChoicePrompt"); + RequestType Type = + RequestType.Create("powerShell/showChoicePrompt"); public bool IsMultiChoice { get; set; } @@ -34,8 +34,8 @@ public class ShowChoicePromptResponse public class ShowInputPromptRequest { public static readonly - RequestType Type = - RequestType.Create("powerShell/showInputPrompt"); + RequestType Type = + RequestType.Create("powerShell/showInputPrompt"); /// /// Gets or sets the name of the field. diff --git a/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs b/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs index 71d94c1a8..f95a56f94 100644 --- a/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs +++ b/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs @@ -50,7 +50,7 @@ await this.SendRequest( } private Task SendRequest( - RequestType requestType, + RequestType requestType, TParams requestParams) { return diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index c74fc35bb..d2ea09a49 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -131,12 +131,12 @@ protected void KillService() } } - protected Task SendRequest( - RequestType requestType, + protected Task SendRequest( + RequestType requestType, TParams requestParams) { return - this.protocolClient.SendRequest( + this.protocolClient.SendRequest( requestType, requestParams); } @@ -218,7 +218,7 @@ protected async Task WaitForEvent( } protected async Task>> WaitForRequest( - RequestType requestType, + RequestType requestType, int timeoutMilliseconds = 5000) { Task>> requestTask = null; diff --git a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs index a8b822a3b..d75472f1b 100644 --- a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs +++ b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs @@ -113,8 +113,8 @@ public Task SendEvent( return Task.FromResult(true); } - public Task SendRequest( - RequestType requestType, + public Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse) { // Legitimately not implemented for these tests. From 808281125cd7783fd3d95454d0ed6963f8073b46 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:05:52 -0700 Subject: [PATCH 24/54] Add missing RequestType0 file --- .../MessageProtocol/RequestType0.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs new file mode 100644 index 000000000..90666b927 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.Diagnostics; + +namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol +{ + [DebuggerDisplay("RequestType0 Method = {Method}")] + public class RequestType0 : AbstractMessageType + { + public RequestType0(string method) : base(method, 0) + { + } + + public static RequestType0 Create(string method) + { + return new RequestType0(method); + } + } +} From 563fce058582cc2e4dbb67a1d4de14dd4b25bc00 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:10:27 -0700 Subject: [PATCH 25/54] Change RequestType.MethodName to RequestType.Method --- .../MessageProtocol/MessageDispatcher.cs | 4 ++-- .../MessageProtocol/MessageWriter.cs | 2 +- .../MessageProtocol/RequestType.cs | 6 +++--- test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index 683de37e9..90e8a0691 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -110,11 +110,11 @@ public void SetRequestHandler( if (overrideExisting) { // Remove the existing handler so a new one can be set - this.requestHandlers.Remove(requestType.MethodName); + this.requestHandlers.Remove(requestType.Method); } this.requestHandlers.Add( - requestType.MethodName, + requestType.Method, (requestMessage, messageWriter) => { var requestContext = diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index 37f85dbad..1b0c4b241 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -103,7 +103,7 @@ public async Task WriteRequest( await this.WriteMessage( Message.Request( requestId.ToString(), - requestType.MethodName, + requestType.Method, contentObject)); } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs index ab9fecc47..03f4ca242 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs @@ -7,10 +7,10 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { - [DebuggerDisplay("RequestType MethodName = {MethodName}")] + [DebuggerDisplay("RequestType Method = {Method}")] public class RequestType { - public string MethodName { get; private set; } + public string Method { get; private set; } public static RequestType ConvertToRequestType( RequestType0 requestType0) @@ -27,7 +27,7 @@ public static RequestType Create( return new RequestType() { - MethodName = typeName + Method = typeName }; } } diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index d2ea09a49..c26e57871 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -225,7 +225,7 @@ protected async Task>> WaitForRequest requestQueue = null; - if (this.requestQueuePerType.TryGetValue(requestType.MethodName, out requestQueue)) + if (this.requestQueuePerType.TryGetValue(requestType.Method, out requestQueue)) { requestTask = requestQueue @@ -264,7 +264,7 @@ protected async Task>> WaitForRequest Date: Wed, 26 Apr 2017 17:17:32 -0700 Subject: [PATCH 26/54] Derive RequestType from AbstractMessageType --- .../MessageProtocol/RequestType.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs index 03f4ca242..9b0472087 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs @@ -8,9 +8,12 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { [DebuggerDisplay("RequestType Method = {Method}")] - public class RequestType + public class RequestType : AbstractMessageType { - public string Method { get; private set; } + private RequestType(string method) : base(method, 1) + { + + } public static RequestType ConvertToRequestType( RequestType0 requestType0) @@ -18,17 +21,14 @@ public static RequestType Convert return RequestType.Create(requestType0.Method); } - public static RequestType Create(string typeName) + public static RequestType Create(string method) { - if (typeName == null) + if (method == null) { - throw new System.ArgumentNullException(nameof(typeName)); + throw new System.ArgumentNullException(nameof(method)); } - return new RequestType() - { - Method = typeName - }; + return new RequestType(method); } } } From c9ddc48d18bcaf26bbe72b5ffb6277e5050c0e6e Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:24:52 -0700 Subject: [PATCH 27/54] Change EventType to NotificationType --- .../DebugAdapter/ContinuedEvent.cs | 4 ++-- .../DebugAdapter/ExitedEvent.cs | 4 ++-- .../DebugAdapter/InitializedEvent.cs | 4 ++-- .../DebugAdapter/OutputEvent.cs | 4 ++-- .../DebugAdapter/StartedEvent.cs | 4 ++-- .../DebugAdapter/StoppedEvent.cs | 6 +++--- .../DebugAdapter/TerminatedEvent.cs | 4 ++-- .../LanguageServer/Configuration.cs | 6 +++--- .../LanguageServer/Diagnostics.cs | 6 +++--- .../LanguageServer/EditorCommands.cs | 12 ++++++------ .../LanguageServer/RunspaceChanged.cs | 4 ++-- .../LanguageServer/Shutdown.cs | 4 ++-- .../LanguageServer/TextDocument.cs | 16 ++++++++-------- .../MessageProtocol/EventContext.cs | 2 +- .../MessageProtocol/EventType.cs | 6 +++--- .../MessageProtocol/IMessageSender.cs | 2 +- .../MessageProtocol/MessageDispatcher.cs | 4 ++-- .../MessageProtocol/MessageWriter.cs | 2 +- .../MessageProtocol/ProtocolEndpoint.cs | 6 +++--- .../MessageProtocol/RequestContext.cs | 2 +- .../Server/LanguageServer.cs | 6 +++--- .../ServerTestsBase.cs | 6 +++--- .../Server/OutputDebouncerTests.cs | 2 +- 23 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs index 8e307500a..01a7dde07 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ContinuedEvent { public static readonly - EventType Type = - EventType.Create("continued"); + NotificationType Type = + NotificationType.Create("continued"); public int ThreadId { get; set; } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs index 8a2189736..c8741b539 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ExitedEvent { public static readonly - EventType Type = - EventType.Create("exited"); + NotificationType Type = + NotificationType.Create("exited"); } public class ExitedEventBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs index 68ed66807..675a82c88 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class InitializedEvent { public static readonly - EventType Type = - EventType.Create("initialized"); + NotificationType Type = + NotificationType.Create("initialized"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs index a9cfee8c3..428addacb 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class OutputEvent { public static readonly - EventType Type = - EventType.Create("output"); + NotificationType Type = + NotificationType.Create("output"); } public class OutputEventBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs index f08f504b4..7bcfd37a2 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StartedEvent { public static readonly - EventType Type = - EventType.Create("started"); + NotificationType Type = + NotificationType.Create("started"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs index 8d88a1e5a..6a799eb5f 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StoppedEvent { public static readonly - EventType Type = - EventType.Create("stopped"); + NotificationType Type = + NotificationType.Create("stopped"); } public class StoppedEventBody @@ -26,7 +26,7 @@ public class StoppedEventBody /// public int? ThreadId { get; set; } - public Source Source { get; set; } + public Source Source { get; set; } /// /// Gets or sets additional information such as an error message. diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs index 39202676d..04962f364 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class TerminatedEvent { public static readonly - EventType Type = - EventType.Create("terminated"); + NotificationType Type = + NotificationType.Create("terminated"); public bool Restart { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs index d4f57781d..e2b9fa135 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs @@ -7,11 +7,11 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer { - public class DidChangeConfigurationNotification + public class DidChangeConfigurationNotification { public static readonly - EventType> Type = - EventType>.Create("workspace/didChangeConfiguration"); + NotificationType> Type = + NotificationType>.Create("workspace/didChangeConfiguration"); } public class DidChangeConfigurationParams diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs index 7aa99a69e..53795be15 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs @@ -15,8 +15,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class PublishDiagnosticsNotification { public static readonly - EventType Type = - EventType.Create("textDocument/publishDiagnostics"); + NotificationType Type = + NotificationType.Create("textDocument/publishDiagnostics"); /// /// Gets or sets the URI for which diagnostic information is reported. @@ -29,7 +29,7 @@ public static readonly public Diagnostic[] Diagnostics { get; set; } } - public enum DiagnosticSeverity + public enum DiagnosticSeverity { /// /// Indicates that the diagnostic represents an error. diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs index 8ebcf632f..cc7d273a8 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ExtensionCommandAddedNotification { public static readonly - EventType Type = - EventType.Create("powerShell/extensionCommandAdded"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandAdded"); public string Name { get; set; } @@ -21,8 +21,8 @@ public static readonly public class ExtensionCommandUpdatedNotification { public static readonly - EventType Type = - EventType.Create("powerShell/extensionCommandUpdated"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandUpdated"); public string Name { get; set; } } @@ -30,8 +30,8 @@ public static readonly public class ExtensionCommandRemovedNotification { public static readonly - EventType Type = - EventType.Create("powerShell/extensionCommandRemoved"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandRemoved"); public string Name { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs index 77a0148dc..bf87c0aa9 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class RunspaceChangedEvent { public static readonly - EventType Type = - EventType.Create("powerShell/runspaceChanged"); + NotificationType Type = + NotificationType.Create("powerShell/runspaceChanged"); } public class RunspaceDetails diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs index 1db69df05..2c35f33f8 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs @@ -25,8 +25,8 @@ public static readonly public class ExitNotification { public static readonly - EventType Type = - EventType.Create("exit"); + NotificationType Type = + NotificationType.Create("exit"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index bd4b11d05..b91b244f5 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -98,8 +98,8 @@ public class TextDocumentPositionParams public class DidOpenTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didOpen"); + NotificationType Type = + NotificationType.Create("textDocument/didOpen"); } /// @@ -116,8 +116,8 @@ public class DidOpenTextDocumentParams public class DidCloseTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didClose"); + NotificationType Type = + NotificationType.Create("textDocument/didClose"); } /// @@ -134,8 +134,8 @@ public class DidCloseTextDocumentParams public class DidSaveTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didSave"); + NotificationType Type = + NotificationType.Create("textDocument/didSave"); } /// @@ -158,8 +158,8 @@ public class DidSaveTextDocumentParams public class DidChangeTextDocumentNotification { public static readonly - EventType Type = - EventType.Create("textDocument/didChange"); + NotificationType Type = + NotificationType.Create("textDocument/didChange"); } /// diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs index e4f4051df..8843ed3e5 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs @@ -22,7 +22,7 @@ public EventContext(MessageWriter messageWriter) } public async Task SendEvent( - EventType eventType, + NotificationType eventType, TParams eventParams) { await this.messageWriter.WriteEvent( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs index 1b2fe1893..46b033748 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs @@ -9,7 +9,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol /// Defines an event type with a particular method name. /// /// The parameter type for this event. - public class EventType + public class NotificationType { /// /// Gets the method name for the event type. @@ -21,9 +21,9 @@ public class EventType /// /// The method name of the event. /// A new EventType instance for the defined type. - public static EventType Create(string methodName) + public static NotificationType Create(string methodName) { - return new EventType() + return new NotificationType() { MethodName = methodName }; diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs index 5eb2f06b9..4e9ffab2b 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol internal interface IMessageSender { Task SendEvent( - EventType eventType, + NotificationType eventType, TParams eventParams); Task SendRequest( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index 90e8a0691..13393df7f 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -134,7 +134,7 @@ public void SetRequestHandler( } public void SetEventHandler( - EventType eventType, + NotificationType eventType, Func eventHandler) { this.SetEventHandler( @@ -144,7 +144,7 @@ public void SetEventHandler( } public void SetEventHandler( - EventType eventType, + NotificationType eventType, Func eventHandler, bool overrideExisting) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index 1b0c4b241..0bc71c19d 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -122,7 +122,7 @@ await this.WriteMessage( contentObject)); } - public async Task WriteEvent(EventType eventType, TParams eventParams) + public async Task WriteEvent(NotificationType eventType, TParams eventParams) { // Allow null content JToken contentObject = diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index da5e4fb98..4802bc9ab 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -215,7 +215,7 @@ await this.protocolChannel.MessageWriter.WriteRequestThe event parameters being sent. /// A Task that tracks completion of the send operation. public Task SendEvent( - EventType eventType, + NotificationType eventType, TParams eventParams) { // Some requests may still be in the SynchronizationContext queue @@ -285,7 +285,7 @@ public void SetRequestHandler( } public void SetEventHandler( - EventType eventType, + NotificationType eventType, Func eventHandler) { this.MessageDispatcher.SetEventHandler( @@ -295,7 +295,7 @@ public void SetEventHandler( } public void SetEventHandler( - EventType eventType, + NotificationType eventType, Func eventHandler, bool overrideExisting) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs index a578f4668..5ec053f14 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs @@ -27,7 +27,7 @@ await this.messageWriter.WriteResponse( requestMessage.Id); } - public async Task SendEvent(EventType eventType, TParams eventParams) + public async Task SendEvent(NotificationType eventType, TParams eventParams) { await this.messageWriter.WriteEvent( eventType, diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index bfc0dad5b..f39a3c84d 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1249,7 +1249,7 @@ private Task RunScriptDiagnostics( private Task RunScriptDiagnostics( ScriptFile[] filesToAnalyze, EditorSession editorSession, - Func, PublishDiagnosticsNotification, Task> eventSender) + Func, PublishDiagnosticsNotification, Task> eventSender) { // If there's an existing task, attempt to cancel it try @@ -1327,7 +1327,7 @@ private static async Task DelayThenInvokeDiagnostics( bool isScriptAnalysisEnabled, Dictionary> correctionIndex, EditorSession editorSession, - Func, PublishDiagnosticsNotification, Task> eventSender, + Func, PublishDiagnosticsNotification, Task> eventSender, CancellationToken cancellationToken) { // First of all, wait for the desired delay period before @@ -1403,7 +1403,7 @@ private static async Task PublishScriptDiagnostics( ScriptFile scriptFile, ScriptFileMarker[] markers, Dictionary> correctionIndex, - Func, PublishDiagnosticsNotification, Task> eventSender) + Func, PublishDiagnosticsNotification, Task> eventSender) { List diagnostics = new List(); diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index c26e57871..a0170a60a 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -141,7 +141,7 @@ protected Task SendRequest(EventType eventType, TParams eventParams) + protected Task SendEvent(NotificationType eventType, TParams eventParams) { return this.protocolClient.SendEvent( @@ -149,7 +149,7 @@ protected Task SendEvent(EventType eventType, TParams eventPar eventParams); } - protected void QueueEventsForType(EventType eventType) + protected void QueueEventsForType(NotificationType eventType) { var eventQueue = this.eventQueuePerType.AddOrUpdate( @@ -166,7 +166,7 @@ protected void QueueEventsForType(EventType eventType) } protected async Task WaitForEvent( - EventType eventType, + NotificationType eventType, int timeoutMilliseconds = 5000) { Task eventTask = null; diff --git a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs index d75472f1b..7cb1cf886 100644 --- a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs +++ b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs @@ -100,7 +100,7 @@ internal class TestMessageSender : IMessageSender public List OutputEvents { get; } = new List(); public Task SendEvent( - EventType eventType, + NotificationType eventType, TParams eventParams) { OutputEventBody outputEvent = eventParams as OutputEventBody; From f94b3edb10b898ee846f25941a17beb89b2b287f Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:31:43 -0700 Subject: [PATCH 28/54] Change NotificationType.MethodName to NotificationType.Method --- .../MessageProtocol/EventType.cs | 8 ++++---- .../MessageProtocol/MessageDispatcher.cs | 4 ++-- .../MessageProtocol/MessageWriter.cs | 2 +- .../PowerShellEditorServices.Test.Host/ServerTestsBase.cs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs index 46b033748..659e13c37 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs @@ -14,18 +14,18 @@ public class NotificationType /// /// Gets the method name for the event type. /// - public string MethodName { get; private set; } + public string Method { get; private set; } /// /// Creates an EventType instance with the given parameter type and method name. /// - /// The method name of the event. + /// The method name of the event. /// A new EventType instance for the defined type. - public static NotificationType Create(string methodName) + public static NotificationType Create(string method) { return new NotificationType() { - MethodName = methodName + Method = method }; } } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index 13393df7f..d112a669e 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -151,11 +151,11 @@ public void SetEventHandler( if (overrideExisting) { // Remove the existing handler so a new one can be set - this.eventHandlers.Remove(eventType.MethodName); + this.eventHandlers.Remove(eventType.Method); } this.eventHandlers.Add( - eventType.MethodName, + eventType.Method, (eventMessage, messageWriter) => { var eventContext = new EventContext(messageWriter); diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index 0bc71c19d..326d4fbd4 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -132,7 +132,7 @@ public async Task WriteEvent(NotificationType eventType, TPara await this.WriteMessage( Message.Event( - eventType.MethodName, + eventType.Method, contentObject)); } diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index a0170a60a..34315c629 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -153,7 +153,7 @@ protected void QueueEventsForType(NotificationType eventType) { var eventQueue = this.eventQueuePerType.AddOrUpdate( - eventType.MethodName, + eventType.Method, new AsyncQueue(), (key, queue) => queue); @@ -173,7 +173,7 @@ protected async Task WaitForEvent( // Use the event queue if one has been registered AsyncQueue eventQueue = null; - if (this.eventQueuePerType.TryGetValue(eventType.MethodName, out eventQueue)) + if (this.eventQueuePerType.TryGetValue(eventType.Method, out eventQueue)) { eventTask = eventQueue @@ -211,7 +211,7 @@ protected async Task WaitForEvent( throw new TimeoutException( string.Format( "Timed out waiting for '{0}' event!", - eventType.MethodName)); + eventType.Method)); } return await eventTask; From 4c68d90b9e711eb9a96da47ce85d0366b1faab66 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:32:36 -0700 Subject: [PATCH 29/54] Derive NotificationType from AbstractMessageType --- .../MessageProtocol/EventType.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs index 659e13c37..b43507a03 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs @@ -9,12 +9,12 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol /// Defines an event type with a particular method name. /// /// The parameter type for this event. - public class NotificationType + public class NotificationType : AbstractMessageType { - /// - /// Gets the method name for the event type. - /// - public string Method { get; private set; } + private NotificationType(string method) : base(method, 1) + { + + } /// /// Creates an EventType instance with the given parameter type and method name. @@ -23,10 +23,7 @@ public class NotificationType /// A new EventType instance for the defined type. public static NotificationType Create(string method) { - return new NotificationType() - { - Method = method - }; + return new NotificationType(method); } } } From 8324d4337fbdd082491b75e2129da81a9faa8660 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 17:57:45 -0700 Subject: [PATCH 30/54] Update NotificationType template parameters --- .../DebugAdapter/ContinuedEvent.cs | 5 +++-- .../DebugAdapter/ExitedEvent.cs | 4 ++-- .../DebugAdapter/InitializedEvent.cs | 4 ++-- .../DebugAdapter/OutputEvent.cs | 4 ++-- .../DebugAdapter/StartedEvent.cs | 4 ++-- .../DebugAdapter/StoppedEvent.cs | 4 ++-- .../DebugAdapter/TerminatedEvent.cs | 4 ++-- .../LanguageServer/Configuration.cs | 4 ++-- .../LanguageServer/Diagnostics.cs | 4 ++-- .../LanguageServer/EditorCommands.cs | 12 ++++++------ .../LanguageServer/RunspaceChanged.cs | 4 ++-- .../LanguageServer/Shutdown.cs | 4 ++-- .../LanguageServer/TextDocument.cs | 16 ++++++++-------- .../MessageProtocol/EventContext.cs | 4 ++-- .../MessageProtocol/EventType.cs | 6 +++--- .../MessageProtocol/IMessageSender.cs | 4 ++-- .../MessageProtocol/MessageDispatcher.cs | 8 ++++---- .../MessageProtocol/MessageWriter.cs | 2 +- .../MessageProtocol/ProtocolEndpoint.cs | 12 ++++++------ .../MessageProtocol/RequestContext.cs | 2 +- .../Server/DebugAdapter.cs | 2 +- .../Server/LanguageServer.cs | 6 +++--- .../ServerTestsBase.cs | 8 ++++---- .../Server/OutputDebouncerTests.cs | 4 ++-- 24 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs index 01a7dde07..af442750f 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ContinuedEvent.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System; using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter @@ -10,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ContinuedEvent { public static readonly - NotificationType Type = - NotificationType.Create("continued"); + NotificationType Type = + NotificationType.Create("continued"); public int ThreadId { get; set; } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs index c8741b539..9f1a0d6ce 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/ExitedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class ExitedEvent { public static readonly - NotificationType Type = - NotificationType.Create("exited"); + NotificationType Type = + NotificationType.Create("exited"); } public class ExitedEventBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs index 675a82c88..7253b7b30 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializedEvent.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class InitializedEvent { public static readonly - NotificationType Type = - NotificationType.Create("initialized"); + NotificationType Type = + NotificationType.Create("initialized"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs index 428addacb..0044855c4 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/OutputEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class OutputEvent { public static readonly - NotificationType Type = - NotificationType.Create("output"); + NotificationType Type = + NotificationType.Create("output"); } public class OutputEventBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs index 7bcfd37a2..5b32d4a84 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StartedEvent.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StartedEvent { public static readonly - NotificationType Type = - NotificationType.Create("started"); + NotificationType Type = + NotificationType.Create("started"); } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs index 6a799eb5f..a3c2a7921 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/StoppedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class StoppedEvent { public static readonly - NotificationType Type = - NotificationType.Create("stopped"); + NotificationType Type = + NotificationType.Create("stopped"); } public class StoppedEventBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs index 04962f364..514d0bcae 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter public class TerminatedEvent { public static readonly - NotificationType Type = - NotificationType.Create("terminated"); + NotificationType Type = + NotificationType.Create("terminated"); public bool Restart { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs index e2b9fa135..a4228ee19 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Configuration.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class DidChangeConfigurationNotification { public static readonly - NotificationType> Type = - NotificationType>.Create("workspace/didChangeConfiguration"); + NotificationType, object> Type = + NotificationType, object>.Create("workspace/didChangeConfiguration"); } public class DidChangeConfigurationParams diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs index 53795be15..e5e46d45f 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs @@ -15,8 +15,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class PublishDiagnosticsNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/publishDiagnostics"); + NotificationType Type = + NotificationType.Create("textDocument/publishDiagnostics"); /// /// Gets or sets the URI for which diagnostic information is reported. diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs index cc7d273a8..04d15c0e9 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ExtensionCommandAddedNotification { public static readonly - NotificationType Type = - NotificationType.Create("powerShell/extensionCommandAdded"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandAdded"); public string Name { get; set; } @@ -21,8 +21,8 @@ public static readonly public class ExtensionCommandUpdatedNotification { public static readonly - NotificationType Type = - NotificationType.Create("powerShell/extensionCommandUpdated"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandUpdated"); public string Name { get; set; } } @@ -30,8 +30,8 @@ public static readonly public class ExtensionCommandRemovedNotification { public static readonly - NotificationType Type = - NotificationType.Create("powerShell/extensionCommandRemoved"); + NotificationType Type = + NotificationType.Create("powerShell/extensionCommandRemoved"); public string Name { get; set; } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs index bf87c0aa9..3f2448097 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/RunspaceChanged.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class RunspaceChangedEvent { public static readonly - NotificationType Type = - NotificationType.Create("powerShell/runspaceChanged"); + NotificationType Type = + NotificationType.Create("powerShell/runspaceChanged"); } public class RunspaceDetails diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs index 2c35f33f8..f5fffce1c 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs @@ -25,8 +25,8 @@ public static readonly public class ExitNotification { public static readonly - NotificationType Type = - NotificationType.Create("exit"); + NotificationType Type = + NotificationType.Create("exit"); } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index b91b244f5..ba5fff17a 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -98,8 +98,8 @@ public class TextDocumentPositionParams public class DidOpenTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didOpen"); + NotificationType Type = + NotificationType.Create("textDocument/didOpen"); } /// @@ -116,8 +116,8 @@ public class DidOpenTextDocumentParams public class DidCloseTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didClose"); + NotificationType Type = + NotificationType.Create("textDocument/didClose"); } /// @@ -134,8 +134,8 @@ public class DidCloseTextDocumentParams public class DidSaveTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didSave"); + NotificationType Type = + NotificationType.Create("textDocument/didSave"); } /// @@ -158,8 +158,8 @@ public class DidSaveTextDocumentParams public class DidChangeTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didChange"); + NotificationType Type = + NotificationType.Create("textDocument/didChange"); } /// diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs index 8843ed3e5..7af362f4e 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventContext.cs @@ -21,8 +21,8 @@ public EventContext(MessageWriter messageWriter) this.messageWriter = messageWriter; } - public async Task SendEvent( - NotificationType eventType, + public async Task SendEvent( + NotificationType eventType, TParams eventParams) { await this.messageWriter.WriteEvent( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs index b43507a03..58e2f1f59 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/EventType.cs @@ -9,7 +9,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol /// Defines an event type with a particular method name. /// /// The parameter type for this event. - public class NotificationType : AbstractMessageType + public class NotificationType : AbstractMessageType { private NotificationType(string method) : base(method, 1) { @@ -21,9 +21,9 @@ private NotificationType(string method) : base(method, 1) /// /// The method name of the event. /// A new EventType instance for the defined type. - public static NotificationType Create(string method) + public static NotificationType Create(string method) { - return new NotificationType(method); + return new NotificationType(method); } } } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs index 4e9ffab2b..962c05c2a 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs @@ -9,8 +9,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { internal interface IMessageSender { - Task SendEvent( - NotificationType eventType, + Task SendEvent( + NotificationType eventType, TParams eventParams); Task SendRequest( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index d112a669e..fcf771cf9 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -133,8 +133,8 @@ public void SetRequestHandler( }); } - public void SetEventHandler( - NotificationType eventType, + public void SetEventHandler( + NotificationType eventType, Func eventHandler) { this.SetEventHandler( @@ -143,8 +143,8 @@ public void SetEventHandler( false); } - public void SetEventHandler( - NotificationType eventType, + public void SetEventHandler( + NotificationType eventType, Func eventHandler, bool overrideExisting) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index 326d4fbd4..ba0e8450d 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -122,7 +122,7 @@ await this.WriteMessage( contentObject)); } - public async Task WriteEvent(NotificationType eventType, TParams eventParams) + public async Task WriteEvent(NotificationType eventType, TParams eventParams) { // Allow null content JToken contentObject = diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index 4802bc9ab..d996b4007 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -214,8 +214,8 @@ await this.protocolChannel.MessageWriter.WriteRequestThe type of event being sent. /// The event parameters being sent. /// A Task that tracks completion of the send operation. - public Task SendEvent( - NotificationType eventType, + public Task SendEvent( + NotificationType eventType, TParams eventParams) { // Some requests may still be in the SynchronizationContext queue @@ -284,8 +284,8 @@ public void SetRequestHandler( requestHandler); } - public void SetEventHandler( - NotificationType eventType, + public void SetEventHandler( + NotificationType eventType, Func eventHandler) { this.MessageDispatcher.SetEventHandler( @@ -294,8 +294,8 @@ public void SetEventHandler( false); } - public void SetEventHandler( - NotificationType eventType, + public void SetEventHandler( + NotificationType eventType, Func eventHandler, bool overrideExisting) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs index 5ec053f14..55c473f01 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestContext.cs @@ -27,7 +27,7 @@ await this.messageWriter.WriteResponse( requestMessage.Id); } - public async Task SendEvent(NotificationType eventType, TParams eventParams) + public async Task SendEvent(NotificationType eventType, TParams eventParams) { await this.messageWriter.WriteEvent( eventType, diff --git a/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs b/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs index f82c316f3..cdc059e43 100644 --- a/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs +++ b/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs @@ -926,7 +926,7 @@ async void powerShellContext_RunspaceChanged(object sender, RunspaceChangedEvent // Exited the session while the debugger is stopped, // send a ContinuedEvent so that the client changes the // UI to appear to be running again - await this.SendEvent( + await this.SendEvent( ContinuedEvent.Type, new ContinuedEvent { diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index f39a3c84d..64d340225 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1249,7 +1249,7 @@ private Task RunScriptDiagnostics( private Task RunScriptDiagnostics( ScriptFile[] filesToAnalyze, EditorSession editorSession, - Func, PublishDiagnosticsNotification, Task> eventSender) + Func, PublishDiagnosticsNotification, Task> eventSender) { // If there's an existing task, attempt to cancel it try @@ -1327,7 +1327,7 @@ private static async Task DelayThenInvokeDiagnostics( bool isScriptAnalysisEnabled, Dictionary> correctionIndex, EditorSession editorSession, - Func, PublishDiagnosticsNotification, Task> eventSender, + Func, PublishDiagnosticsNotification, Task> eventSender, CancellationToken cancellationToken) { // First of all, wait for the desired delay period before @@ -1403,7 +1403,7 @@ private static async Task PublishScriptDiagnostics( ScriptFile scriptFile, ScriptFileMarker[] markers, Dictionary> correctionIndex, - Func, PublishDiagnosticsNotification, Task> eventSender) + Func, PublishDiagnosticsNotification, Task> eventSender) { List diagnostics = new List(); diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index 34315c629..0c1234795 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -141,7 +141,7 @@ protected Task SendRequest(NotificationType eventType, TParams eventParams) + protected Task SendEvent(NotificationType eventType, TParams eventParams) { return this.protocolClient.SendEvent( @@ -149,7 +149,7 @@ protected Task SendEvent(NotificationType eventType, TParams e eventParams); } - protected void QueueEventsForType(NotificationType eventType) + protected void QueueEventsForType(NotificationType eventType) { var eventQueue = this.eventQueuePerType.AddOrUpdate( @@ -165,8 +165,8 @@ protected void QueueEventsForType(NotificationType eventType) }); } - protected async Task WaitForEvent( - NotificationType eventType, + protected async Task WaitForEvent( + NotificationType eventType, int timeoutMilliseconds = 5000) { Task eventTask = null; diff --git a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs index 7cb1cf886..8ade77002 100644 --- a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs +++ b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs @@ -99,8 +99,8 @@ internal class TestMessageSender : IMessageSender { public List OutputEvents { get; } = new List(); - public Task SendEvent( - NotificationType eventType, + public Task SendEvent( + NotificationType eventType, TParams eventParams) { OutputEventBody outputEvent = eventParams as OutputEventBody; From 663ee2c0daaedb3c0e99d9699fd1acdc6d639f14 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 18:00:47 -0700 Subject: [PATCH 31/54] Change TRegistrationOption to TRegistrationOptions --- .../MessageProtocol/IMessageSender.cs | 4 +-- .../MessageProtocol/MessageDispatcher.cs | 8 +++--- .../MessageProtocol/MessageWriter.cs | 4 +-- .../MessageProtocol/ProtocolEndpoint.cs | 26 +++++++++---------- .../MessageProtocol/RequestType.cs | 12 ++++----- .../MessageProtocol/RequestType0.cs | 6 ++--- .../WebSocketChannelTest.cs | 2 +- .../ServerTestsBase.cs | 4 +-- .../Server/OutputDebouncerTests.cs | 4 +-- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs index 962c05c2a..5b4da2452 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/IMessageSender.cs @@ -13,8 +13,8 @@ Task SendEvent( NotificationType eventType, TParams eventParams); - Task SendRequest( - RequestType requestType, + Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse); } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs index fcf771cf9..995d124d7 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs @@ -92,8 +92,8 @@ public void Stop() } } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler) { this.SetRequestHandler( @@ -102,8 +102,8 @@ public void SetRequestHandler( false); } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler, bool overrideExisting) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs index ba0e8450d..b1936d40e 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageWriter.cs @@ -89,8 +89,8 @@ public async Task WriteMessage(Message messageToWrite) } } - public async Task WriteRequest( - RequestType requestType, + public async Task WriteRequest( + RequestType requestType, TParams requestParams, int requestId) { diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs index d996b4007..9ef13c828 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs @@ -132,11 +132,11 @@ public async Task Stop() #region Message Sending - public Task SendRequest( - RequestType0 requestType0) + public Task SendRequest( + RequestType0 requestType0) { return this.SendRequest( - RequestType.ConvertToRequestType(requestType0), + RequestType.ConvertToRequestType(requestType0), null); } @@ -149,15 +149,15 @@ public Task SendRequest( /// /// /// - public Task SendRequest( - RequestType requestType, + public Task SendRequest( + RequestType requestType, TParams requestParams) { return this.SendRequest(requestType, requestParams, true); } - public async Task SendRequest( - RequestType requestType, + public async Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse) { @@ -186,7 +186,7 @@ public async Task SendRequest( + await this.protocolChannel.MessageWriter.WriteRequest( requestType, requestParams, this.currentMessageId); @@ -263,20 +263,20 @@ await this.protocolChannel.MessageWriter.WriteEvent( #region Message Handling - public void SetRequestHandler( - RequestType0 requestType0, + public void SetRequestHandler( + RequestType0 requestType0, Func, Task> requestHandler) { SetRequestHandler( - RequestType.ConvertToRequestType(requestType0), + RequestType.ConvertToRequestType(requestType0), (param1, requestContext) => { return requestHandler(requestContext); }); } - public void SetRequestHandler( - RequestType requestType, + public void SetRequestHandler( + RequestType requestType, Func, Task> requestHandler) { this.MessageDispatcher.SetRequestHandler( diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs index 9b0472087..d7c5a6e8e 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs @@ -8,27 +8,27 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { [DebuggerDisplay("RequestType Method = {Method}")] - public class RequestType : AbstractMessageType + public class RequestType : AbstractMessageType { private RequestType(string method) : base(method, 1) { } - public static RequestType ConvertToRequestType( - RequestType0 requestType0) + public static RequestType ConvertToRequestType( + RequestType0 requestType0) { - return RequestType.Create(requestType0.Method); + return RequestType.Create(requestType0.Method); } - public static RequestType Create(string method) + public static RequestType Create(string method) { if (method == null) { throw new System.ArgumentNullException(nameof(method)); } - return new RequestType(method); + return new RequestType(method); } } } diff --git a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs index 90666b927..e8fc8da1c 100644 --- a/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs +++ b/src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType0.cs @@ -8,15 +8,15 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol { [DebuggerDisplay("RequestType0 Method = {Method}")] - public class RequestType0 : AbstractMessageType + public class RequestType0 : AbstractMessageType { public RequestType0(string method) : base(method, 0) { } - public static RequestType0 Create(string method) + public static RequestType0 Create(string method) { - return new RequestType0(method); + return new RequestType0(method); } } } diff --git a/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs b/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs index f95a56f94..bfc74168d 100644 --- a/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs +++ b/test/PowerShellEditorServices.Test.Channel.WebSocket/WebSocketChannelTest.cs @@ -50,7 +50,7 @@ await this.SendRequest( } private Task SendRequest( - RequestType requestType, + RequestType requestType, TParams requestParams) { return diff --git a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs index 0c1234795..e65983b1a 100644 --- a/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs +++ b/test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs @@ -131,8 +131,8 @@ protected void KillService() } } - protected Task SendRequest( - RequestType requestType, + protected Task SendRequest( + RequestType requestType, TParams requestParams) { return diff --git a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs index 8ade77002..bd15d1a75 100644 --- a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs +++ b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs @@ -113,8 +113,8 @@ public Task SendEvent( return Task.FromResult(true); } - public Task SendRequest( - RequestType requestType, + public Task SendRequest( + RequestType requestType, TParams requestParams, bool waitForResponse) { // Legitimately not implemented for these tests. From 86afcec37d5e8cee961c7d7973de619a11caf187 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Wed, 26 Apr 2017 18:34:27 -0700 Subject: [PATCH 32/54] Fix completion request parameters --- .../LanguageServer/Completion.cs | 4 +-- .../Server/LanguageServer.cs | 8 +++--- .../LanguageServerTests.cs | 28 +++++++++++++------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs index 4b2cc8976..db83143b2 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CompletionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/completion"); + RequestType Type = + RequestType.Create("textDocument/completion"); } public class CompletionResolveRequest diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 64d340225..a2927010b 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -708,15 +708,15 @@ await editorSession.LanguageService.FindReferencesOfSymbol( } protected async Task HandleCompletionRequest( - TextDocumentPosition textDocumentPosition, + TextDocumentPositionParams textDocumentPositionParams, RequestContext requestContext) { - int cursorLine = textDocumentPosition.Position.Line + 1; - int cursorColumn = textDocumentPosition.Position.Character + 1; + int cursorLine = textDocumentPositionParams.Position.Line + 1; + int cursorColumn = textDocumentPositionParams.Position.Character + 1; ScriptFile scriptFile = editorSession.Workspace.GetFile( - textDocumentPosition.Uri); + textDocumentPositionParams.TextDocument.Uri); CompletionResults completionResults = await editorSession.LanguageService.GetCompletionsInFile( diff --git a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs index 88f8cdf30..7ca874794 100644 --- a/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs +++ b/test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs @@ -122,9 +122,12 @@ public async Task ServiceCompletesFunctionName() CompletionItem[] completions = await this.SendRequest( CompletionRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\CompleteFunctionName.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\CompleteFunctionName.ps1", + }, Position = new Position { Line = 4, @@ -146,9 +149,12 @@ public async Task CompletesDetailOnVariableSuggestion() CompletionItem[] completions = await this.SendRequest( CompletionRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\CompleteFunctionName.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\CompleteFunctionName.ps1" + }, Position = new Position { Line = 3, @@ -172,9 +178,12 @@ public async Task CompletesDetailOnVariableDocSuggestion() await this.SendRequest( CompletionRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\CompleteFunctionName.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\CompleteFunctionName.ps1" + }, Position = new Position { Line = 7, @@ -212,9 +221,12 @@ public async Task CompletesDetailOnCommandSuggestion() CompletionItem[] completions = await this.SendRequest( CompletionRequest.Type, - new TextDocumentPosition + new TextDocumentPositionParams { - Uri = "TestFiles\\CompleteFunctionName.ps1", + TextDocument = new TextDocumentIdentifier + { + Uri = "TestFiles\\CompleteFunctionName.ps1" + }, Position = new Position { Line = 5, From 206da143bc4574beb3d4df6dc6317c21b0eed424 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 14:20:29 -0700 Subject: [PATCH 33/54] Add WorkspaceClientCapabilities type --- .../WorkspaceClientCapabilities.cs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs new file mode 100644 index 000000000..5f3a89a66 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs @@ -0,0 +1,91 @@ +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + public class WorkspaceClientCapabilities + { + /// + /// The client supports applying batch edits to the workspace by + /// by supporting the request `workspace/applyEdit' + /// /// + bool ApplyEdit { get; set; } + + /// + /// Capabilities specific to `WorkspaceEdit`. + /// + public WorkspaceEditCapabilities WorkspaceEdit { get; set; } + + /// + /// Capabilities specific to the `workspace/didChangeConfiguration` notification. + /// + public DidChangeConfigurationCapabilities DidChangeConfiguration { get; set; } + + /// + /// Capabilities specific to the `workspace/didChangeWatchedFiles` notification. + /// + public DidChangeWatchedFilesCapabilities DidChangeWatchedFiles { get; set; } + + /// + /// Capabilities specific to the `workspace/symbol` request. + /// + public SymbolCapabilities Symbol { get; set; } + + /// + /// Capabilities specific to the `workspace/executeCommand` request. + /// + public ExecuteCommandCapabilities ExecuteCommand { get; set; } + } + + /// + /// Class to represent capabilities specific to `WorkspaceEdit`. + /// + public class WorkspaceEditCapabilities + { + /// + /// The client supports versioned document changes in `WorkspaceEdit` + /// + bool DocumentChanges { get; set; } + } + + /// + /// Class to represent capabilities specific to the `workspace/didChangeConfiguration` notification. + /// + public class DidChangeConfigurationCapabilities + { + /// + /// Did change configuration supports dynamic registration. + /// + bool DynamicRegistration { get; set; } + } + + /// + /// Class to represent capabilities specific to the `workspace/didChangeWatchedFiles` notification. + /// + public class DidChangeWatchedFilesCapabilities + { + /// + /// Did change watched files notification supports dynamic registration. + /// + bool DynamicRegistration { get; set; } + } + + /// + /// Class to represent capabilities specific to the `workspace/symbol` request. + /// + public class SymbolCapabilities + { + /// + /// Symbol request supports dynamic registration. + /// + bool DynamicRegistration { get; set; } + } + + /// + /// Class to represent capabilities specific to the `workspace/executeCommand` request. + /// + public class ExecuteCommandCapabilities + { + /// + /// Execute command supports dynamic registration. + /// + bool DynamicRegistration { get; set; } + } +} From 60f1aa16fe969f9675de09e54f6689341277fb2d Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 15:07:44 -0700 Subject: [PATCH 34/54] Add DynamicRegistrationCapability type --- .../LanguageServer/DynamicRegistrationCapability.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs new file mode 100644 index 000000000..d281a6cfb --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs @@ -0,0 +1,13 @@ +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + /// + /// Class to represent if a capability supports dynamic registration. + /// + public class DynamicRegistrationCapability + { + /// + /// Whether the capability supports dynamic registration. + /// + public bool DynamicRegistration { get; set; } + } +} From cd517626daa223c72c2072fd18dbc7771f2b3f7f Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 15:09:16 -0700 Subject: [PATCH 35/54] Update WorkspaceClientCapabilities type --- .../WorkspaceClientCapabilities.cs | 52 ++----------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs index 5f3a89a66..fef6ca79f 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs @@ -16,22 +16,22 @@ public class WorkspaceClientCapabilities /// /// Capabilities specific to the `workspace/didChangeConfiguration` notification. /// - public DidChangeConfigurationCapabilities DidChangeConfiguration { get; set; } + public DynamicRegistrationCapability DidChangeConfiguration { get; set; } /// /// Capabilities specific to the `workspace/didChangeWatchedFiles` notification. /// - public DidChangeWatchedFilesCapabilities DidChangeWatchedFiles { get; set; } + public DynamicRegistrationCapability DidChangeWatchedFiles { get; set; } /// /// Capabilities specific to the `workspace/symbol` request. /// - public SymbolCapabilities Symbol { get; set; } + public DynamicRegistrationCapability Symbol { get; set; } /// /// Capabilities specific to the `workspace/executeCommand` request. /// - public ExecuteCommandCapabilities ExecuteCommand { get; set; } + public DynamicRegistrationCapability ExecuteCommand { get; set; } } /// @@ -44,48 +44,4 @@ public class WorkspaceEditCapabilities /// bool DocumentChanges { get; set; } } - - /// - /// Class to represent capabilities specific to the `workspace/didChangeConfiguration` notification. - /// - public class DidChangeConfigurationCapabilities - { - /// - /// Did change configuration supports dynamic registration. - /// - bool DynamicRegistration { get; set; } - } - - /// - /// Class to represent capabilities specific to the `workspace/didChangeWatchedFiles` notification. - /// - public class DidChangeWatchedFilesCapabilities - { - /// - /// Did change watched files notification supports dynamic registration. - /// - bool DynamicRegistration { get; set; } - } - - /// - /// Class to represent capabilities specific to the `workspace/symbol` request. - /// - public class SymbolCapabilities - { - /// - /// Symbol request supports dynamic registration. - /// - bool DynamicRegistration { get; set; } - } - - /// - /// Class to represent capabilities specific to the `workspace/executeCommand` request. - /// - public class ExecuteCommandCapabilities - { - /// - /// Execute command supports dynamic registration. - /// - bool DynamicRegistration { get; set; } - } } From 7919ed8a086469a4f9971311aba351d0f30cbade Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 15:11:00 -0700 Subject: [PATCH 36/54] Add TextDocumentClientCapabilities type --- .../TextDocumentClientCapabilities.cs | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs new file mode 100644 index 000000000..4e46b2891 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs @@ -0,0 +1,130 @@ +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + public class TextDocumentClientCapabilities + { + /// + /// Synchronization capabilities the client supports. + /// + public SynchronizationCapabilities Synchronization { get; set; } + + /// + /// Capabilities specific to `textDocument/completion`. + /// + public CompletionCapabilities Completion { get; set; } + + /// + /// Capabilities specific to the `textDocument/hover`. + /// + public DynamicRegistrationCapability Hover { get; set; } + + /// + /// Capabilities specific to the `textDocument/signatureHelp`. + /// + public DynamicRegistrationCapability SignatureHelp { get; set; } + + /// + /// Capabilities specific to the `textDocument/references`. + /// + public DynamicRegistrationCapability References { get; set; } + + /// + /// Capabilities specific to the `textDocument/documentHighlight`. + /// + public DynamicRegistrationCapability DocumentHighlight { get; set; } + + /// + /// Capabilities specific to the `textDocument/documentSymbol`. + /// + public DynamicRegistrationCapability DocumentSymbol { get; set; } + + /// + /// Capabilities specific to the `textDocument/formatting`. + /// + public DynamicRegistrationCapability Formatting { get; set; } + + /// + /// Capabilities specific to the `textDocument/rangeFormatting`. + /// + public DynamicRegistrationCapability RangeFormatting { get; set; } + + /// + /// Capabilities specific to the `textDocument/onTypeFormatting`. + /// + public DynamicRegistrationCapability OnTypeFormatting { get; set; } + + /// + /// Capabilities specific to the `textDocument/definition`. + /// + public DynamicRegistrationCapability Definition { get; set; } + + /// + /// Capabilities specific to the `textDocument/codeAction`. + /// + public DynamicRegistrationCapability CodeAction { get; set; } + + /// + /// Capabilities specific to the `textDocument/codeLens`. + /// + public DynamicRegistrationCapability CodeLens { get; set; } + + /// + /// Capabilities specific to the `textDocument/documentLink`. + /// + public DynamicRegistrationCapability DocumentLink { get; set; } + + /// + /// Capabilities specific to the `textDocument/rename`. + /// + public DynamicRegistrationCapability Rename { get; set; } + } + + /// + /// Class to represent capabilities specific to `textDocument/completion`. + /// + public class CompletionCapabilities : DynamicRegistrationCapability + { + /// + /// The client supports the following `CompletionItem` specific capabilities. + /// + /// + CompletionItemCapabilities CompletionItem { get; set; } + } + + /// + /// Class to represent capabilities specific to `CompletionItem`. + /// + public class CompletionItemCapabilities + { + /// + /// Client supports snippets as insert text. + /// + /// A snippet can define tab stops and placeholders with `$1`, `$2` + /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to + /// the end of the snippet. Placeholders with equal identifiers are linked, + /// that is typing in one will update others too. + /// + bool SnippetSupport { get; set; } + } + + /// + /// Class to represent synchronization capabilities the client supports. + /// + public class SynchronizationCapabilities : DynamicRegistrationCapability + { + /// + /// The client supports sending will save notifications. + /// + bool WillSave { get; set; } + + /// + /// The client supports sending a will save request and waits for a response + /// providing text edits which will be applied to the document before it is save. + /// + bool WillSaveWaitUntil { get; set; } + + /// + /// The client supports did save notifications. + /// + bool DidSave { get; set; } + } +} From 1fb9ccf00bb6e6e98c9f33d5dae7f38de87f592f Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 15:11:35 -0700 Subject: [PATCH 37/54] Update ClientCapabilities type --- .../LanguageServer/ClientCapabilities.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ClientCapabilities.cs index 2bebdeb65..f66982c43 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ClientCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ClientCapabilities.cs @@ -18,6 +18,9 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer /// public class ClientCapabilities { + public WorkspaceClientCapabilities Workspace { get; set; } + public TextDocumentClientCapabilities TextDocument { get; set; } + public object Experimental { get; set; } } } From aa8db9ad912da6151d1daba71aa41b518c142335 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 16:06:05 -0700 Subject: [PATCH 38/54] Add InitializeParams type --- .../LanguageServer/Initialize.cs | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs index bef99a30e..147a5d6de 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs @@ -10,20 +10,53 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class InitializeRequest { public static readonly - RequestType Type = - RequestType.Create("initialize"); + RequestType Type = + RequestType.Create("initialize"); + } + public enum TraceType { + Off, + Messages, + Verbose + } + + public class InitializeParams { /// - /// Gets or sets the root path of the editor's open workspace. - /// If null it is assumed that a file was opened without having - /// a workspace open. + /// The process Id of the parent process that started the server + /// + public int ProcessId { get; set; } + + /// + /// The root path of the workspace. It is null if no folder is open. + /// + /// This property has been deprecated in favor of RootUri. /// public string RootPath { get; set; } /// - /// Gets or sets the capabilities provided by the client (editor). + /// The root uri of the workspace. It is null if not folder is open. If both + /// `RootUri` and `RootPath` are non-null, `RootUri` should be used. + /// + public string RootUri { get; set; } + + /// + /// The capabilities provided by the client. /// public ClientCapabilities Capabilities { get; set; } + + /// + /// User provided initialization options. + /// + /// This is defined as `any` type on the client side. + /// + public object InitializeOptions { get; set; } + + // TODO We need to verify if the deserializer will map the type defined in the client + // to an enum. + /// + /// The initial trace setting. If omitted trace is disabled. + /// + public TraceType Trace { get; set; } = TraceType.Off; } public class InitializeResult From c558ae2d7d93f4e3cbd176bcc3336b257ab93921 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 16:24:25 -0700 Subject: [PATCH 39/54] Update ServerCapabilities type --- .../LanguageServer/ServerCapabilities.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs index aeebb411d..26fec4ae1 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs @@ -26,6 +26,60 @@ public class ServerCapabilities public bool? WorkspaceSymbolProvider { get; set; } public bool? CodeActionProvider { get; set; } + + public bool? CodeLensProvider { get; set; } + + public bool? DocumentFormattingProvider { get; set; } + + public bool? DocumentRangeFormattingProvider { get; set; } + + public DocumentOnTypeFormattingOptions DocumentOnTypeFormattingProvider { get; set; } + + public bool? RenameProvider { get; set; } + + public DocumentLinkOptions DocumentLinkProvider { get; set; } + + public ExecuteCommandOptions ExecuteCommandProvider { get; set; } + + public object Experimental { get; set; } + } + + /// + /// Execute command options. + /// + public class ExecuteCommandOptions + { + /// + /// The commands to be executed on the server. + /// + public string[] Commands { get; set; } + } + + /// + /// Document link options. + /// + public class DocumentLinkOptions + { + /// + /// Document links have a resolve provider. + /// + public bool? ResolveProvider { get; set; } + } + + /// + /// Options that the server provides for OnTypeFormatting request. + /// + public class DocumentOnTypeFormattingOptions + { + /// + /// A character on which formatting should be triggered. + /// + public string FirstTriggerCharacter { get; set; } + + /// + /// More trigger characters. + /// + public string[] MoreTriggerCharacters { get; set; } } /// From cc6921df3f0382cbe1082b3d00076e523a08c088 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 16:41:45 -0700 Subject: [PATCH 40/54] Fix ClientCapabilities and related types --- .../LanguageServer/DynamicRegistrationCapability.cs | 2 +- .../LanguageServer/TextDocumentClientCapabilities.cs | 10 +++++----- .../LanguageServer/WorkspaceClientCapabilities.cs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs index d281a6cfb..64d2c35ce 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/DynamicRegistrationCapability.cs @@ -8,6 +8,6 @@ public class DynamicRegistrationCapability /// /// Whether the capability supports dynamic registration. /// - public bool DynamicRegistration { get; set; } + public bool? DynamicRegistration { get; set; } } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs index 4e46b2891..c620ad056 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocumentClientCapabilities.cs @@ -87,7 +87,7 @@ public class CompletionCapabilities : DynamicRegistrationCapability /// The client supports the following `CompletionItem` specific capabilities. /// /// - CompletionItemCapabilities CompletionItem { get; set; } + public CompletionItemCapabilities CompletionItem { get; set; } } /// @@ -103,7 +103,7 @@ public class CompletionItemCapabilities /// the end of the snippet. Placeholders with equal identifiers are linked, /// that is typing in one will update others too. /// - bool SnippetSupport { get; set; } + public bool? SnippetSupport { get; set; } } /// @@ -114,17 +114,17 @@ public class SynchronizationCapabilities : DynamicRegistrationCapability /// /// The client supports sending will save notifications. /// - bool WillSave { get; set; } + public bool? WillSave { get; set; } /// /// The client supports sending a will save request and waits for a response /// providing text edits which will be applied to the document before it is save. /// - bool WillSaveWaitUntil { get; set; } + public bool? WillSaveWaitUntil { get; set; } /// /// The client supports did save notifications. /// - bool DidSave { get; set; } + public bool? DidSave { get; set; } } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs index fef6ca79f..3e781a217 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceClientCapabilities.cs @@ -6,7 +6,7 @@ public class WorkspaceClientCapabilities /// The client supports applying batch edits to the workspace by /// by supporting the request `workspace/applyEdit' /// /// - bool ApplyEdit { get; set; } + bool? ApplyEdit { get; set; } /// /// Capabilities specific to `WorkspaceEdit`. @@ -42,6 +42,6 @@ public class WorkspaceEditCapabilities /// /// The client supports versioned document changes in `WorkspaceEdit` /// - bool DocumentChanges { get; set; } + bool? DocumentChanges { get; set; } } } From fcfefe8d5fdf0a627c20a48adaae6a357b2b19b6 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 27 Apr 2017 16:42:18 -0700 Subject: [PATCH 41/54] Update initialize request --- .../Client/LanguageServiceClient.cs | 4 ++-- .../LanguageServer/Initialize.cs | 4 ++-- .../Server/LanguageServer.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs index c218b4ef5..63fde920f 100644 --- a/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs +++ b/src/PowerShellEditorServices.Protocol/Client/LanguageServiceClient.cs @@ -34,7 +34,7 @@ protected override Task Initialize() protected override Task OnConnect() { // Send the 'initialize' request and wait for the response - var initializeRequest = new InitializeRequest + var initializeParams = new InitializeParams { RootPath = "", Capabilities = new ClientCapabilities() @@ -42,7 +42,7 @@ protected override Task OnConnect() return this.SendRequest( InitializeRequest.Type, - initializeRequest); + initializeParams); } #region Events diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs index 147a5d6de..be73b74a0 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Initialize.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class InitializeRequest { public static readonly - RequestType Type = - RequestType.Create("initialize"); + RequestType Type = + RequestType.Create("initialize"); } public enum TraceType { diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index a2927010b..ede85beba 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -174,7 +174,7 @@ protected override async Task Shutdown() #region Built-in Message Handlers protected async Task HandleInitializeRequest( - InitializeRequest initializeParams, + InitializeParams initializeParams, RequestContext requestContext) { // Grab the workspace path from the parameters From 61c2e0dc1f47bda8fa14526afc8f839736639114 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:35:44 -0700 Subject: [PATCH 42/54] Add registration options for didOpen notification --- .../LanguageServer/TextDocument.cs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index ba5fff17a..8e97dbbe3 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -98,8 +98,8 @@ public class TextDocumentPositionParams public class DidOpenTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didOpen"); + NotificationType Type = + NotificationType.Create("textDocument/didOpen"); } /// @@ -113,6 +113,39 @@ public class DidOpenTextDocumentParams public TextDocumentItem TextDocument { get; set; } } + /// + /// General text document registration options. + /// + public class TextDocumentRegistrationOptions { + /// + /// A document selector to identify the scope of the registration. If set to null the document + /// selector provided on the client side will be used. + /// + public DocumentFilter[] DocumentSelector { get; set; } + } + + /// + /// A document filter denotes a document by different properties like the language, the scheme + /// of its resource, or a glob-pattern that is applied to the path. + /// + public class DocumentFilter + { + /// + /// A language id, like `powershell` + /// + public string Language { get; set; } + + /// + /// A Uri, like `file` or `untitled` + /// + public string Scheme { get; set; } + + /// + /// A glob pattern, like `*.{ps1,psd1}` + /// + public string Pattern { get; set; } + } + public class DidCloseTextDocumentNotification { public static readonly From e372ac0fecd52bdb90474492ec108f1f3a8923de Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:40:14 -0700 Subject: [PATCH 43/54] Add registration options for didClose notification --- .../LanguageServer/TextDocument.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 8e97dbbe3..750db5298 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -149,8 +149,8 @@ public class DocumentFilter public class DidCloseTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didClose"); + NotificationType Type = + NotificationType.Create("textDocument/didClose"); } /// From b329d0e6c348b5a1d02762e44176a92d86c71bfe Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:47:53 -0700 Subject: [PATCH 44/54] Add registration options for didSave notification --- .../LanguageServer/TextDocument.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index 750db5298..ebbe34d50 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -167,8 +167,28 @@ public class DidCloseTextDocumentParams public class DidSaveTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didSave"); + NotificationType Type = + NotificationType.Create("textDocument/didSave"); + } + + /// + /// Save options. + /// + public class SaveOptions { + /// + /// The client is supposed to include the content on save. + /// + public bool? IncludeText { get; set; } + } + + public class TextDocumentSaveRegistrationOptions : TextDocumentRegistrationOptions + { + // We cannot inherit from two base classes (SaveOptions and TextDocumentRegistrationOptions) + // simultaneously, hence we repeat this IncludeText flag here. + /// + /// The client is supposed to include the content on save. + /// + public bool? IncludeText { get; set; } } /// From 6640f13aac33abcfdac7ac3622e42bca260c5661 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:51:37 -0700 Subject: [PATCH 45/54] Add registration options for didChange notification --- .../LanguageServer/TextDocument.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index ebbe34d50..f438569de 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -211,8 +211,19 @@ public class DidSaveTextDocumentParams public class DidChangeTextDocumentNotification { public static readonly - NotificationType Type = - NotificationType.Create("textDocument/didChange"); + NotificationType Type = + NotificationType.Create("textDocument/didChange"); + } + + /// + /// Describe options to be used when registered for text document change events. + /// + public class TextDocumentChangeRegistrationOptions : TextDocumentRegistrationOptions + { + /// + /// How documents are synced to the server. + /// + public TextDocumentSyncKind SyncKind { get; set; } } /// From 9345b6172270875f69aaf1b3f233a5ea786be4fb Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:54:57 -0700 Subject: [PATCH 46/54] Add registration options for definition request --- .../LanguageServer/Definition.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs index 52f6aba80..336259ba9 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Definition.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class DefinitionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/definition"); + RequestType Type = + RequestType.Create("textDocument/definition"); } } From 2677607d10f3eb8752ec13f76204eb0508fc0223 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 14:56:40 -0700 Subject: [PATCH 47/54] Add registration options for reference request --- .../LanguageServer/References.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs index e08b4c9c3..992464140 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/References.cs @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class ReferencesRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/references"); + RequestType Type = + RequestType.Create("textDocument/references"); } public class ReferencesParams : TextDocumentPosition From 339014a8a01b57a9c4b29ccb296d96108cbc132a Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:09:26 -0700 Subject: [PATCH 48/54] Add registration options for completion request --- .../LanguageServer/Completion.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs index db83143b2..b26691229 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CompletionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/completion"); + RequestType Type = + RequestType.Create("textDocument/completion"); } public class CompletionResolveRequest @@ -22,6 +22,19 @@ public static readonly RequestType.Create("completionItem/resolve"); } + /// + /// Completion registration options. + /// + public class CompletionRegistrationOptions : TextDocumentRegistrationOptions + { + // We duplicate the properties of completionOptions class here because + // we cannot derive from two classes. One way to get around this situation + // is to use define CompletionOptions as an interface instead of a class. + public bool? ResolveProvider { get; set; } + + public string[] TriggerCharacters { get; set; } + } + public enum CompletionItemKind { Text = 1, From 0402de1a28b4bda20adace343861ac0c134dca4d Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:13:08 -0700 Subject: [PATCH 49/54] Add registration options for signaturehelp request --- .../LanguageServer/SignatureHelp.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs index d793d63b6..e24fa6358 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/SignatureHelp.cs @@ -10,8 +10,16 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class SignatureHelpRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/signatureHelp"); + RequestType Type = + RequestType.Create("textDocument/signatureHelp"); + } + + public class SignatureHelpRegistrationOptions : TextDocumentRegistrationOptions + { + // We duplicate the properties of SignatureHelpOptions class here because + // we cannot derive from two classes. One way to get around this situation + // is to use define SignatureHelpOptions as an interface instead of a class. + public string[] TriggerCharacters { get; set; } } public class ParameterInformation From ed9912290c3410a4e048ffd4c4fbe14333689832 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:15:44 -0700 Subject: [PATCH 50/54] Add registration options for documentHighlight request --- .../LanguageServer/DocumentHighlight.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs index da1bdb267..cf8196f18 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/DocumentHighlight.cs @@ -24,8 +24,8 @@ public class DocumentHighlight public class DocumentHighlightRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentHighlight"); + RequestType Type = + RequestType.Create("textDocument/documentHighlight"); } } From 1f41fbc5cd29e289304fc6c2a19817a8bbd1fa25 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:19:52 -0700 Subject: [PATCH 51/54] Add registration options for hover request --- src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs index f46d7fe29..5a036bd7b 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Hover.cs @@ -29,8 +29,8 @@ public class Hover public class HoverRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/hover"); + RequestType Type = + RequestType.Create("textDocument/hover"); } } From 4e3c159fb649ce33d8d9c788daf8ddcf948f8784 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:21:18 -0700 Subject: [PATCH 52/54] Add registration options for documentSymbol request --- .../LanguageServer/WorkspaceSymbols.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs index 4eb790235..97e990345 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/WorkspaceSymbols.cs @@ -43,8 +43,8 @@ public class SymbolInformation public class DocumentSymbolRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/documentSymbol"); + RequestType Type = + RequestType.Create("textDocument/documentSymbol"); } /// From 1439bc4d4da246093635a28e20fe5d8cc7e402c9 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:23:08 -0700 Subject: [PATCH 53/54] Add registration options for codeAction request --- .../LanguageServer/CodeAction.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs index 31b52d996..a382d8dcf 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs @@ -6,8 +6,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer public class CodeActionRequest { public static readonly - RequestType Type = - RequestType.Create("textDocument/codeAction"); + RequestType Type = + RequestType.Create("textDocument/codeAction"); } /// From 2f61e26fa3efdc498ca1a403d29f59e8f3d31445 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Sat, 29 Apr 2017 15:32:07 -0700 Subject: [PATCH 54/54] Capitalize property names and other minor changes --- .../LanguageServer/Completion.cs | 12 ++++++++---- .../LanguageServer/TextDocument.cs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs index b26691229..38fb9e431 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs @@ -94,7 +94,7 @@ public class CompletionItem public TextEdit[] AdditionalTextEdits { get; set; } - public Command Command { get; set; } + public CommandType Command { get; set; } /// /// Gets or sets a custom data field that allows the server to mark @@ -109,8 +109,12 @@ public class CompletionItem /// Represents a reference to a command. Provides a title which will be used to /// represent a command in the UI and, optionally, an array of arguments which /// will be passed to the command handler function when invoked. + /// + /// The name of the corresponding type in vscode-languageserver-node is Command + /// but since .net does not allow a property name (Command) and its enclosing + /// type name to be the same we change its name to CommandType. /// - public class Command + public class CommandType { /// /// Title of the command. @@ -121,12 +125,12 @@ public class Command /// /// The identifier of the actual command handler. /// - public string command { get; set; } + public string Command { get; set; } /// /// Arguments that the command handler should be invoked with. /// - public object[] arguments { get; set; } + public object[] Arguments { get; set; } } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs index f438569de..8920ef1c4 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs @@ -197,7 +197,7 @@ public class TextDocumentSaveRegistrationOptions : TextDocumentRegistrationOptio public class DidSaveTextDocumentParams { /// - /// The document that was closed. + /// The document that was saved. /// public VersionedTextDocumentIdentifier TextDocument { get; set; }