|
| 1 | +import * as vscode from 'vscode'; |
| 2 | +import { OutputChannel, StatusBarAlignment, StatusBarItem } from 'vscode'; |
| 3 | + |
| 4 | +export interface IWindowsSrevice { |
| 5 | + /** |
| 6 | + * Create a new [output channel](#OutputChannel) with the given name. |
| 7 | + * |
| 8 | + * @param name Human-readable string which will be used to represent the channel in the UI. |
| 9 | + */ |
| 10 | + createOutputChannel(name: string): OutputChannel; |
| 11 | + /** |
| 12 | + * Creates a status bar [item](#StatusBarItem). |
| 13 | + * |
| 14 | + * @param alignment The alignment of the item. |
| 15 | + * @param priority The priority of the item. Higher values mean the item should be shown more to the left. |
| 16 | + * @return A new status bar item. |
| 17 | + */ |
| 18 | + createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem; |
| 19 | + /** |
| 20 | + * Show an information message to users. Optionally provide an array of items which will be presented as |
| 21 | + * clickable buttons. |
| 22 | + * |
| 23 | + * @param message The message to show. |
| 24 | + * @param items A set of items that will be rendered as actions in the message. |
| 25 | + * @return A thenable that resolves to the selected item or `undefined` when being dismissed. |
| 26 | + */ |
| 27 | + showInformationMessage(message: string, ...items: string[]): Thenable<string>; |
| 28 | + /** |
| 29 | + * Show a warning message. |
| 30 | + * |
| 31 | + * @see [showInformationMessage](#window.showInformationMessage) |
| 32 | + * |
| 33 | + * @param message The message to show. |
| 34 | + * @param items A set of items that will be rendered as actions in the message. |
| 35 | + * @return A thenable that resolves to the selected item or `undefined` when being dismissed. |
| 36 | + */ |
| 37 | + showWarningMessage(message: string, ...items: string[]): Thenable<string>; |
| 38 | + /** |
| 39 | + * Show an error message. |
| 40 | + * |
| 41 | + * @see [showInformationMessage](#window.showInformationMessage) |
| 42 | + * |
| 43 | + * @param message The message to show. |
| 44 | + * @param items A set of items that will be rendered as actions in the message. |
| 45 | + * @return A thenable that resolves to the selected item or `undefined` when being dismissed. |
| 46 | + */ |
| 47 | + showErrorMessage(message: string, ...items: string[]): Thenable<string>; |
| 48 | +} |
| 49 | + |
| 50 | +export class WindowService implements IWindowsSrevice { |
| 51 | + public createOutputChannel(name: string): OutputChannel { |
| 52 | + return vscode.window.createOutputChannel(name); |
| 53 | + } |
| 54 | + public createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem { |
| 55 | + return vscode.window.createStatusBarItem.apply(vscode.window, arguments); |
| 56 | + } |
| 57 | + public showInformationMessage(message: string, ...items: string[]): Thenable<string> { |
| 58 | + return vscode.window.showInformationMessage.apply(vscode.window, arguments); |
| 59 | + } |
| 60 | + public showWarningMessage(message: string, ...items: string[]): Thenable<string> { |
| 61 | + return vscode.window.showWarningMessage.apply(vscode.window, arguments); |
| 62 | + } |
| 63 | + public showErrorMessage(message: string, ...items: string[]): Thenable<string> { |
| 64 | + return vscode.window.showErrorMessage.apply(vscode.window, arguments); |
| 65 | + } |
| 66 | +} |
0 commit comments