Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ExtensionContext

An extension context is a collection of utilities private to an extension.

An instance of an ExtensionContext is provided as the first parameter to the activate-call of an extension.

Hierarchy

  • ExtensionContext

Index

Properties(15)

Readonly subscriptions

subscriptions: { dispose: any }[]

An array to which disposables can be added. When this extension is deactivated the disposables will be disposed.

Note that asynchronous dispose-functions aren't awaited.

Readonly workspaceState

workspaceState: Memento

A memento object that stores state in the context of the currently opened workspace.

Readonly globalState

globalState: Memento & { setKeysForSync: any }

A memento object that stores state independent of the current opened workspace.

Readonly secrets

secrets: SecretStorage

A storage utility for secrets. Secrets are persisted across reloads and are independent of the current opened workspace.

Readonly extensionUri

extensionUri: Uri

The uri of the directory containing the extension.

Readonly extensionPath

extensionPath: string

The absolute file path of the directory containing the extension. Shorthand notation for ExtensionContext.extensionUri.fsPath (independent of the uri scheme).

Readonly environmentVariableCollection

environmentVariableCollection: EnvironmentVariableCollection

Gets the extension's environment variable collection for this workspace, enabling changes to be applied to terminal environment variables.

Readonly storageUri

storageUri: undefined | Uri

The uri of a workspace specific directory in which the extension can store private state. The directory might not exist and creation is up to the extension. However, the parent directory is guaranteed to be existent. The value is undefined when no workspace nor folder has been opened.

Use workspaceState or globalState to store key value data.

see

workspace.fs for how to read and write files and folders from an uri.

Readonly storagePath

storagePath: undefined | string

An absolute file path of a workspace specific directory in which the extension can store private state. The directory might not exist on disk and creation is up to the extension. However, the parent directory is guaranteed to be existent.

Use workspaceState or globalState to store key value data.

deprecated

Use storageUri instead.

Readonly globalStorageUri

globalStorageUri: Uri

The uri of a directory in which the extension can store global state. The directory might not exist on disk and creation is up to the extension. However, the parent directory is guaranteed to be existent.

Use globalState to store key value data.

see

workspace.fs for how to read and write files and folders from an uri.

Readonly globalStoragePath

globalStoragePath: string

An absolute file path in which the extension can store global state. The directory might not exist on disk and creation is up to the extension. However, the parent directory is guaranteed to be existent.

Use globalState to store key value data.

deprecated

Use globalStorageUri instead.

Readonly logUri

logUri: Uri

The uri of a directory in which the extension can create log files. The directory might not exist on disk and creation is up to the extension. However, the parent directory is guaranteed to be existent.

see

workspace.fs for how to read and write files and folders from an uri.

Readonly logPath

logPath: string

An absolute file path of a directory in which the extension can create log files. The directory might not exist on disk and creation is up to the extension. However, the parent directory is guaranteed to be existent.

deprecated

Use logUri instead.

Readonly extensionMode

extensionMode: ExtensionMode

The mode the extension is running in. This is specific to the current extension. One extension may be in ExtensionMode.Development while other extensions in the host run in ExtensionMode.Release.

Readonly extension

extension: Extension<any>

The current Extension instance.

Methods(1)

asAbsolutePath

  • asAbsolutePath(relativePath: string): string
  • Get the absolute path of a resource contained in the extension.

    Note that an absolute uri can be constructed via Uri.joinPath and extensionUri, e.g. vscode.Uri.joinPath(context.extensionUri, relativePath);

    Parameters

    • relativePath: string

      A relative path to a resource contained in the extension.

    Returns string

    The absolute path of the resource.

Generated by TypeDoc. Maintained by 洛竹