Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace 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));

Index

Functions(2)

Variables(1)

Functions(2)

getExtension

  • getExtension<T>(extensionId: string): Extension<T> | undefined
  • Get an extension by its full identifier in the form of: publisher.name.

    Type parameters

    • T = any

    Parameters

    • extensionId: string

      An extension identifier.

    Returns Extension<T> | undefined

    An extension or undefined.

Const onDidChange

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

    Parameters

    • listener: (e: void) => any
        • (e: void): any
        • Parameters

          • e: void

          Returns any

    • Optional thisArgs: any
    • Optional disposables: Disposable[]

    Returns Disposable

Variables(1)

Const all

all: readonly Extension<any>[]

All extensions currently known to the system.

Generated by TypeDoc. Maintained by 洛竹