extensions

Namespace for dealing with installed extensions. Extensions are represented by an Extension-interface which enables reflection on them.

Extension writers can provide APIs to other extensions by returning their API public surface from the activate-call.

export function activate(context: vscode.ExtensionContext) {
	let api = {
		sum(a, b) {
			return a + b;
		},
		mul(a, b) {
			return a * b;
		}
	};
	// 'export' public api-surface
	return api;
}

When depending on the API of another extension add an extensionDependencies-entry to package.json, and use the getExtension-function and the exports-property, like below:

let mathExt = extensions.getExtension('genius.math');
let importedApi = mathExt.exports;

console.log(importedApi.mul(42, 1));

Online Documentation

Properties

Link copied to clipboard

All extensions currently known to the system.

Link copied to clipboard

An event which fires when extensions.all changes. This can happen when extensions are installed, uninstalled, enabled or disabled.

Functions

Link copied to clipboard
fun <T : JsAny?> getExtension(extensionId: String): Extension<T>?

Get an extension by its full identifier in the form of: publisher.name.