diff --git a/package.json b/package.json index ab805873be..a98fdcf480 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "onCommand:PowerShell.PickPSHostProcess" ], "dependencies": { - "vscode-languageclient": "1.3.1" + "vscode-languageclient": "3.2.0" }, "devDependencies": { "@types/node": "^6.0.40", diff --git a/src/features/CodeActions.ts b/src/features/CodeActions.ts index 521026a24a..f6ca66beea 100644 --- a/src/features/CodeActions.ts +++ b/src/features/CodeActions.ts @@ -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'; diff --git a/src/features/Console.ts b/src/features/Console.ts index 31f2298901..deb91eb0d7 100644 --- a/src/features/Console.ts +++ b/src/features/Console.ts @@ -8,8 +8,7 @@ import { showCheckboxQuickPick, CheckboxQuickPickItem } from '../controls/checkb import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient'; export namespace EvaluateRequest { - export const type: RequestType = - { get method() { return 'evaluate'; } }; + export const type = new RequestType('evaluate'); } export interface EvaluateRequestArguments { @@ -17,8 +16,7 @@ export interface EvaluateRequestArguments { } export namespace OutputNotification { - export const type: NotificationType = - { get method() { return 'output'; } }; + export const type = new NotificationType('output'); } export interface OutputNotificationBody { @@ -27,13 +25,13 @@ export interface OutputNotificationBody { } export namespace ShowChoicePromptRequest { - export const type: RequestType = - { get method() { return 'powerShell/showChoicePrompt'; } }; + export const type = + new RequestType('powerShell/showChoicePrompt'); } export namespace ShowInputPromptRequest { - export const type: RequestType = - { get method() { return 'powerShell/showInputPrompt'; } }; + export const type = + new RequestType('powerShell/showInputPrompt'); } interface ChoiceDetails { diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index 17a94ce899..0f57f481b7 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -118,8 +118,8 @@ interface PSHostProcessInfo { } namespace GetPSHostProcessesRequest { - export const type: RequestType = - { get method() { return 'powerShell/getPSHostProcesses'; } }; + export const type = + new RequestType('powerShell/getPSHostProcesses'); } interface GetPSHostProcessesResponseBody { diff --git a/src/features/DocumentFormatter.ts b/src/features/DocumentFormatter.ts index 17e4628796..685491ea7b 100644 --- a/src/features/DocumentFormatter.ts +++ b/src/features/DocumentFormatter.ts @@ -25,11 +25,11 @@ import * as Utils from '../utils'; import * as AnimatedStatusBar from '../controls/animatedStatusBar'; export namespace ScriptFileMarkersRequest { - export const type: RequestType = { get method(): string { return "powerShell/getScriptFileMarkers"; } }; + export const type = new RequestType("powerShell/getScriptFileMarkers"); } export namespace ScriptRegionRequest { - export const type: RequestType = { get method(): string { return "powerShell/getScriptRegion"; } }; + export const type = new RequestType("powerShell/getScriptRegion"); } interface ScriptRegionRequestParams { diff --git a/src/features/ExpandAlias.ts b/src/features/ExpandAlias.ts index e4997daa97..64564262da 100644 --- a/src/features/ExpandAlias.ts +++ b/src/features/ExpandAlias.ts @@ -8,7 +8,7 @@ import { IFeature } from '../feature'; import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient'; export namespace ExpandAliasRequest { - export const type: RequestType = { get method() { return 'powerShell/expandAlias'; } }; + export const type = new RequestType('powerShell/expandAlias'); } export class ExpandAliasFeature implements IFeature { diff --git a/src/features/ExtensionCommands.ts b/src/features/ExtensionCommands.ts index a68fa74673..d107829549 100644 --- a/src/features/ExtensionCommands.ts +++ b/src/features/ExtensionCommands.ts @@ -17,8 +17,9 @@ export interface ExtensionCommandQuickPickItem extends vscode.QuickPickItem { } export namespace InvokeExtensionCommandRequest { - export const type: RequestType = - { get method() { return 'powerShell/invokeExtensionCommand'; } }; + export const type = + new RequestType( + 'powerShell/invokeExtensionCommand'); } export interface EditorContext { @@ -33,8 +34,9 @@ export interface InvokeExtensionCommandRequestArguments { } export namespace ExtensionCommandAddedNotification { - export const type: NotificationType = - { get method() { return 'powerShell/extensionCommandAdded'; } }; + export const type = + new NotificationType( + 'powerShell/extensionCommandAdded'); } export interface ExtensionCommandAddedNotificationBody { @@ -85,8 +87,9 @@ function asCodePosition(value: Position): vscode.Position { } export namespace GetEditorContextRequest { - export const type: RequestType = - { get method() { return 'editor/getEditorContext'; } }; + export const type = + new RequestType( + 'editor/getEditorContext'); } export interface GetEditorContextRequestArguments { @@ -98,8 +101,9 @@ enum EditorOperationResponse { } export namespace InsertTextRequest { - export const type: RequestType = - { get method() { return 'editor/insertText'; } }; + export const type = + new RequestType( + 'editor/insertText'); } export interface InsertTextRequestArguments { @@ -109,8 +113,9 @@ export interface InsertTextRequestArguments { } export namespace SetSelectionRequest { - export const type: RequestType = - { get method() { return 'editor/setSelection'; } }; + export const type = + new RequestType( + 'editor/setSelection'); } export interface SetSelectionRequestArguments { @@ -118,33 +123,39 @@ export interface SetSelectionRequestArguments { } export namespace OpenFileRequest { - export const type: RequestType = - { get method() { return 'editor/openFile'; } }; + export const type = + new RequestType( + 'editor/openFile'); } export namespace CloseFileRequest { - export const type: RequestType = - { get method() { return 'editor/closeFile'; } }; + export const type = + new RequestType( + 'editor/closeFile'); } export namespace ShowErrorMessageRequest { - export const type: RequestType = - { get method() { return 'editor/showErrorMessage'; } }; + export const type = + new RequestType( + 'editor/showErrorMessage'); } export namespace ShowWarningMessageRequest { - export const type: RequestType = - { get method() { return 'editor/showWarningMessage'; } }; + export const type = + new RequestType( + 'editor/showWarningMessage'); } export namespace ShowInformationMessageRequest { - export const type: RequestType = - { get method() { return 'editor/showInformationMessage'; } }; + export const type = + new RequestType( + 'editor/showInformationMessage'); } export namespace SetStatusBarMessageRequest { - export const type: RequestType = - { get method() { return 'editor/setStatusBarMessage'; } }; + export const type = + new RequestType( + 'editor/setStatusBarMessage'); } export interface StatusBarMessageDetails { diff --git a/src/features/NewFileOrProject.ts b/src/features/NewFileOrProject.ts index 6a91938622..34595bf6d1 100644 --- a/src/features/NewFileOrProject.ts +++ b/src/features/NewFileOrProject.ts @@ -182,8 +182,9 @@ interface TemplateDetails { } namespace GetProjectTemplatesRequest { - export const type: RequestType = - { get method() { return 'powerShell/getProjectTemplates'; } }; + export const type = + new RequestType( + 'powerShell/getProjectTemplates'); } interface GetProjectTemplatesRequestArgs { @@ -196,8 +197,9 @@ interface GetProjectTemplatesResponseBody { } namespace NewProjectFromTemplateRequest { - export const type: RequestType = - { get method() { return 'powerShell/newProjectFromTemplate'; } }; + export const type = + new RequestType( + 'powerShell/newProjectFromTemplate'); } interface NewProjectFromTemplateRequestArgs { diff --git a/src/features/PowerShellFindModule.ts b/src/features/PowerShellFindModule.ts index a95ca40675..c1664a69d0 100644 --- a/src/features/PowerShellFindModule.ts +++ b/src/features/PowerShellFindModule.ts @@ -9,11 +9,11 @@ import QuickPickItem = vscode.QuickPickItem; import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient'; export namespace FindModuleRequest { - export const type: RequestType = { get method() { return 'powerShell/findModule'; } }; + export const type = new RequestType('powerShell/findModule'); } export namespace InstallModuleRequest { - export const type: RequestType = { get method() { return 'powerShell/installModule'; } }; + export const type = new RequestType('powerShell/installModule'); } export class FindModuleFeature implements IFeature { diff --git a/src/features/RemoteFiles.ts b/src/features/RemoteFiles.ts index 854824260f..ff837fa5eb 100644 --- a/src/features/RemoteFiles.ts +++ b/src/features/RemoteFiles.ts @@ -19,8 +19,7 @@ export interface DidSaveTextDocumentParams { } export namespace DidSaveTextDocumentNotification { - export const type: NotificationType = - { get method() { return 'textDocument/didSave'; } } + export const type = new NotificationType('textDocument/didSave'); } export class RemoteFilesFeature implements IFeature { diff --git a/src/features/SelectPSSARules.ts b/src/features/SelectPSSARules.ts index 089ad46df6..167c02eb19 100644 --- a/src/features/SelectPSSARules.ts +++ b/src/features/SelectPSSARules.ts @@ -8,11 +8,11 @@ import { LanguageClient, RequestType } from "vscode-languageclient"; import { CheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick"; export namespace GetPSSARulesRequest { - export const type: RequestType = { get method(): string { return "powerShell/getPSSARules"; } }; + export const type = new RequestType("powerShell/getPSSARules"); } export namespace SetPSSARulesRequest { - export const type: RequestType = { get method(): string { return "powerShell/setPSSARules"; } }; + export const type = new RequestType("powerShell/setPSSARules"); } class RuleInfo { diff --git a/src/features/ShowOnlineHelp.ts b/src/features/ShowOnlineHelp.ts index 54e38d2072..f96c648c72 100644 --- a/src/features/ShowOnlineHelp.ts +++ b/src/features/ShowOnlineHelp.ts @@ -7,7 +7,7 @@ import { IFeature } from '../feature'; import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient'; export namespace ShowOnlineHelpRequest { - export const type: RequestType = { get method() { return 'powerShell/showOnlineHelp'; } }; + export const type = new RequestType('powerShell/showOnlineHelp'); } export class ShowHelpFeature implements IFeature { diff --git a/src/logging.ts b/src/logging.ts index 02806cc4e7..e77528ebbf 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -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, @@ -145,7 +145,7 @@ export class Logger { } } -export class LanguageClientLogger implements ILogger { +export class LanguageClientLogger implements jsonrpc.Logger { constructor(private logger: Logger) { } diff --git a/src/session.ts b/src/session.ts index 625215f76a..e92de2904a 100644 --- a/src/session.ts +++ b/src/session.ts @@ -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, @@ -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( () => { @@ -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(); } @@ -744,8 +745,7 @@ class SessionMenuItem implements vscode.QuickPickItem { } export namespace PowerShellVersionRequest { - export const type: RequestType = - { get method() { return 'powerShell/getVersion'; } }; + export const type = new RequestType0('powerShell/getVersion'); } export interface PowerShellVersionDetails { @@ -768,6 +768,5 @@ export interface RunspaceDetails { } export namespace RunspaceChangedEvent { - export const type: NotificationType = - { get method() { return 'powerShell/runspaceChanged'; } }; -} \ No newline at end of file + export const type = new NotificationType('powerShell/runspaceChanged'); +}