Skip to content

Commit 2fb82ef

Browse files
authored
Merge pull request #706 from PowerShell/kapilmb/lsp-3
Upgrade language server protocol to v3.2.0
2 parents 7821670 + b8844d1 commit 2fb82ef

14 files changed

+72
-63
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"onCommand:PowerShell.PickPSHostProcess"
3434
],
3535
"dependencies": {
36-
"vscode-languageclient": "1.3.1"
36+
"vscode-languageclient": "3.2.0"
3737
},
3838
"devDependencies": {
3939
"@types/node": "^6.0.40",

src/features/CodeActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*--------------------------------------------------------*/
44

55
import vscode = require('vscode');
6-
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
6+
import { LanguageClient } from 'vscode-languageclient';
77
import Window = vscode.window;
88
import { IFeature } from '../feature';
99

src/features/Console.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ import { showCheckboxQuickPick, CheckboxQuickPickItem } from '../controls/checkb
88
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
99

1010
export namespace EvaluateRequest {
11-
export const type: RequestType<EvaluateRequestArguments, void, void> =
12-
{ get method() { return 'evaluate'; } };
11+
export const type = new RequestType<EvaluateRequestArguments, void, void, void>('evaluate');
1312
}
1413

1514
export interface EvaluateRequestArguments {
1615
expression: string;
1716
}
1817

1918
export namespace OutputNotification {
20-
export const type: NotificationType<OutputNotificationBody> =
21-
{ get method() { return 'output'; } };
19+
export const type = new NotificationType<OutputNotificationBody, void>('output');
2220
}
2321

2422
export interface OutputNotificationBody {
@@ -27,13 +25,13 @@ export interface OutputNotificationBody {
2725
}
2826

2927
export namespace ShowChoicePromptRequest {
30-
export const type: RequestType<ShowChoicePromptRequestArgs, ShowChoicePromptResponseBody, string> =
31-
{ get method() { return 'powerShell/showChoicePrompt'; } };
28+
export const type =
29+
new RequestType<ShowChoicePromptRequestArgs, ShowChoicePromptResponseBody, string, void>('powerShell/showChoicePrompt');
3230
}
3331

3432
export namespace ShowInputPromptRequest {
35-
export const type: RequestType<ShowInputPromptRequestArgs, ShowInputPromptResponseBody, string> =
36-
{ get method() { return 'powerShell/showInputPrompt'; } };
33+
export const type =
34+
new RequestType<ShowInputPromptRequestArgs, ShowInputPromptResponseBody, string, void>('powerShell/showInputPrompt');
3735
}
3836

3937
interface ChoiceDetails {

src/features/DebugSession.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ interface PSHostProcessInfo {
118118
}
119119

120120
namespace GetPSHostProcessesRequest {
121-
export const type: RequestType<any, GetPSHostProcessesResponseBody, string> =
122-
{ get method() { return 'powerShell/getPSHostProcesses'; } };
121+
export const type =
122+
new RequestType<any, GetPSHostProcessesResponseBody, string, void>('powerShell/getPSHostProcesses');
123123
}
124124

125125
interface GetPSHostProcessesResponseBody {

src/features/DocumentFormatter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import * as Utils from '../utils';
2525
import * as AnimatedStatusBar from '../controls/animatedStatusBar';
2626

2727
export namespace ScriptFileMarkersRequest {
28-
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/getScriptFileMarkers"; } };
28+
export const type = new RequestType<any, any, void, void>("powerShell/getScriptFileMarkers");
2929
}
3030

3131
export namespace ScriptRegionRequest {
32-
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/getScriptRegion"; } };
32+
export const type = new RequestType<any, any, void, void>("powerShell/getScriptRegion");
3333
}
3434

3535
interface ScriptRegionRequestParams {

src/features/ExpandAlias.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IFeature } from '../feature';
88
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
99

1010
export namespace ExpandAliasRequest {
11-
export const type: RequestType<string, any, void> = { get method() { return 'powerShell/expandAlias'; } };
11+
export const type = new RequestType<string, any, void, void>('powerShell/expandAlias');
1212
}
1313

1414
export class ExpandAliasFeature implements IFeature {

src/features/ExtensionCommands.ts

+33-22
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export interface ExtensionCommandQuickPickItem extends vscode.QuickPickItem {
1717
}
1818

1919
export namespace InvokeExtensionCommandRequest {
20-
export const type: RequestType<InvokeExtensionCommandRequestArguments, void, void> =
21-
{ get method() { return 'powerShell/invokeExtensionCommand'; } };
20+
export const type =
21+
new RequestType<InvokeExtensionCommandRequestArguments, void, void, void>(
22+
'powerShell/invokeExtensionCommand');
2223
}
2324

2425
export interface EditorContext {
@@ -33,8 +34,9 @@ export interface InvokeExtensionCommandRequestArguments {
3334
}
3435

3536
export namespace ExtensionCommandAddedNotification {
36-
export const type: NotificationType<ExtensionCommandAddedNotificationBody> =
37-
{ get method() { return 'powerShell/extensionCommandAdded'; } };
37+
export const type =
38+
new NotificationType<ExtensionCommandAddedNotificationBody, void>(
39+
'powerShell/extensionCommandAdded');
3840
}
3941

4042
export interface ExtensionCommandAddedNotificationBody {
@@ -85,8 +87,9 @@ function asCodePosition(value: Position): vscode.Position {
8587
}
8688

8789
export namespace GetEditorContextRequest {
88-
export const type: RequestType<GetEditorContextRequestArguments, EditorContext, void> =
89-
{ get method() { return 'editor/getEditorContext'; } };
90+
export const type =
91+
new RequestType<GetEditorContextRequestArguments, EditorContext, void, void>(
92+
'editor/getEditorContext');
9093
}
9194

9295
export interface GetEditorContextRequestArguments {
@@ -98,8 +101,9 @@ enum EditorOperationResponse {
98101
}
99102

100103
export namespace InsertTextRequest {
101-
export const type: RequestType<InsertTextRequestArguments, EditorOperationResponse, void> =
102-
{ get method() { return 'editor/insertText'; } };
104+
export const type =
105+
new RequestType<InsertTextRequestArguments, EditorOperationResponse, void, void>(
106+
'editor/insertText');
103107
}
104108

105109
export interface InsertTextRequestArguments {
@@ -109,42 +113,49 @@ export interface InsertTextRequestArguments {
109113
}
110114

111115
export namespace SetSelectionRequest {
112-
export const type: RequestType<SetSelectionRequestArguments, EditorOperationResponse, void> =
113-
{ get method() { return 'editor/setSelection'; } };
116+
export const type =
117+
new RequestType<SetSelectionRequestArguments, EditorOperationResponse, void, void>(
118+
'editor/setSelection');
114119
}
115120

116121
export interface SetSelectionRequestArguments {
117122
selectionRange: Range
118123
}
119124

120125
export namespace OpenFileRequest {
121-
export const type: RequestType<string, EditorOperationResponse, void> =
122-
{ get method() { return 'editor/openFile'; } };
126+
export const type =
127+
new RequestType<string, EditorOperationResponse, void, void>(
128+
'editor/openFile');
123129
}
124130

125131
export namespace CloseFileRequest {
126-
export const type: RequestType<string, EditorOperationResponse, void> =
127-
{ get method() { return 'editor/closeFile'; } };
132+
export const type =
133+
new RequestType<string, EditorOperationResponse, void, void>(
134+
'editor/closeFile');
128135
}
129136

130137
export namespace ShowErrorMessageRequest {
131-
export const type: RequestType<string, EditorOperationResponse, void> =
132-
{ get method() { return 'editor/showErrorMessage'; } };
138+
export const type =
139+
new RequestType<string, EditorOperationResponse, void, void>(
140+
'editor/showErrorMessage');
133141
}
134142

135143
export namespace ShowWarningMessageRequest {
136-
export const type: RequestType<string, EditorOperationResponse, void> =
137-
{ get method() { return 'editor/showWarningMessage'; } };
144+
export const type =
145+
new RequestType<string, EditorOperationResponse, void, void>(
146+
'editor/showWarningMessage');
138147
}
139148

140149
export namespace ShowInformationMessageRequest {
141-
export const type: RequestType<string, EditorOperationResponse, void> =
142-
{ get method() { return 'editor/showInformationMessage'; } };
150+
export const type =
151+
new RequestType<string, EditorOperationResponse, void, void>(
152+
'editor/showInformationMessage');
143153
}
144154

145155
export namespace SetStatusBarMessageRequest {
146-
export const type: RequestType<StatusBarMessageDetails, EditorOperationResponse, void> =
147-
{ get method() { return 'editor/setStatusBarMessage'; } };
156+
export const type =
157+
new RequestType<StatusBarMessageDetails, EditorOperationResponse, void, void>(
158+
'editor/setStatusBarMessage');
148159
}
149160

150161
export interface StatusBarMessageDetails {

src/features/NewFileOrProject.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ interface TemplateDetails {
182182
}
183183

184184
namespace GetProjectTemplatesRequest {
185-
export const type: RequestType<GetProjectTemplatesRequestArgs, GetProjectTemplatesResponseBody, string> =
186-
{ get method() { return 'powerShell/getProjectTemplates'; } };
185+
export const type =
186+
new RequestType<GetProjectTemplatesRequestArgs, GetProjectTemplatesResponseBody, string, void>(
187+
'powerShell/getProjectTemplates');
187188
}
188189

189190
interface GetProjectTemplatesRequestArgs {
@@ -196,8 +197,9 @@ interface GetProjectTemplatesResponseBody {
196197
}
197198

198199
namespace NewProjectFromTemplateRequest {
199-
export const type: RequestType<any, NewProjectFromTemplateResponseBody, string> =
200-
{ get method() { return 'powerShell/newProjectFromTemplate'; } };
200+
export const type =
201+
new RequestType<any, NewProjectFromTemplateResponseBody, string, void>(
202+
'powerShell/newProjectFromTemplate');
201203
}
202204

203205
interface NewProjectFromTemplateRequestArgs {

src/features/PowerShellFindModule.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import QuickPickItem = vscode.QuickPickItem;
99
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
1010

1111
export namespace FindModuleRequest {
12-
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/findModule'; } };
12+
export const type = new RequestType<any, any, void, void>('powerShell/findModule');
1313
}
1414

1515
export namespace InstallModuleRequest {
16-
export const type: RequestType<string, void, void> = { get method() { return 'powerShell/installModule'; } };
16+
export const type = new RequestType<string, void, void, void>('powerShell/installModule');
1717
}
1818

1919
export class FindModuleFeature implements IFeature {

src/features/RemoteFiles.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export interface DidSaveTextDocumentParams {
1919
}
2020

2121
export namespace DidSaveTextDocumentNotification {
22-
export const type: NotificationType<DidSaveTextDocumentParams> =
23-
{ get method() { return 'textDocument/didSave'; } }
22+
export const type = new NotificationType<DidSaveTextDocumentParams, void>('textDocument/didSave');
2423
}
2524

2625
export class RemoteFilesFeature implements IFeature {

src/features/SelectPSSARules.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { LanguageClient, RequestType } from "vscode-languageclient";
88
import { CheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick";
99

1010
export namespace GetPSSARulesRequest {
11-
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/getPSSARules"; } };
11+
export const type = new RequestType<any, any, void, void>("powerShell/getPSSARules");
1212
}
1313

1414
export namespace SetPSSARulesRequest {
15-
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/setPSSARules"; } };
15+
export const type = new RequestType<any, any, void, void>("powerShell/setPSSARules");
1616
}
1717

1818
class RuleInfo {

src/features/ShowOnlineHelp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IFeature } from '../feature';
77
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
88

99
export namespace ShowOnlineHelpRequest {
10-
export const type: RequestType<string, void, void> = { get method() { return 'powerShell/showOnlineHelp'; } };
10+
export const type = new RequestType<string, void, void, void>('powerShell/showOnlineHelp');
1111
}
1212

1313
export class ShowHelpFeature implements IFeature {

src/logging.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import os = require('os');
77
import path = require('path');
88
import vscode = require('vscode');
99
import utils = require('./utils');
10-
import { ILogger } from 'vscode-jsonrpc';
10+
import jsonrpc = require('vscode-jsonrpc');
1111

1212
export enum LogLevel {
1313
Verbose,
@@ -145,7 +145,7 @@ export class Logger {
145145
}
146146
}
147147

148-
export class LanguageClientLogger implements ILogger {
148+
export class LanguageClientLogger implements jsonrpc.Logger {
149149

150150
constructor(private logger: Logger) { }
151151

src/session.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Settings = require('./settings');
1414
import { Logger } from './logging';
1515
import { IFeature } from './feature';
1616
import { StringDecoder } from 'string_decoder';
17-
import { LanguageClient, LanguageClientOptions, Executable, RequestType, NotificationType, StreamInfo } from 'vscode-languageclient';
17+
import { LanguageClient, LanguageClientOptions, Executable, RequestType, RequestType0, NotificationType, StreamInfo } from 'vscode-languageclient';
1818

1919
export enum SessionStatus {
2020
NotStarted,
@@ -456,10 +456,6 @@ export class SessionManager {
456456
connectFunc,
457457
clientOptions);
458458

459-
// Send the new LanguageClient to extension features
460-
// so that they can register their message handlers
461-
// before the connection is established.
462-
this.updateExtensionFeatures(this.languageServerClient);
463459

464460
this.languageServerClient.onReady().then(
465461
() => {
@@ -474,14 +470,19 @@ export class SessionManager {
474470
: this.versionDetails.displayVersion,
475471
SessionStatus.Running);
476472
});
473+
474+
// Send the new LanguageClient to extension features
475+
// so that they can register their message handlers
476+
// before the connection is established.
477+
this.updateExtensionFeatures(this.languageServerClient);
478+
this.languageServerClient.onNotification(
479+
RunspaceChangedEvent.type,
480+
(runspaceDetails) => { this.setStatusBarVersionString(runspaceDetails); });
477481
},
478482
(reason) => {
479483
this.setSessionFailure("Could not start language service: ", reason);
480484
});
481485

482-
this.languageServerClient.onNotification(
483-
RunspaceChangedEvent.type,
484-
(runspaceDetails) => { this.setStatusBarVersionString(runspaceDetails); });
485486

486487
this.languageServerClient.start();
487488
}
@@ -744,8 +745,7 @@ class SessionMenuItem implements vscode.QuickPickItem {
744745
}
745746

746747
export namespace PowerShellVersionRequest {
747-
export const type: RequestType<void, PowerShellVersionDetails, void> =
748-
{ get method() { return 'powerShell/getVersion'; } };
748+
export const type = new RequestType0<PowerShellVersionDetails, void, void>('powerShell/getVersion');
749749
}
750750

751751
export interface PowerShellVersionDetails {
@@ -768,6 +768,5 @@ export interface RunspaceDetails {
768768
}
769769

770770
export namespace RunspaceChangedEvent {
771-
export const type: NotificationType<RunspaceDetails> =
772-
{ get method() { return 'powerShell/runspaceChanged'; } };
773-
}
771+
export const type = new NotificationType<RunspaceDetails, void>('powerShell/runspaceChanged');
772+
}

0 commit comments

Comments
 (0)