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

索引

Functions

Variables

Functions

getExtension

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

    Parameters

    • extensionId: string

      An extension identifier.

    Returns Extension<any> | undefined

    An extension or undefined.

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

    Type parameters

    • T

    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

Const all

all: readonly Extension<any>[]

All extensions currently known to the system.

Generated by TypeDoc