diff --git a/src/features/ExtensionCommands.ts b/src/features/ExtensionCommands.ts index 9e81d4bf38..745d86f620 100644 --- a/src/features/ExtensionCommands.ts +++ b/src/features/ExtensionCommands.ts @@ -122,6 +122,31 @@ export namespace OpenFileRequest { { get method() { return 'editor/openFile'; } }; } +export namespace ShowErrorMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showErrorMessage'; } }; +} + +export namespace ShowWarningMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showWarningMessage'; } }; +} + +export namespace ShowInformationMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showInformationMessage'; } }; +} + +export namespace SetStatusBarMessageRequest { + export const type: RequestType = + { get method() { return 'editor/setStatusBarMessage'; } }; +} + +export interface StatusBarMessageDetails { + message: string; + timeout?: number; +} + export class ExtensionCommandsFeature implements IFeature { private command: vscode.Disposable; @@ -172,6 +197,22 @@ export class ExtensionCommandsFeature implements IFeature { this.languageClient.onRequest( OpenFileRequest.type, filePath => this.openFile(filePath)); + + this.languageClient.onRequest( + ShowInformationMessageRequest.type, + message => this.showInformationMessage(message)); + + this.languageClient.onRequest( + ShowErrorMessageRequest.type, + message => this.showErrorMessage(message)); + + this.languageClient.onRequest( + ShowWarningMessageRequest.type, + message => this.showWarningMessage(message)); + + this.languageClient.onRequest( + SetStatusBarMessageRequest.type, + messageDetails => this.setStatusBarMessage(messageDetails)); } } @@ -285,4 +326,34 @@ export class ExtensionCommandsFeature implements IFeature { return EditorOperationResponse.Completed; } + + private showInformationMessage(message: string): Thenable { + return vscode.window + .showInformationMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private showErrorMessage(message: string): Thenable { + return vscode.window + .showErrorMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private showWarningMessage(message: string): Thenable { + return vscode.window + .showWarningMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private setStatusBarMessage(messageDetails: StatusBarMessageDetails): EditorOperationResponse { + + if (messageDetails.timeout) { + vscode.window.setStatusBarMessage(messageDetails.message, messageDetails.timeout); + } + else { + vscode.window.setStatusBarMessage(messageDetails.message); + } + + return EditorOperationResponse.Completed; + } } diff --git a/src/main.ts b/src/main.ts index 0ba1071886..804ecf7e65 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,27 +55,27 @@ export function activate(context: vscode.ExtensionContext): void { // e.g. /** | */ beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, afterText: /^\s*\*\/$/, - action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' } + action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: ' * ' } }, { // e.g. /** ...| beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, - action: { indentAction: IndentAction.None, appendText: ' * ' } + action: { indentAction: vscode.IndentAction.None, appendText: ' * ' } }, { // e.g. * ...| beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/, - action: { indentAction: IndentAction.None, appendText: '* ' } + action: { indentAction: vscode.IndentAction.None, appendText: '* ' } }, { // e.g. */| beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/, - action: { indentAction: IndentAction.None, removeText: 1 } + action: { indentAction: vscode.IndentAction.None, removeText: 1 } }, { // e.g. *-----*/| beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/, - action: { indentAction: IndentAction.None, removeText: 1 } + action: { indentAction: vscode.IndentAction.None, removeText: 1 } } ] });