Options
All
  • Public
  • Public/Protected
  • All
Menu

用于处理已安装扩展的命名空间。扩展由一个可以映射它们的接口 Extension 表示。

通过在 activate 方法中返回它们的公共 API 给其他扩展,扩展开发者可以给其他扩展提供 API。

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

当依赖于另一个扩展的 API 时,将 依赖的扩展 添加到 package.json,然后使用 getExtension 方法 和 exports 来获取,如下:

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

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

@pan463859

索引

Functions(2)

Variables(1)

Functions(2)

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(1)

Const all

all: readonly Extension<any>[]

All extensions currently known to the system.

友链:VS Code 中文文档 | VS Code 官网文档 | VS Code 扩展市场

Generated by TypeDoc. Maintained by 洛竹