Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ExtensionManager

A class to manage the extension.

Yeah, yeah. It's another "Manager", but this is to be the only one.

This is the true "singleton" of the extension. It acts as the glue between the lower layers and the VSCode UX. When a user presses a button to necessitate user input, this class acts as intermediary and will send important information down to the lower layers.

Hierarchy

  • ExtensionManager

Implements

  • Disposable

Index

Constructors

constructor

  • new ExtensionManager(extensionContext: vscode.ExtensionContext): ExtensionManager

Properties

Private _activeWorkspaceFolder

_activeWorkspaceFolder: vscode.WorkspaceFolder | null = null

The active workspace folder. This controls several aspects of the extension, including:

  • Which CMakeTools backend receives commands from the user
  • Where we search for variants
  • Where we search for workspace-local kits

Private _buildTypeSub

_buildTypeSub: vscode.Disposable = new DummyDisposable()

Private _cmakeToolsInstances

_cmakeToolsInstances: Map<string, CMakeTools> = new Map()

The CMake Tools backend instances available in the extension. The reason for multiple is so that each workspace folder may have its own unique instance

Private _codeModelSub

_codeModelSub: vscode.Disposable = new DummyDisposable()

Private _configProvider

_configProvider: CppConfigurationProvider = new CppConfigurationProvider(this.extensionContext)

Private Optional _configProviderRegister

_configProviderRegister: Promise<void>

Private Optional _cppToolsAPI

_cppToolsAPI: cpt.CppToolsApi

Private _ctestEnabledSub

_ctestEnabledSub: vscode.Disposable = new DummyDisposable()

Private _editorWatcher

