Skip to content

Commit c3e53cc

Browse files
dfinkedaviwil
authored andcommitted
Wired up Show Information|Warning|Error Message
1 parent 21abcb0 commit c3e53cc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/features/ExtensionCommands.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@ export namespace OpenFileRequest {
122122
{ get method() { return 'editor/openFile'; } };
123123
}
124124

125+
export namespace ShowErrorMessageRequest {
126+
export const type: RequestType<string, EditorOperationResponse, void> =
127+
{ get method() { return 'editor/showErrorMessage'; } };
128+
}
129+
130+
export namespace ShowWarningMessageRequest {
131+
export const type: RequestType<string, EditorOperationResponse, void> =
132+
{ get method() { return 'editor/showWarningMessage'; } };
133+
}
134+
135+
export namespace ShowInformationMessageRequest {
136+
export const type: RequestType<string, EditorOperationResponse, void> =
137+
{ get method() { return 'editor/showInformationMessage'; } };
138+
}
139+
140+
export namespace SetStatusBarMessageRequest {
141+
export const type: RequestType<string, EditorOperationResponse, void> =
142+
{ get method() { return 'editor/setStatusBarMessage'; } };
143+
}
144+
125145
export class ExtensionCommandsFeature implements IFeature {
126146

127147
private command: vscode.Disposable;
@@ -172,6 +192,22 @@ export class ExtensionCommandsFeature implements IFeature {
172192
this.languageClient.onRequest(
173193
OpenFileRequest.type,
174194
filePath => this.openFile(filePath));
195+
196+
this.languageClient.onRequest(
197+
ShowInformationMessageRequest.type,
198+
message => this.showInformationMessage(message));
199+
200+
this.languageClient.onRequest(
201+
ShowErrorMessageRequest.type,
202+
message => this.showErrorMessage(message));
203+
204+
this.languageClient.onRequest(
205+
ShowWarningMessageRequest.type,
206+
message => this.showWarningMessage(message));
207+
208+
this.languageClient.onRequest(
209+
SetStatusBarMessageRequest.type,
210+
message => this.setStatusBarMessage(message));
175211
}
176212
}
177213

@@ -285,4 +321,27 @@ export class ExtensionCommandsFeature implements IFeature {
285321

286322
return EditorOperationResponse.Completed;
287323
}
324+
325+
private showInformationMessage(message: string): Thenable<EditorOperationResponse> {
326+
return vscode.window
327+
.showInformationMessage(message)
328+
.then(_ => EditorOperationResponse.Completed);
329+
}
330+
331+
private showErrorMessage(message: string): Thenable<EditorOperationResponse> {
332+
return vscode.window
333+
.showErrorMessage(message)
334+
.then(_ => EditorOperationResponse.Completed);
335+
}
336+
337+
private showWarningMessage(message: string): Thenable<EditorOperationResponse> {
338+
return vscode.window
339+
.showWarningMessage(message)
340+
.then(_ => EditorOperationResponse.Completed);
341+
}
342+
343+
private setStatusBarMessage(message: string): EditorOperationResponse {
344+
vscode.window.setStatusBarMessage(message);
345+
return EditorOperationResponse.Completed;
346+
}
288347
}

0 commit comments

Comments
 (0)