mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
// The module 'vscode' contains the VS Code extensibility API
|
|
// Import the module and reference it with the alias vscode in your code below
|
|
import { ExtensionContext, languages, commands, Disposable, workspace, window, ConfigurationTarget } from 'vscode';
|
|
import { CodelensProvider } from './CodelensProvider';
|
|
|
|
// this method is called when your extension is activated
|
|
// your extension is activated the very first time the command is executed
|
|
|
|
var disposables: Disposable[] = [];
|
|
|
|
export function activate(context: ExtensionContext) {
|
|
let codelensProvider = new CodelensProvider();
|
|
|
|
languages.registerCodeLensProvider("*", codelensProvider);
|
|
|
|
commands.registerCommand("codelens-sample.enableCodeLens", () => {
|
|
workspace.getConfiguration("codelens-sample").update("enableCodeLens", true, true);
|
|
});
|
|
|
|
commands.registerCommand("codelens-sample.disableCodeLens", () => {
|
|
workspace.getConfiguration("codelens-sample").update("enableCodeLens", false, true);
|
|
});
|
|
|
|
commands.registerCommand("codelens-sample.codelensAction", (args) => {
|
|
window.showInformationMessage(`CodeLens action clicked with args=${args}`);
|
|
});
|
|
}
|
|
|
|
// this method is called when your extension is deactivated
|
|
export function deactivate() {
|
|
if (disposables) {
|
|
disposables.forEach(item => item.dispose());
|
|
}
|
|
disposables = [];
|
|
}
|