_editorWatcher: Disposable = vscode.workspace.onDidSaveTextDocument(doc => {if (doc.uri.fsPath === USER_KITS_FILEPATH) {rollbar.takePromise('Re-reading kits on text edit', {}, this._rereadKits());} else if (this._workspaceKitsPath && doc.uri.fsPath === this._workspaceKitsPath) {rollbar.takePromise('Re-reading kits on text edit', {}, this._rereadKits());} else {// Ignore}})

Watch for text edits. At the moment, this only watches for changes to the kits files, since the filesystem watcher in the _kitsWatcher is sometimes unreliable.

Private _isBusySub

_isBusySub: vscode.Disposable = new DummyDisposable()

Private _kitsWatcher

_kitsWatcher: MultiWatcher = new MultiWatcher(USER_KITS_FILEPATH)

Watches for changes to the kits file

Private _launchTargetSub

_launchTargetSub: vscode.Disposable = new DummyDisposable()

Private _projectOutlineDisposer

_projectOutlineDisposer: Disposable = vscode.window.registerTreeDataProvider('cmake.outline', this._projectOutlineProvider)

Private _projectOutlineProvider

_projectOutlineProvider: ProjectOutlineProvider = new ProjectOutlineProvider()

The tree data provider

Private _statusBar

_statusBar: StatusBar = new StatusBar()

The status bar controller

Private _statusMessageSub

_statusMessageSub: vscode.Disposable = new DummyDisposable()

Private _targetNameSub

_targetNameSub: vscode.Disposable = new DummyDisposable()

Private _testResultsSub

_testResultsSub: vscode.Disposable = new DummyDisposable()

Private _userKits

_userKits: Kit[] = []

The kits available from the user-local kits file

Private _workspaceFoldersChangedSub

_workspaceFoldersChangedSub: Disposable = vscode.workspace.onDidChangeWorkspaceFolders(e => rollbar.invokeAsync('Update workspace folders', () => this._onWorkspaceFoldersChanged(e)))

Subscription to workspace changes.

When a workspace is added or removed, the instances of CMakeTools are update to match the new state.

For each workspace folder, a separate instance of CMake Tools is maintained. This allows each folder to both share configuration as well as keep its own separately.

Private _wsKits

_wsKits: Kit[] = []

The kits available from the workspace kits file

Private _wsModStrand

_wsModStrand: Strand = new Strand()

Adding/removing workspaces should be serialized. Keep that work in a strand.

extensionContext

extensionContext: vscode.ExtensionContext

Accessors

Private _activeCMakeTools

  • The CMake Tools instance associated with the current workspace folder, or null if no folder is open.

    Returns CMakeTools | null

Private _allKits

  • get _allKits(): Kit[]

Private _workspaceKitsPath

  • get _workspaceKitsPath(): string | null
  • The path to the workspace-local kits file, dependent on the path to the active workspace folder.

    Returns string | null

Methods

Private _checkHaveKits

  • _checkHaveKits(): Promise<"use-unspec" | "ok" | "cancel">

Private _cmakeToolsForWorkspaceFolder

  • _cmakeToolsForWorkspaceFolder(ws: vscode.WorkspaceFolder): CMakeTools | null
  • Get the CMakeTools instance associated with the given workspace folder, or null

    Parameters

    • ws: vscode.WorkspaceFolder

      The workspace folder to search

    Returns CMakeTools | null

Private _createCMakeToolsForWorkspaceFolder

  • _createCMakeToolsForWorkspaceFolder(ws: vscode.WorkspaceFolder): Promise<CMakeTools>
  • Create a new CMakeTools instance for the given WorkspaceFolder

    Parameters

    • ws: vscode.WorkspaceFolder

      The workspace folder to create for

    Returns Promise<CMakeTools>

Private _disposeSubs

  • _disposeSubs(): void

_doRegisterCppTools

  • _doRegisterCppTools(): Promise<void>

Private _ensureActiveKit

  • _ensureActiveKit(cmt?: CMakeTools | null): Promise<boolean>
  • Ensure that there is an active kit for the current CMakeTools.

    Parameters

    Returns Promise<boolean>

    false if there is not active CMakeTools, or it has no active kit and the user cancelled the kit selection dialog.

Private _getMinGWDirs

  • _getMinGWDirs(): string[]
  • Get the current MinGW search directories

    Returns string[]

Private _keepKit

  • _keepKit(kit: Kit): Promise<undefined | false>
  • Mark a kit to be "kept". This set the keep value to true and writes re-writes the user kits file.

    Parameters

    • kit: Kit

      The kit to mark

    Returns Promise<undefined | false>

Private _loadCMakeToolsForWorkspaceFolder

  • _loadCMakeToolsForWorkspaceFolder(ws: vscode.WorkspaceFolder): Promise<CMakeTools>
  • Load a new CMakeTools for the given workspace folder and remember it.

    Parameters

    • ws: vscode.WorkspaceFolder

      The workspace folder to load for

    Returns Promise<CMakeTools>

Private _onWorkspaceFoldersChanged

  • _onWorkspaceFoldersChanged(e: vscode.WorkspaceFoldersChangeEvent): Promise<void>
  • Handle workspace change event.

    Parameters

    • e: vscode.WorkspaceFoldersChangeEvent

      Workspace change event

    Returns Promise<void>

_postWorkspaceOpen

  • _postWorkspaceOpen(ws: vscode.WorkspaceFolder, cmt: CMakeTools): Promise<void>

Private _removeKit

  • _removeKit(kit: Kit): Promise<undefined | false>
  • Remove a kit from the user-local kits.

    Parameters

    • kit: Kit

      The kit to remove

    Returns Promise<undefined | false>

Private _removeWorkspaceFolder

  • _removeWorkspaceFolder(ws: vscode.WorkspaceFolder): Thenable<void>
  • Remove knowledge of the given workspace folder. Disposes of the CMakeTools instance associated with the workspace.

    Parameters

    • ws: vscode.WorkspaceFolder

      The workspace to remove for

    Returns Thenable<void>

Private _rereadKits

  • Reload the list of available kits from the filesystem. This will also update the kit loaded into the current backend if applicable.

    Parameters

    Returns Promise<void>

Private _resetKitsWatcher

  • _resetKitsWatcher(): void
  • Drop the current kits watcher and create a new one.

    Returns void

Private _setActiveWorkspaceFolder

  • _setActiveWorkspaceFolder(ws: vscode.WorkspaceFolder | null, progress?: ProgressHandle): Promise<void>
  • Set the active workspace folder. This reloads a lot of different bits and pieces to control which backend has control and receives user input.

    Parameters

    • ws: vscode.WorkspaceFolder | null

      The workspace to activate

    • Optional progress: ProgressHandle

    Returns Promise<void>

_setCurrentKit

  • _setCurrentKit(k: Kit | null): Promise<void>
  • Set the current kit in the current CMake Tools instance

    Parameters

    • k: Kit | null

      The kit

    Returns Promise<void>

Private _setKnownKits

  • _setKnownKits(opts: object): Promise<void>
  • Set the kits that are available to the user. May change the active kit.

    Parameters

    • opts: object

      user for user local kits, workspace for workspace-local kits

      • user: Kit[]
      • workspace: Kit[]

    Returns Promise<void>

Private _setupSubscriptions

  • _setupSubscriptions(): void

Private _startPruneOutdatedKitsAsync

  • _startPruneOutdatedKitsAsync(): void
  • User-interactive kit pruning:

    This function will find all user-local kits that identify files that are no longer present (such as compiler binaries), and will show a popup notification to the user requesting an action.

    This function will not prune kits that have the keep field marked true

    If the user chooses to remove the kit, we call _removeKit() and erase it from the user-local file.

    If the user chooses to keep teh kit, we call _keepKit() and set the keep field on the kit to true.

    Always returns immediately.

    Returns void

Private _updateCodeModel

Private _writeUserKitsFile

  • _writeUserKitsFile(kits: Kit[]): Promise<undefined | false>
  • Write the given kits the the user-local cmake-kits.json file.

    Parameters

    • kits: Kit[]

      The kits to write to the file.

    Returns Promise<undefined | false>

addWorkspaceFolder

  • Create a new instance of the backend to support the given workspace folder. The given folder must not already be loaded.

    Parameters

    • ws: vscode.WorkspaceFolder

      The workspace folder to load for

    • Optional progress: ProgressHandle

    Returns Promise<CMakeTools>

    The newly created CMakeTools backend for the given folder

asyncDispose

  • asyncDispose(): Promise<void>
  • Asynchronously dispose of all the child objects.

    Returns Promise<void>

build

  • build(name?: undefined | string): Promise<number>
  • Parameters

    • Optional name: undefined | string

    Returns Promise<number>

buildWithTarget

  • buildWithTarget(): Promise<number>

clean

  • clean(): Promise<number>

cleanConfigure

  • cleanConfigure(): Promise<number>

cleanRebuild

  • cleanRebuild(): Promise<number>

compileFile

  • compileFile(file?: string | vscode.Uri): Promise<undefined | null | Terminal>
  • Compile a single source file.

    Parameters

    • Optional file: string | vscode.Uri

      The file to compile. Either a file path or the URI to the file. If not provided, compiles the file in the active text editor.

    Returns Promise<undefined | null | Terminal>

configure

  • configure(): Promise<number>

ctest

  • ctest(): Promise<number>

debugTarget

  • debugTarget(name?: undefined | string): Promise<null | DebugSession>
  • Parameters

    • Optional name: undefined | string

    Returns Promise<null | DebugSession>

dispose

  • dispose(): void
  • Dispose of the CMake Tools extension.

    If you can, prefer to call asyncDispose, which awaits on the children.

    Returns void

editCache

  • editCache(): Promise<undefined | void>

editKits

  • editKits(): Promise<vscode.TextEditor | null>
  • Opens a text editor with the user-local cmake-kits.json file.

    Returns Promise<vscode.TextEditor | null>

ensureCppToolsProviderRegistered

  • ensureCppToolsProviderRegistered(): Promise<void>

install

  • install(): Promise<number>

launchTarget

  • launchTarget(name?: undefined | string): Promise<null | Terminal>
  • Parameters

    • Optional name: undefined | string

    Returns Promise<null | Terminal>

launchTargetPath

  • launchTargetPath(): Promise<null | string>

quickStart

  • quickStart(): Promise<Number>

resetState

  • resetState(): Promise<null | void>

scanForKits

  • scanForKits(): Promise<void>
  • Rescan the system for kits and save them to the user-local kits file

    Returns Promise<void>

selectKit

  • selectKit(): Promise<boolean>
  • Show UI to allow the user to select an active kit

    Returns Promise<boolean>

selectLaunchTarget

  • selectLaunchTarget(name?: undefined | string): Promise<null | string>
  • Parameters

    • Optional name: undefined | string

    Returns Promise<null | string>

setDefaultTarget

  • setDefaultTarget(name?: undefined | string): Promise<undefined | void>
  • Parameters

    • Optional name: undefined | string

    Returns Promise<undefined | void>

setVariant

  • setVariant(): Promise<boolean>

stop

  • stop(): Promise<boolean>

viewLog

  • viewLog(): Promise<null | void>

withCMakeTools

  • withCMakeTools<Ret>(default_: Ret, fn: function): Promise<Ret>
  • Wraps an operation that requires an open workspace and kit selection. If there is no active CMakeTools (no open workspace) or if the user cancels kit selection, we return the given default value.

    Type parameters

    • Ret

    Parameters

    • default_: Ret

      The default return value

    • fn: function

      The callback

    Returns Promise<Ret>

Generated using TypeDoc