Skip to content

Upgrade language server protocol to v3.2.0 #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"onCommand:PowerShell.PickPSHostProcess"
],
"dependencies": {
"vscode-languageclient": "1.3.1"
"vscode-languageclient": "3.2.0"
},
"devDependencies": {
"@types/node": "^6.0.40",
Expand Down
2 changes: 1 addition & 1 deletion src/features/CodeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*--------------------------------------------------------*/

import vscode = require('vscode');
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient';
import Window = vscode.window;
import { IFeature } from '../feature';

Expand Down
14 changes: 6 additions & 8 deletions src/features/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import { showCheckboxQuickPick, CheckboxQuickPickItem } from '../controls/checkb
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';

export namespace EvaluateRequest {
export const type: RequestType<EvaluateRequestArguments, void, void> =
{ get method() { return 'evaluate'; } };
export const type = new RequestType<EvaluateRequestArguments, void, void, void>('evaluate');
}

export interface EvaluateRequestArguments {
expression: string;
}

export namespace OutputNotification {
export const type: NotificationType<OutputNotificationBody> =
{ get method() { return 'output'; } };
export const type = new NotificationType<OutputNotificationBody, void>('output');
}

export interface OutputNotificationBody {
Expand All @@ -27,13 +25,13 @@ export interface OutputNotificationBody {
}

export namespace ShowChoicePromptRequest {
export const type: RequestType<ShowChoicePromptRequestArgs, ShowChoicePromptResponseBody, string> =
{ get method() { return 'powerShell/showChoicePrompt'; } };
export const type =
new RequestType<ShowChoicePromptRequestArgs, ShowChoicePromptResponseBody, string, void>('powerShell/showChoicePrompt');
}

export namespace ShowInputPromptRequest {
export const type: RequestType<ShowInputPromptRequestArgs, ShowInputPromptResponseBody, string> =
{ get method() { return 'powerShell/showInputPrompt'; } };
export const type =
new RequestType<ShowInputPromptRequestArgs, ShowInputPromptResponseBody, string, void>('powerShell/showInputPrompt');
}

interface ChoiceDetails {
Expand Down
4 changes: 2 additions & 2 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ interface PSHostProcessInfo {
}

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

interface GetPSHostProcessesResponseBody {
Expand Down
4 changes: 2 additions & 2 deletions src/features/DocumentFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import * as Utils from '../utils';
import * as AnimatedStatusBar from '../controls/animatedStatusBar';

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

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

interface ScriptRegionRequestParams {
Expand Down
2 changes: 1 addition & 1 deletion src/features/ExpandAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IFeature } from '../feature';
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';

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

export class ExpandAliasFeature implements IFeature {
Expand Down
55 changes: 33 additions & 22 deletions src/features/ExtensionCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export interface ExtensionCommandQuickPickItem extends vscode.QuickPickItem {
}

export namespace InvokeExtensionCommandRequest {
export const type: RequestType<InvokeExtensionCommandRequestArguments, void, void> =
{ get method() { return 'powerShell/invokeExtensionCommand'; } };
export const type =
new RequestType<InvokeExtensionCommandRequestArguments, void, void, void>(
'powerShell/invokeExtensionCommand');
}

export interface EditorContext {
Expand All @@ -33,8 +34,9 @@ export interface InvokeExtensionCommandRequestArguments {
}

export namespace ExtensionCommandAddedNotification {
export const type: NotificationType<ExtensionCommandAddedNotificationBody> =
{ get method() { return 'powerShell/extensionCommandAdded'; } };
export const type =
new NotificationType<ExtensionCommandAddedNotificationBody, void>(
'powerShell/extensionCommandAdded');
}

export interface ExtensionCommandAddedNotificationBody {
Expand Down Expand Up @@ -85,8 +87,9 @@ function asCodePosition(value: Position): vscode.Position {
}

export namespace GetEditorContextRequest {
export const type: RequestType<GetEditorContextRequestArguments, EditorContext, void> =
{ get method() { return 'editor/getEditorContext'; } };
export const type =
new RequestType<GetEditorContextRequestArguments, EditorContext, void, void>(
'editor/getEditorContext');
}

export interface GetEditorContextRequestArguments {
Expand All @@ -98,8 +101,9 @@ enum EditorOperationResponse {
}

export namespace InsertTextRequest {
export const type: RequestType<InsertTextRequestArguments, EditorOperationResponse, void> =
{ get method() { return 'editor/insertText'; } };
export const type =
new RequestType<InsertTextRequestArguments, EditorOperationResponse, void, void>(
'editor/insertText');
}

export interface InsertTextRequestArguments {
Expand All @@ -109,42 +113,49 @@ export interface InsertTextRequestArguments {
}

export namespace SetSelectionRequest {
export const type: RequestType<SetSelectionRequestArguments, EditorOperationResponse, void> =
{ get method() { return 'editor/setSelection'; } };
export const type =
new RequestType<SetSelectionRequestArguments, EditorOperationResponse, void, void>(
'editor/setSelection');
}

export interface SetSelectionRequestArguments {
selectionRange: Range
}

export namespace OpenFileRequest {
export const type: RequestType<string, EditorOperationResponse, void> =
{ get method() { return 'editor/openFile'; } };
export const type =
new RequestType<string, EditorOperationResponse, void, void>(
'editor/openFile');
}

export namespace CloseFileRequest {
export const type: RequestType<string, EditorOperationResponse, void> =
{ get method() { return 'editor/closeFile'; } };
export const type =
new RequestType<string, EditorOperationResponse, void, void>(
'editor/closeFile');
}

export namespace ShowErrorMessageRequest {
export const type: RequestType<string, EditorOperationResponse, void> =
{ get method() { return 'editor/showErrorMessage'; } };
export const type =
new RequestType<string, EditorOperationResponse, void, void>(
'editor/showErrorMessage');
}

export namespace ShowWarningMessageRequest {
export const type: RequestType<string, EditorOperationResponse, void> =
{ get method() { return 'editor/showWarningMessage'; } };
export const type =
new RequestType<string, EditorOperationResponse, void, void>(
'editor/showWarningMessage');
}

export namespace ShowInformationMessageRequest {
export const type: RequestType<string, EditorOperationResponse, void> =
{ get method() { return 'editor/showInformationMessage'; } };
export const type =
new RequestType<string, EditorOperationResponse, void, void>(
'editor/showInformationMessage');
}

export namespace SetStatusBarMessageRequest {
export const type: RequestType<StatusBarMessageDetails, EditorOperationResponse, void> =
{ get method() { return 'editor/setStatusBarMessage'; } };
export const type =
new RequestType<StatusBarMessageDetails, EditorOperationResponse, void, void>(
'editor/setStatusBarMessage');
}

export interface StatusBarMessageDetails {
Expand Down
10 changes: 6 additions & 4 deletions src/features/NewFileOrProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ interface TemplateDetails {
}

namespace GetProjectTemplatesRequest {
export const type: RequestType<GetProjectTemplatesRequestArgs, GetProjectTemplatesResponseBody, string> =
{ get method() { return 'powerShell/getProjectTemplates'; } };
export const type =
new RequestType<GetProjectTemplatesRequestArgs, GetProjectTemplatesResponseBody, string, void>(
'powerShell/getProjectTemplates');
}

interface GetProjectTemplatesRequestArgs {
Expand All @@ -196,8 +197,9 @@ interface GetProjectTemplatesResponseBody {
}

namespace NewProjectFromTemplateRequest {
export const type: RequestType<any, NewProjectFromTemplateResponseBody, string> =
{ get method() { return 'powerShell/newProjectFromTemplate'; } };
export const type =
new RequestType<any, NewProjectFromTemplateResponseBody, string, void>(
'powerShell/newProjectFromTemplate');
}

interface NewProjectFromTemplateRequestArgs {
Expand Down
4 changes: 2 additions & 2 deletions src/features/PowerShellFindModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import QuickPickItem = vscode.QuickPickItem;
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';

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

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

export class FindModuleFeature implements IFeature {
Expand Down
3 changes: 1 addition & 2 deletions src/features/RemoteFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export interface DidSaveTextDocumentParams {
}

export namespace DidSaveTextDocumentNotification {
export const type: NotificationType<DidSaveTextDocumentParams> =
{ get method() { return 'textDocument/didSave'; } }
export const type = new NotificationType<DidSaveTextDocumentParams, void>('textDocument/didSave');
}

export class RemoteFilesFeature implements IFeature {
Expand Down
4 changes: 2 additions & 2 deletions src/features/SelectPSSARules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { LanguageClient, RequestType } from "vscode-languageclient";
import { CheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick";

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

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

class RuleInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/features/ShowOnlineHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IFeature } from '../feature';
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';

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

export class ShowHelpFeature implements IFeature {
Expand Down
4 changes: 2 additions & 2 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import os = require('os');
import path = require('path');
import vscode = require('vscode');
import utils = require('./utils');
import { ILogger } from 'vscode-jsonrpc';
import jsonrpc = require('vscode-jsonrpc');

export enum LogLevel {
Verbose,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class Logger {
}
}

export class LanguageClientLogger implements ILogger {
export class LanguageClientLogger implements jsonrpc.Logger {

constructor(private logger: Logger) { }

Expand Down
25 changes: 12 additions & 13 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Settings = require('./settings');
import { Logger } from './logging';
import { IFeature } from './feature';
import { StringDecoder } from 'string_decoder';
import { LanguageClient, LanguageClientOptions, Executable, RequestType, NotificationType, StreamInfo } from 'vscode-languageclient';
import { LanguageClient, LanguageClientOptions, Executable, RequestType, RequestType0, NotificationType, StreamInfo } from 'vscode-languageclient';

export enum SessionStatus {
NotStarted,
Expand Down Expand Up @@ -456,10 +456,6 @@ export class SessionManager {
connectFunc,
clientOptions);

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

this.languageServerClient.onReady().then(
() => {
Expand All @@ -474,14 +470,19 @@ export class SessionManager {
: this.versionDetails.displayVersion,
SessionStatus.Running);
});

// Send the new LanguageClient to extension features
// so that they can register their message handlers
// before the connection is established.
this.updateExtensionFeatures(this.languageServerClient);
this.languageServerClient.onNotification(
RunspaceChangedEvent.type,
(runspaceDetails) => { this.setStatusBarVersionString(runspaceDetails); });
},
(reason) => {
this.setSessionFailure("Could not start language service: ", reason);
});

this.languageServerClient.onNotification(
RunspaceChangedEvent.type,
(runspaceDetails) => { this.setStatusBarVersionString(runspaceDetails); });

this.languageServerClient.start();
}
Expand Down Expand Up @@ -744,8 +745,7 @@ class SessionMenuItem implements vscode.QuickPickItem {
}

export namespace PowerShellVersionRequest {
export const type: RequestType<void, PowerShellVersionDetails, void> =
{ get method() { return 'powerShell/getVersion'; } };
export const type = new RequestType0<PowerShellVersionDetails, void, void>('powerShell/getVersion');
}

export interface PowerShellVersionDetails {
Expand All @@ -768,6 +768,5 @@ export interface RunspaceDetails {
}

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