mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
* initial * cleanup * Add typings ref * fix compile * remove unused * add missing * another unused * Use newer vscodetestcover * newer dataprotocol * format * cleanup ignores * fix out path * fix entry point * more cleanup * Move into src folder * Handle service client log messages * remove unused
29 lines
1.4 KiB
TypeScript
29 lines
1.4 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
|
|
import { ICommandViewContext, ICommandObjectExplorerContext } from './command';
|
|
import * as constants from './constants';
|
|
import * as LocalizedConstants from './localizedConstants';
|
|
import { AppContext } from './appContext';
|
|
import { TreeNode } from './treeNodes';
|
|
import { MssqlExtensionApi } from './typings/mssqlapis';
|
|
|
|
|
|
export async function getNodeFromMssqlProvider<T extends TreeNode>(context: ICommandViewContext | ICommandObjectExplorerContext, appContext: AppContext): Promise<T> {
|
|
let node: T = undefined;
|
|
if (context && context.type === constants.ViewType && context.node) {
|
|
node = context.node as T;
|
|
} else if (context && context.type === constants.ObjectExplorerService) {
|
|
let extensionApi: MssqlExtensionApi = vscode.extensions.getExtension('Microsoft.mssql').exports;
|
|
let mssqlObjectExplorerBrowser = extensionApi.getMssqlObjectExplorerBrowser();
|
|
node = <T><any>await mssqlObjectExplorerBrowser.getNode(context.explorerContext);
|
|
} else {
|
|
throw new Error(LocalizedConstants.msgMissingNodeContext);
|
|
}
|
|
return node;
|
|
}
|