| 1 | import * as vscode from "vscode"; |
| 2 | |
| 3 | export class DownloadYamlExtensionCodeLensProvider |
| 4 | implements vscode.CodeLensProvider |
| 5 | { |
| 6 | private yamlExtensionDownloaded(): boolean { |
| 7 | const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml"); |
| 8 | return yamlExtension !== undefined; |
| 9 | } |
| 10 | |
| 11 | public provideCodeLenses( |
| 12 | document: vscode.TextDocument, |
| 13 | _: vscode.CancellationToken, |
| 14 | ): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> { |
| 15 | if (!document.uri.fsPath.includes(".continue")) { |
| 16 | return []; |
| 17 | } |
| 18 | if (this.yamlExtensionDownloaded()) { |
| 19 | return []; |
| 20 | } |
| 21 | |
| 22 | const codeLens: vscode.CodeLens = { |
| 23 | range: new vscode.Range(0, 0, 0, 0), |
| 24 | command: { |
| 25 | title: "Download YAML extension for Intellisense", |
| 26 | command: "workbench.extensions.installExtension", |
| 27 | arguments: ["redhat.vscode-yaml"], |
| 28 | }, |
| 29 | isResolved: true, |
| 30 | }; |
| 31 | |
| 32 | return [codeLens]; |
| 33 | } |
| 34 | } |