mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Integrate into vscode node module factory workflow (#6685)
* integrate into vscode node module factory workflow * add missing file * fix compile errors * fix compile errors * change uppercase * fix compile
This commit is contained in:
@@ -3,9 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as extHostApi from 'vs/workbench/api/common/extHost.api.impl';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -28,35 +25,422 @@ import { ExtHostQueryEditor } from 'sql/workbench/api/common/extHostQueryEditor'
|
||||
import { ExtHostBackgroundTaskManagement } from 'sql/workbench/api/common/extHostBackgroundTaskManagement';
|
||||
import { ExtHostNotebook } from 'sql/workbench/api/common/extHostNotebook';
|
||||
import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/common/extHostNotebookDocumentsAndEditors';
|
||||
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/common/extensionDescriptionRegistry';
|
||||
import { ExtHostExtensionManagement } from 'sql/workbench/api/common/extHostExtensionManagement';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { ExtHostConfigProvider, IExtHostConfiguration } from 'vs/workbench/api/common/extHostConfiguration';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
export interface ISqlExtensionApiFactory {
|
||||
vsCodeFactory(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
|
||||
sqlopsFactory(extension: IExtensionDescription): typeof sqlops;
|
||||
azdataFactory(extension: IExtensionDescription): typeof azdata;
|
||||
export interface ISqlopsExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof sqlops;
|
||||
}
|
||||
|
||||
export interface IAzdataExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof azdata;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method instantiates and returns the extension API surface
|
||||
*/
|
||||
export function createSqlopsApiFactory(accessor: ServicesAccessor): ISqlopsExtensionApiFactory {
|
||||
const uriTransformer = accessor.get(IURITransformerService);
|
||||
const rpcProtocol = accessor.get(IExtHostRpcService);
|
||||
const extHostLogService = accessor.get(ILogService);
|
||||
|
||||
// Addressable instances
|
||||
const extHostConnectionManagement = rpcProtocol.set(SqlExtHostContext.ExtHostConnectionManagement, new ExtHostConnectionManagement(rpcProtocol));
|
||||
const extHostCredentialManagement = rpcProtocol.set(SqlExtHostContext.ExtHostCredentialManagement, new ExtHostCredentialManagement(rpcProtocol));
|
||||
const extHostDataProvider = rpcProtocol.set(SqlExtHostContext.ExtHostDataProtocol, new ExtHostDataProtocol(rpcProtocol, uriTransformer));
|
||||
const extHostObjectExplorer = rpcProtocol.set(SqlExtHostContext.ExtHostObjectExplorer, new ExtHostObjectExplorer(rpcProtocol));
|
||||
const extHostModalDialogs = rpcProtocol.set(SqlExtHostContext.ExtHostModalDialogs, new ExtHostModalDialogs(rpcProtocol));
|
||||
const extHostTasks = rpcProtocol.set(SqlExtHostContext.ExtHostTasks, new ExtHostTasks(rpcProtocol, extHostLogService));
|
||||
const extHostBackgroundTaskManagement = rpcProtocol.set(SqlExtHostContext.ExtHostBackgroundTaskManagement, new ExtHostBackgroundTaskManagement(rpcProtocol));
|
||||
const extHostWebviewWidgets = rpcProtocol.set(SqlExtHostContext.ExtHostDashboardWebviews, new ExtHostDashboardWebviews(rpcProtocol));
|
||||
const extHostModelViewTree = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewTreeViews, new ExtHostModelViewTreeViews(rpcProtocol));
|
||||
const extHostModelView = rpcProtocol.set(SqlExtHostContext.ExtHostModelView, new ExtHostModelView(rpcProtocol, extHostModelViewTree));
|
||||
const extHostDashboard = rpcProtocol.set(SqlExtHostContext.ExtHostDashboard, new ExtHostDashboard(rpcProtocol));
|
||||
const extHostModelViewDialog = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewDialog, new ExtHostModelViewDialog(rpcProtocol, extHostModelView, extHostBackgroundTaskManagement));
|
||||
const extHostQueryEditor = rpcProtocol.set(SqlExtHostContext.ExtHostQueryEditor, new ExtHostQueryEditor(rpcProtocol));
|
||||
const extHostExtensionManagement = rpcProtocol.set(SqlExtHostContext.ExtHostExtensionManagement, new ExtHostExtensionManagement(rpcProtocol));
|
||||
|
||||
return function (extension: IExtensionDescription): typeof sqlops {
|
||||
|
||||
extHostExtensionManagement.$showObsoleteExtensionApiUsageNotification(localize('ObsoleteApiModuleMessage', "The extension \"{0}\" is using sqlops module which has been replaced by azdata module, the sqlops module will be removed in a future release.", extension.identifier.value));
|
||||
// namespace: connection
|
||||
const connection: typeof sqlops.connection = {
|
||||
getActiveConnections(): Thenable<sqlops.connection.Connection[]> {
|
||||
return extHostConnectionManagement.$getActiveConnections();
|
||||
},
|
||||
getCurrentConnection(): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$getSqlOpsCurrentConnection();
|
||||
},
|
||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||
},
|
||||
getServerInfo(connectionId: string): Thenable<sqlops.ServerInfo> {
|
||||
return extHostConnectionManagement.$getServerInfo(connectionId);
|
||||
},
|
||||
openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||
},
|
||||
listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||
},
|
||||
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||
return extHostConnectionManagement.$getConnectionString(connectionId, includePassword);
|
||||
},
|
||||
getUriForConnection(connectionId: string): Thenable<string> {
|
||||
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
||||
},
|
||||
connect(connectionProfile: sqlops.IConnectionProfile, saveConnection: boolean, showDashboard: boolean): Thenable<sqlops.ConnectionResult> {
|
||||
return extHostConnectionManagement.$connect(connectionProfile, saveConnection, showDashboard);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: credentials
|
||||
const credentials: typeof sqlops.credentials = {
|
||||
registerProvider(provider: sqlops.CredentialProvider): vscode.Disposable {
|
||||
return extHostCredentialManagement.$registerCredentialProvider(provider);
|
||||
},
|
||||
getProvider(namespaceId: string): Thenable<sqlops.CredentialProvider> {
|
||||
return extHostCredentialManagement.$getCredentialProvider(namespaceId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: objectexplorer
|
||||
const objectExplorer: typeof sqlops.objectexplorer = {
|
||||
getNode(connectionId: string, nodePath?: string): Thenable<sqlops.objectexplorer.ObjectExplorerNode> {
|
||||
return extHostObjectExplorer.$getNode(connectionId, nodePath);
|
||||
},
|
||||
getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$getActiveConnectionNodes();
|
||||
},
|
||||
findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$findNodes(connectionId, type, schema, name, database, parentObjectNames);
|
||||
},
|
||||
getNodeActions(connectionId: string, nodePath: string): Thenable<string[]> {
|
||||
return extHostObjectExplorer.$getNodeActions(connectionId, nodePath);
|
||||
},
|
||||
getSessionConnectionProfile(sessionId: string): Thenable<sqlops.IConnectionProfile> {
|
||||
return extHostObjectExplorer.$getSessionConnectionProfile(sessionId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: serialization
|
||||
const serialization: typeof sqlops.serialization = {
|
||||
registerProvider(provider: sqlops.SerializationProvider): vscode.Disposable {
|
||||
// No-op this to avoid breaks in existing applications. Tested on Github - no examples,
|
||||
// but I think it's safer to avoid breaking this
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
let registerConnectionProvider = (provider: sqlops.ConnectionProvider): vscode.Disposable => {
|
||||
// Connection callbacks
|
||||
provider.registerOnConnectionComplete((connSummary: sqlops.ConnectionInfoSummary) => {
|
||||
extHostDataProvider.$onConnectComplete(provider.handle, connSummary);
|
||||
});
|
||||
|
||||
provider.registerOnIntelliSenseCacheComplete((connectionUri: string) => {
|
||||
extHostDataProvider.$onIntelliSenseCacheComplete(provider.handle, connectionUri);
|
||||
});
|
||||
|
||||
provider.registerOnConnectionChanged((changedConnInfo: sqlops.ChangedConnectionInfo) => {
|
||||
extHostDataProvider.$onConnectionChanged(provider.handle, changedConnInfo);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerConnectionProvider(provider);
|
||||
};
|
||||
|
||||
let registerQueryProvider = (provider: sqlops.QueryProvider): vscode.Disposable => {
|
||||
provider.registerOnQueryComplete((result: sqlops.QueryExecuteCompleteNotificationResult) => {
|
||||
extHostDataProvider.$onQueryComplete(provider.handle, result);
|
||||
});
|
||||
|
||||
provider.registerOnBatchStart((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchStart(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnBatchComplete((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchComplete(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetAvailable((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetAvailable(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetUpdated((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetUpdated(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnMessage((message: sqlops.QueryExecuteMessageParams) => {
|
||||
extHostDataProvider.$onQueryMessage(provider.handle, message);
|
||||
});
|
||||
|
||||
provider.registerOnEditSessionReady((ownerUri: string, success: boolean, message: string) => {
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerQueryProvider(<azdata.QueryProvider>provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerProvider = (provider: sqlops.ObjectExplorerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionCreated((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
if (provider.registerOnSessionDisconnected) {
|
||||
provider.registerOnSessionDisconnected((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionDisconnected(provider.handle, response);
|
||||
});
|
||||
}
|
||||
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerProvider(provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerNodeProvider = (provider: sqlops.ObjectExplorerNodeProvider): vscode.Disposable => {
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerNodeProvider(provider);
|
||||
};
|
||||
|
||||
let registerTaskServicesProvider = (provider: sqlops.TaskServicesProvider): vscode.Disposable => {
|
||||
provider.registerOnTaskCreated((response: sqlops.TaskInfo) => {
|
||||
extHostDataProvider.$onTaskCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnTaskStatusChanged((response: sqlops.TaskProgressInfo) => {
|
||||
extHostDataProvider.$onTaskStatusChanged(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerTaskServicesProvider(provider);
|
||||
};
|
||||
|
||||
let registerFileBrowserProvider = (provider: sqlops.FileBrowserProvider): vscode.Disposable => {
|
||||
provider.registerOnFileBrowserOpened((response: sqlops.FileBrowserOpenedParams) => {
|
||||
extHostDataProvider.$onFileBrowserOpened(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFolderNodeExpanded((response: sqlops.FileBrowserExpandedParams) => {
|
||||
extHostDataProvider.$onFolderNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFilePathsValidated((response: sqlops.FileBrowserValidatedParams) => {
|
||||
extHostDataProvider.$onFilePathsValidated(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerFileBrowserProvider(provider);
|
||||
};
|
||||
|
||||
let registerScriptingProvider = (provider: sqlops.ScriptingProvider): vscode.Disposable => {
|
||||
provider.registerOnScriptingComplete((response: sqlops.ScriptingCompleteResult) => {
|
||||
extHostDataProvider.$onScriptingComplete(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerScriptingProvider(provider);
|
||||
};
|
||||
|
||||
let registerMetadataProvider = (provider: sqlops.MetadataProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerMetadataProvider(provider);
|
||||
};
|
||||
|
||||
let registerCapabilitiesServiceProvider = (provider: sqlops.CapabilitiesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerCapabilitiesServiceProvider(provider);
|
||||
};
|
||||
|
||||
let registerAdminServicesProvider = (provider: sqlops.AdminServicesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerAdminServicesProvider(provider);
|
||||
};
|
||||
|
||||
|
||||
// namespace: dataprotocol
|
||||
const dataprotocol: typeof sqlops.dataprotocol = {
|
||||
registerConnectionProvider,
|
||||
registerFileBrowserProvider,
|
||||
registerMetadataProvider,
|
||||
registerObjectExplorerProvider,
|
||||
registerObjectExplorerNodeProvider,
|
||||
registerScriptingProvider,
|
||||
registerTaskServicesProvider,
|
||||
registerQueryProvider,
|
||||
registerAdminServicesProvider,
|
||||
registerCapabilitiesServiceProvider,
|
||||
onDidChangeLanguageFlavor(listener: (e: sqlops.DidChangeLanguageFlavorParams) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostDataProvider.onDidChangeLanguageFlavor(listener, thisArgs, disposables);
|
||||
},
|
||||
getProvider<T extends sqlops.DataProvider>(providerId: string, providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvider<T>(providerId, providerType);
|
||||
},
|
||||
getProvidersByType<T extends sqlops.DataProvider>(providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvidersByType<T>(providerType);
|
||||
}
|
||||
};
|
||||
|
||||
const modelViewDialog: typeof sqlops.window.modelviewdialog = {
|
||||
createDialog(title: string, dialogName?: string): sqlops.window.modelviewdialog.Dialog {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createDialog has been deprecated, replace it with azdata.window.createModelViewDialog');
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.modelviewdialog.DialogTab {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createTab has been deprecated, replace it with azdata.window.createTab');
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.modelviewdialog.Button {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createButton has been deprecated, replace it with azdata.window.createButton');
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.openDialog has been deprecated, replace it with azdata.window.openDialog');
|
||||
return extHostModelViewDialog.openDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.closeDialog has been deprecated, replace it with azdata.window.closeDialog');
|
||||
return extHostModelViewDialog.closeDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.modelviewdialog.WizardPage {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizardPage has been deprecated, replace it with azdata.window.createWizardPage');
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.modelviewdialog.Wizard {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizard has been deprecated, replace it with azdata.window.createWizard');
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const window: typeof sqlops.window = {
|
||||
createDialog(name: string) {
|
||||
console.warn('the method sqlops.window.createDialog has been deprecated, replace it with azdata.window.createWebViewDialog');
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
modelviewdialog: modelViewDialog,
|
||||
createWebViewDialog(name: string) {
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
createModelViewDialog(title: string, dialogName?: string): sqlops.window.Dialog {
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.DialogTab {
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.Button {
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.openDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.closeDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.WizardPage {
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.Wizard {
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const tasks: typeof sqlops.tasks = {
|
||||
registerTask(id: string, task: (...args: any[]) => any, thisArgs?: any): vscode.Disposable {
|
||||
return extHostTasks.registerTask(id, task, thisArgs);
|
||||
},
|
||||
startBackgroundOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
|
||||
extHostBackgroundTaskManagement.$registerTask(operationInfo);
|
||||
}
|
||||
};
|
||||
|
||||
const workspace: typeof sqlops.workspace = {
|
||||
onDidOpenDashboard: extHostDashboard.onDidOpenDashboard,
|
||||
onDidChangeToDashboard: extHostDashboard.onDidChangeToDashboard,
|
||||
createModelViewEditor(title: string, options?: sqlops.ModelViewEditorOptions): sqlops.workspace.ModelViewEditor {
|
||||
return extHostModelViewDialog.createModelViewEditor(title, extension, options);
|
||||
}
|
||||
};
|
||||
|
||||
const dashboard = {
|
||||
registerWebviewProvider(widgetId: string, handler: (webview: sqlops.DashboardWebview) => void) {
|
||||
extHostWebviewWidgets.$registerProvider(widgetId, handler);
|
||||
}
|
||||
};
|
||||
|
||||
const ui = {
|
||||
registerModelViewProvider(modelViewId: string, handler: (view: sqlops.ModelView) => void): void {
|
||||
extHostModelView.$registerProvider(modelViewId, handler, extension);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: queryeditor
|
||||
const queryEditor: typeof sqlops.queryeditor = {
|
||||
|
||||
connect(fileUri: string, connectionId: string): Thenable<void> {
|
||||
return extHostQueryEditor.$connect(fileUri, connectionId);
|
||||
},
|
||||
|
||||
runQuery(fileUri: string): void {
|
||||
extHostQueryEditor.$runQuery(fileUri);
|
||||
}
|
||||
};
|
||||
|
||||
const extensions: typeof sqlops.extensions = {
|
||||
install(vsixPath: string): Thenable<string> {
|
||||
return extHostExtensionManagement.$install(vsixPath);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
connection,
|
||||
credentials,
|
||||
objectexplorer: objectExplorer,
|
||||
serialization,
|
||||
dataprotocol,
|
||||
DataProviderType: sqlExtHostTypes.DataProviderType,
|
||||
DeclarativeDataType: sqlExtHostTypes.DeclarativeDataType,
|
||||
ServiceOptionType: sqlExtHostTypes.ServiceOptionType,
|
||||
ConnectionOptionSpecialType: sqlExtHostTypes.ConnectionOptionSpecialType,
|
||||
EditRowState: sqlExtHostTypes.EditRowState,
|
||||
MetadataType: sqlExtHostTypes.MetadataType,
|
||||
TaskStatus: sqlExtHostTypes.TaskStatus,
|
||||
TaskExecutionMode: sqlExtHostTypes.TaskExecutionMode,
|
||||
ScriptOperation: sqlExtHostTypes.ScriptOperation,
|
||||
window,
|
||||
tasks,
|
||||
dashboard,
|
||||
workspace,
|
||||
queryeditor: queryEditor,
|
||||
ui: ui,
|
||||
StatusIndicator: sqlExtHostTypes.StatusIndicator,
|
||||
CardType: sqlExtHostTypes.CardType,
|
||||
Orientation: sqlExtHostTypes.Orientation,
|
||||
SqlThemeIcon: sqlExtHostTypes.SqlThemeIcon,
|
||||
TreeComponentItem: sqlExtHostTypes.TreeComponentItem,
|
||||
AzureResource: sqlExtHostTypes.AzureResource,
|
||||
extensions: extensions,
|
||||
TreeItem: sqlExtHostTypes.TreeItem
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This method instantiates and returns the extension API surface
|
||||
*/
|
||||
export function createApiFactory(accessor: ServicesAccessor): ISqlExtensionApiFactory {
|
||||
const instaServer = accessor.get(IInstantiationService);
|
||||
export function createAzdataApiFactory(accessor: ServicesAccessor): IAzdataExtensionApiFactory {
|
||||
|
||||
const uriTransformer = accessor.get(IURITransformerService);
|
||||
const rpcProtocol = accessor.get(IExtHostRpcService);
|
||||
const extHostLogService = accessor.get(ILogService);
|
||||
let vsCodeFactory = instaServer.invokeFunction(extHostApi.createApiFactoryAndRegisterActors);
|
||||
|
||||
// Addressable instances
|
||||
const extHostAccountManagement = rpcProtocol.set(SqlExtHostContext.ExtHostAccountManagement, new ExtHostAccountManagement(rpcProtocol));
|
||||
@@ -79,9 +463,7 @@ export function createApiFactory(accessor: ServicesAccessor): ISqlExtensionApiFa
|
||||
const extHostExtensionManagement = rpcProtocol.set(SqlExtHostContext.ExtHostExtensionManagement, new ExtHostExtensionManagement(rpcProtocol));
|
||||
|
||||
|
||||
return {
|
||||
vsCodeFactory: vsCodeFactory,
|
||||
azdataFactory: function (extension: IExtensionDescription): typeof azdata {
|
||||
return function (extension: IExtensionDescription): typeof azdata {
|
||||
// namespace: connection
|
||||
const connection: typeof azdata.connection = {
|
||||
// "azdata" API definition
|
||||
@@ -550,459 +932,5 @@ export function createApiFactory(accessor: ServicesAccessor): ISqlExtensionApiFa
|
||||
ExtensionNodeType: sqlExtHostTypes.ExtensionNodeType,
|
||||
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode
|
||||
};
|
||||
},
|
||||
|
||||
// "sqlops" namespace provided for back-compat only, add new interfaces to "azdata"
|
||||
sqlopsFactory: function (extension: IExtensionDescription): typeof sqlops {
|
||||
|
||||
extHostExtensionManagement.$showObsoleteExtensionApiUsageNotification(localize('ObsoleteApiModuleMessage', "The extension \"{0}\" is using sqlops module which has been replaced by azdata module, the sqlops module will be removed in a future release.", extension.identifier.value));
|
||||
// namespace: connection
|
||||
const connection: typeof sqlops.connection = {
|
||||
getActiveConnections(): Thenable<sqlops.connection.Connection[]> {
|
||||
return extHostConnectionManagement.$getActiveConnections();
|
||||
},
|
||||
getCurrentConnection(): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$getSqlOpsCurrentConnection();
|
||||
},
|
||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||
},
|
||||
getServerInfo(connectionId: string): Thenable<sqlops.ServerInfo> {
|
||||
return extHostConnectionManagement.$getServerInfo(connectionId);
|
||||
},
|
||||
openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||
},
|
||||
listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||
},
|
||||
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||
return extHostConnectionManagement.$getConnectionString(connectionId, includePassword);
|
||||
},
|
||||
getUriForConnection(connectionId: string): Thenable<string> {
|
||||
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
||||
},
|
||||
connect(connectionProfile: sqlops.IConnectionProfile, saveConnection: boolean, showDashboard: boolean): Thenable<sqlops.ConnectionResult> {
|
||||
return extHostConnectionManagement.$connect(connectionProfile, saveConnection, showDashboard);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: credentials
|
||||
const credentials: typeof sqlops.credentials = {
|
||||
registerProvider(provider: sqlops.CredentialProvider): vscode.Disposable {
|
||||
return extHostCredentialManagement.$registerCredentialProvider(provider);
|
||||
},
|
||||
getProvider(namespaceId: string): Thenable<sqlops.CredentialProvider> {
|
||||
return extHostCredentialManagement.$getCredentialProvider(namespaceId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: objectexplorer
|
||||
const objectExplorer: typeof sqlops.objectexplorer = {
|
||||
getNode(connectionId: string, nodePath?: string): Thenable<sqlops.objectexplorer.ObjectExplorerNode> {
|
||||
return extHostObjectExplorer.$getNode(connectionId, nodePath);
|
||||
},
|
||||
getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$getActiveConnectionNodes();
|
||||
},
|
||||
findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$findNodes(connectionId, type, schema, name, database, parentObjectNames);
|
||||
},
|
||||
getNodeActions(connectionId: string, nodePath: string): Thenable<string[]> {
|
||||
return extHostObjectExplorer.$getNodeActions(connectionId, nodePath);
|
||||
},
|
||||
getSessionConnectionProfile(sessionId: string): Thenable<sqlops.IConnectionProfile> {
|
||||
return extHostObjectExplorer.$getSessionConnectionProfile(sessionId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: serialization
|
||||
const serialization: typeof sqlops.serialization = {
|
||||
registerProvider(provider: sqlops.SerializationProvider): vscode.Disposable {
|
||||
// No-op this to avoid breaks in existing applications. Tested on Github - no examples,
|
||||
// but I think it's safer to avoid breaking this
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
let registerConnectionProvider = (provider: sqlops.ConnectionProvider): vscode.Disposable => {
|
||||
// Connection callbacks
|
||||
provider.registerOnConnectionComplete((connSummary: sqlops.ConnectionInfoSummary) => {
|
||||
extHostDataProvider.$onConnectComplete(provider.handle, connSummary);
|
||||
});
|
||||
|
||||
provider.registerOnIntelliSenseCacheComplete((connectionUri: string) => {
|
||||
extHostDataProvider.$onIntelliSenseCacheComplete(provider.handle, connectionUri);
|
||||
});
|
||||
|
||||
provider.registerOnConnectionChanged((changedConnInfo: sqlops.ChangedConnectionInfo) => {
|
||||
extHostDataProvider.$onConnectionChanged(provider.handle, changedConnInfo);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerConnectionProvider(provider);
|
||||
};
|
||||
|
||||
let registerQueryProvider = (provider: sqlops.QueryProvider): vscode.Disposable => {
|
||||
provider.registerOnQueryComplete((result: sqlops.QueryExecuteCompleteNotificationResult) => {
|
||||
extHostDataProvider.$onQueryComplete(provider.handle, result);
|
||||
});
|
||||
|
||||
provider.registerOnBatchStart((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchStart(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnBatchComplete((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchComplete(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetAvailable((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetAvailable(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetUpdated((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetUpdated(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnMessage((message: sqlops.QueryExecuteMessageParams) => {
|
||||
extHostDataProvider.$onQueryMessage(provider.handle, message);
|
||||
});
|
||||
|
||||
provider.registerOnEditSessionReady((ownerUri: string, success: boolean, message: string) => {
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerQueryProvider(<azdata.QueryProvider>provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerProvider = (provider: sqlops.ObjectExplorerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionCreated((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
if (provider.registerOnSessionDisconnected) {
|
||||
provider.registerOnSessionDisconnected((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionDisconnected(provider.handle, response);
|
||||
});
|
||||
}
|
||||
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerProvider(provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerNodeProvider = (provider: sqlops.ObjectExplorerNodeProvider): vscode.Disposable => {
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerNodeProvider(provider);
|
||||
};
|
||||
|
||||
let registerTaskServicesProvider = (provider: sqlops.TaskServicesProvider): vscode.Disposable => {
|
||||
provider.registerOnTaskCreated((response: sqlops.TaskInfo) => {
|
||||
extHostDataProvider.$onTaskCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnTaskStatusChanged((response: sqlops.TaskProgressInfo) => {
|
||||
extHostDataProvider.$onTaskStatusChanged(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerTaskServicesProvider(provider);
|
||||
};
|
||||
|
||||
let registerFileBrowserProvider = (provider: sqlops.FileBrowserProvider): vscode.Disposable => {
|
||||
provider.registerOnFileBrowserOpened((response: sqlops.FileBrowserOpenedParams) => {
|
||||
extHostDataProvider.$onFileBrowserOpened(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFolderNodeExpanded((response: sqlops.FileBrowserExpandedParams) => {
|
||||
extHostDataProvider.$onFolderNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFilePathsValidated((response: sqlops.FileBrowserValidatedParams) => {
|
||||
extHostDataProvider.$onFilePathsValidated(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerFileBrowserProvider(provider);
|
||||
};
|
||||
|
||||
let registerScriptingProvider = (provider: sqlops.ScriptingProvider): vscode.Disposable => {
|
||||
provider.registerOnScriptingComplete((response: sqlops.ScriptingCompleteResult) => {
|
||||
extHostDataProvider.$onScriptingComplete(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerScriptingProvider(provider);
|
||||
};
|
||||
|
||||
let registerMetadataProvider = (provider: sqlops.MetadataProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerMetadataProvider(provider);
|
||||
};
|
||||
|
||||
let registerCapabilitiesServiceProvider = (provider: sqlops.CapabilitiesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerCapabilitiesServiceProvider(provider);
|
||||
};
|
||||
|
||||
let registerAdminServicesProvider = (provider: sqlops.AdminServicesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerAdminServicesProvider(provider);
|
||||
};
|
||||
|
||||
|
||||
// namespace: dataprotocol
|
||||
const dataprotocol: typeof sqlops.dataprotocol = {
|
||||
registerConnectionProvider,
|
||||
registerFileBrowserProvider,
|
||||
registerMetadataProvider,
|
||||
registerObjectExplorerProvider,
|
||||
registerObjectExplorerNodeProvider,
|
||||
registerScriptingProvider,
|
||||
registerTaskServicesProvider,
|
||||
registerQueryProvider,
|
||||
registerAdminServicesProvider,
|
||||
registerCapabilitiesServiceProvider,
|
||||
onDidChangeLanguageFlavor(listener: (e: sqlops.DidChangeLanguageFlavorParams) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostDataProvider.onDidChangeLanguageFlavor(listener, thisArgs, disposables);
|
||||
},
|
||||
getProvider<T extends sqlops.DataProvider>(providerId: string, providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvider<T>(providerId, providerType);
|
||||
},
|
||||
getProvidersByType<T extends sqlops.DataProvider>(providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvidersByType<T>(providerType);
|
||||
}
|
||||
};
|
||||
|
||||
const modelViewDialog: typeof sqlops.window.modelviewdialog = {
|
||||
createDialog(title: string, dialogName?: string): sqlops.window.modelviewdialog.Dialog {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createDialog has been deprecated, replace it with azdata.window.createModelViewDialog');
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.modelviewdialog.DialogTab {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createTab has been deprecated, replace it with azdata.window.createTab');
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.modelviewdialog.Button {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createButton has been deprecated, replace it with azdata.window.createButton');
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.openDialog has been deprecated, replace it with azdata.window.openDialog');
|
||||
return extHostModelViewDialog.openDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.closeDialog has been deprecated, replace it with azdata.window.closeDialog');
|
||||
return extHostModelViewDialog.closeDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.modelviewdialog.WizardPage {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizardPage has been deprecated, replace it with azdata.window.createWizardPage');
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.modelviewdialog.Wizard {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizard has been deprecated, replace it with azdata.window.createWizard');
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const window: typeof sqlops.window = {
|
||||
createDialog(name: string) {
|
||||
console.warn('the method sqlops.window.createDialog has been deprecated, replace it with azdata.window.createWebViewDialog');
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
modelviewdialog: modelViewDialog,
|
||||
createWebViewDialog(name: string) {
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
createModelViewDialog(title: string, dialogName?: string): sqlops.window.Dialog {
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.DialogTab {
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.Button {
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.openDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.closeDialog(dialog as azdata.window.Dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.WizardPage {
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.Wizard {
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const tasks: typeof sqlops.tasks = {
|
||||
registerTask(id: string, task: (...args: any[]) => any, thisArgs?: any): vscode.Disposable {
|
||||
return extHostTasks.registerTask(id, task, thisArgs);
|
||||
},
|
||||
startBackgroundOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
|
||||
extHostBackgroundTaskManagement.$registerTask(operationInfo);
|
||||
}
|
||||
};
|
||||
|
||||
const workspace: typeof sqlops.workspace = {
|
||||
onDidOpenDashboard: extHostDashboard.onDidOpenDashboard,
|
||||
onDidChangeToDashboard: extHostDashboard.onDidChangeToDashboard,
|
||||
createModelViewEditor(title: string, options?: sqlops.ModelViewEditorOptions): sqlops.workspace.ModelViewEditor {
|
||||
return extHostModelViewDialog.createModelViewEditor(title, extension, options);
|
||||
}
|
||||
};
|
||||
|
||||
const dashboard = {
|
||||
registerWebviewProvider(widgetId: string, handler: (webview: sqlops.DashboardWebview) => void) {
|
||||
extHostWebviewWidgets.$registerProvider(widgetId, handler);
|
||||
}
|
||||
};
|
||||
|
||||
const ui = {
|
||||
registerModelViewProvider(modelViewId: string, handler: (view: sqlops.ModelView) => void): void {
|
||||
extHostModelView.$registerProvider(modelViewId, handler, extension);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: queryeditor
|
||||
const queryEditor: typeof sqlops.queryeditor = {
|
||||
|
||||
connect(fileUri: string, connectionId: string): Thenable<void> {
|
||||
return extHostQueryEditor.$connect(fileUri, connectionId);
|
||||
},
|
||||
|
||||
runQuery(fileUri: string): void {
|
||||
extHostQueryEditor.$runQuery(fileUri);
|
||||
}
|
||||
};
|
||||
|
||||
const extensions: typeof sqlops.extensions = {
|
||||
install(vsixPath: string): Thenable<string> {
|
||||
return extHostExtensionManagement.$install(vsixPath);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
connection,
|
||||
credentials,
|
||||
objectexplorer: objectExplorer,
|
||||
serialization,
|
||||
dataprotocol,
|
||||
DataProviderType: sqlExtHostTypes.DataProviderType,
|
||||
DeclarativeDataType: sqlExtHostTypes.DeclarativeDataType,
|
||||
ServiceOptionType: sqlExtHostTypes.ServiceOptionType,
|
||||
ConnectionOptionSpecialType: sqlExtHostTypes.ConnectionOptionSpecialType,
|
||||
EditRowState: sqlExtHostTypes.EditRowState,
|
||||
MetadataType: sqlExtHostTypes.MetadataType,
|
||||
TaskStatus: sqlExtHostTypes.TaskStatus,
|
||||
TaskExecutionMode: sqlExtHostTypes.TaskExecutionMode,
|
||||
ScriptOperation: sqlExtHostTypes.ScriptOperation,
|
||||
window,
|
||||
tasks,
|
||||
dashboard,
|
||||
workspace,
|
||||
queryeditor: queryEditor,
|
||||
ui: ui,
|
||||
StatusIndicator: sqlExtHostTypes.StatusIndicator,
|
||||
CardType: sqlExtHostTypes.CardType,
|
||||
Orientation: sqlExtHostTypes.Orientation,
|
||||
SqlThemeIcon: sqlExtHostTypes.SqlThemeIcon,
|
||||
TreeComponentItem: sqlExtHostTypes.TreeComponentItem,
|
||||
AzureResource: sqlExtHostTypes.AzureResource,
|
||||
extensions: extensions,
|
||||
TreeItem: sqlExtHostTypes.TreeItem
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function initializeExtensionApi(extensionService: IExtHostExtensionService, apiFactory: ISqlExtensionApiFactory, extensionRegistry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): Promise<void> {
|
||||
return extensionService.getExtensionPathIndex().then(trie => defineAPI(apiFactory, trie, extensionRegistry, configProvider));
|
||||
}
|
||||
|
||||
function defineAPI(factory: ISqlExtensionApiFactory, extensionPaths: TernarySearchTree<IExtensionDescription>, extensionRegistry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): void {
|
||||
type ApiImpl = typeof vscode | typeof azdata | typeof sqlops;
|
||||
|
||||
// each extension is meant to get its own api implementation
|
||||
const extApiImpl = new Map<string, typeof vscode>();
|
||||
const dataExtApiImpl = new Map<string, typeof sqlops>();
|
||||
const azDataExtApiImpl = new Map<string, typeof azdata>();
|
||||
let defaultApiImpl: typeof vscode;
|
||||
let defaultDataApiImpl: typeof sqlops;
|
||||
let defaultAzDataApiImpl: typeof azdata;
|
||||
|
||||
// The module factory looks for an entry in the API map for an extension. If found, it reuses this.
|
||||
// If not, it loads it & saves it in the map
|
||||
let getModuleFactory = function (apiMap: Map<string, any>,
|
||||
createApi: (extensionDescription: IExtensionDescription) => ApiImpl,
|
||||
defaultImpl: ApiImpl,
|
||||
setDefaultApiImpl: (defaultImpl: ApiImpl) => void,
|
||||
parent: any): ApiImpl {
|
||||
// get extension id from filename and api for extension
|
||||
const ext = extensionPaths.findSubstr(URI.file(parent.filename).fsPath);
|
||||
if (ext) {
|
||||
let apiImpl = apiMap.get(ext.identifier.value);
|
||||
if (!apiImpl) {
|
||||
apiImpl = createApi(ext);
|
||||
apiMap.set(ext.identifier.value, apiImpl);
|
||||
}
|
||||
return apiImpl;
|
||||
}
|
||||
|
||||
// fall back to a default implementation
|
||||
if (!defaultImpl) {
|
||||
console.warn(`Could not identify extension for 'vscode' require call from ${parent.filename}`);
|
||||
defaultImpl = createApi(nullExtensionDescription);
|
||||
setDefaultApiImpl(defaultImpl);
|
||||
}
|
||||
return defaultImpl;
|
||||
};
|
||||
|
||||
const node_module = <any>require.__$__nodeRequire('module');
|
||||
const original = node_module._load;
|
||||
|
||||
// TODO look into de-duplicating this code
|
||||
node_module._load = function load(request, parent, isMain) {
|
||||
if (request === 'vscode') {
|
||||
return getModuleFactory(extApiImpl, (ext) => factory.vsCodeFactory(ext, extensionRegistry, configProvider),
|
||||
defaultApiImpl,
|
||||
(impl) => defaultApiImpl = <typeof vscode>impl,
|
||||
parent);
|
||||
} else if (request === 'azdata') {
|
||||
return getModuleFactory(azDataExtApiImpl,
|
||||
(ext) => factory.azdataFactory(ext),
|
||||
defaultAzDataApiImpl,
|
||||
(impl) => defaultAzDataApiImpl = <typeof azdata>impl,
|
||||
parent);
|
||||
} else if (request === 'sqlops') {
|
||||
return getModuleFactory(dataExtApiImpl,
|
||||
(ext) => factory.sqlopsFactory(ext),
|
||||
defaultDataApiImpl,
|
||||
(impl) => defaultDataApiImpl = <typeof sqlops>impl,
|
||||
parent);
|
||||
} else {
|
||||
// Allow standard node_module load to occur
|
||||
return original.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const nullExtensionDescription: IExtensionDescription = {
|
||||
identifier: new ExtensionIdentifier('nullExtensionDescription'),
|
||||
name: 'Null Extension Description',
|
||||
publisher: 'vscode',
|
||||
activationEvents: undefined,
|
||||
contributes: undefined,
|
||||
enableProposedApi: false,
|
||||
engines: undefined,
|
||||
extensionDependencies: undefined,
|
||||
extensionLocation: undefined,
|
||||
isBuiltin: false,
|
||||
main: undefined,
|
||||
version: undefined,
|
||||
isUnderDevelopment: true
|
||||
};
|
||||
|
||||
85
src/sql/workbench/api/node/extHostRequireInterceptor.ts
Normal file
85
src/sql/workbench/api/node/extHostRequireInterceptor.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { INodeModuleFactory } from 'vs/workbench/api/node/extHostRequireInterceptor';
|
||||
import * as azdata from 'azdata';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { IAzdataExtensionApiFactory, ISqlopsExtensionApiFactory } from 'sql/workbench/api/common/sqlExtHost.api.impl';
|
||||
|
||||
export class AzdataNodeModuleFactory implements INodeModuleFactory {
|
||||
public readonly nodeModuleName = 'azdata';
|
||||
|
||||
private readonly _extApiImpl = new Map<string, typeof azdata>();
|
||||
private _defaultApiImpl: typeof azdata;
|
||||
|
||||
constructor(
|
||||
private readonly _apiFactory: IAzdataExtensionApiFactory,
|
||||
private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>
|
||||
) {
|
||||
}
|
||||
|
||||
public load(request: string, parent: { filename: string; }): any {
|
||||
|
||||
// get extension id from filename and api for extension
|
||||
const ext = this._extensionPaths.findSubstr(URI.file(parent.filename).fsPath);
|
||||
if (ext) {
|
||||
let apiImpl = this._extApiImpl.get(ExtensionIdentifier.toKey(ext.identifier));
|
||||
if (!apiImpl) {
|
||||
apiImpl = this._apiFactory(ext);
|
||||
this._extApiImpl.set(ExtensionIdentifier.toKey(ext.identifier), apiImpl);
|
||||
}
|
||||
return apiImpl;
|
||||
}
|
||||
|
||||
// fall back to a default implementation
|
||||
if (!this._defaultApiImpl) {
|
||||
let extensionPathsPretty = '';
|
||||
this._extensionPaths.forEach((value, index) => extensionPathsPretty += `\t${index} -> ${value.identifier.value}\n`);
|
||||
console.warn(`Could not identify extension for 'azdata' require call from ${parent.filename}. These are the extension path mappings: \n${extensionPathsPretty}`);
|
||||
this._defaultApiImpl = this._apiFactory(nullExtensionDescription);
|
||||
}
|
||||
return this._defaultApiImpl;
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlopsNodeModuleFactory implements INodeModuleFactory {
|
||||
public readonly nodeModuleName = 'sqlops';
|
||||
|
||||
private readonly _extApiImpl = new Map<string, typeof sqlops>();
|
||||
private _defaultApiImpl: typeof sqlops;
|
||||
|
||||
constructor(
|
||||
private readonly _apiFactory: ISqlopsExtensionApiFactory,
|
||||
private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>
|
||||
) {
|
||||
}
|
||||
|
||||
public load(request: string, parent: { filename: string; }): any {
|
||||
|
||||
// get extension id from filename and api for extension
|
||||
const ext = this._extensionPaths.findSubstr(URI.file(parent.filename).fsPath);
|
||||
if (ext) {
|
||||
let apiImpl = this._extApiImpl.get(ExtensionIdentifier.toKey(ext.identifier));
|
||||
if (!apiImpl) {
|
||||
apiImpl = this._apiFactory(ext);
|
||||
this._extApiImpl.set(ExtensionIdentifier.toKey(ext.identifier), apiImpl);
|
||||
}
|
||||
return apiImpl;
|
||||
}
|
||||
|
||||
// fall back to a default implementation
|
||||
if (!this._defaultApiImpl) {
|
||||
let extensionPathsPretty = '';
|
||||
this._extensionPaths.forEach((value, index) => extensionPathsPretty += `\t${index} -> ${value.identifier.value}\n`);
|
||||
console.warn(`Could not identify extension for 'sqlops' require call from ${parent.filename}. These are the extension path mappings: \n${extensionPathsPretty}`);
|
||||
this._defaultApiImpl = this._apiFactory(nullExtensionDescription);
|
||||
}
|
||||
return this._defaultApiImpl;
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,16 @@ import { connectProxyResolver } from 'vs/workbench/services/extensions/node/prox
|
||||
import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { ExtHostDownloadService } from 'vs/workbench/api/node/extHostDownloadService';
|
||||
import { CLIServer } from 'vs/workbench/api/node/extHostCLIServer';
|
||||
import { initializeExtensionApi, createApiFactory } from 'sql/workbench/api/common/sqlExtHost.api.impl'; // {{SQL CARBON EDIT}} use our extension initalizer
|
||||
import { createAzdataApiFactory, createSqlopsApiFactory } from 'sql/workbench/api/common/sqlExtHost.api.impl'; // {{SQL CARBON EDIT}} use our extension initalizer
|
||||
import { AzdataNodeModuleFactory, SqlopsNodeModuleFactory } from 'sql/workbench/api/node/extHostRequireInterceptor'; // {{SQL CARBON EDIT}} use our extension initalizer
|
||||
|
||||
export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
|
||||
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
|
||||
// initialize API and register actors
|
||||
const extensionApiFactory = this._instaService.invokeFunction(createApiFactory);
|
||||
const extensionApiFactory = this._instaService.invokeFunction(createApiFactoryAndRegisterActors);
|
||||
const sqlopsExtensionApiFactory = this._instaService.invokeFunction(createSqlopsApiFactory); // {{SQL CARBON EDIT}} // add factory
|
||||
const azdataExtensionApiFactory = this._instaService.invokeFunction(createAzdataApiFactory); // {{SQL CARBON EDIT}} // add factory
|
||||
|
||||
// Register Download command
|
||||
this._instaService.createInstance(ExtHostDownloadService);
|
||||
@@ -31,9 +34,9 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
// Module loading tricks
|
||||
const configProvider = await this._extHostConfiguration.getConfigProvider();
|
||||
const extensionPaths = await this.getExtensionPathIndex();
|
||||
// {{SQL CARBON EDIT}} - disable VSCodeNodeModuleFactory and use older initializeExtensionApi
|
||||
// NodeModuleRequireInterceptor.INSTANCE.register(new VSCodeNodeModuleFactory(this._extensionApiFactory, extensionPaths, this._registry, configProvider));
|
||||
await initializeExtensionApi(this, extensionApiFactory, this._registry, configProvider);
|
||||
NodeModuleRequireInterceptor.INSTANCE.register(new AzdataNodeModuleFactory(azdataExtensionApiFactory, extensionPaths)); // {{SQL CARBON EDIT}} // add node module
|
||||
NodeModuleRequireInterceptor.INSTANCE.register(new SqlopsNodeModuleFactory(sqlopsExtensionApiFactory, extensionPaths)); // {{SQL CARBON EDIT}} // add node module
|
||||
NodeModuleRequireInterceptor.INSTANCE.register(new VSCodeNodeModuleFactory(extensionApiFactory, extensionPaths, this._registry, configProvider));
|
||||
NodeModuleRequireInterceptor.INSTANCE.register(new KeytarNodeModuleFactory(this._extHostContext.getProxy(MainContext.MainThreadKeytar), this._initData.environment));
|
||||
if (this._initData.remote.isRemote) {
|
||||
NodeModuleRequireInterceptor.INSTANCE.register(new OpenNodeModuleFactory(
|
||||
|
||||
@@ -19,7 +19,7 @@ interface LoadFunction {
|
||||
(request: string, parent: { filename: string; }, isMain: any): any;
|
||||
}
|
||||
|
||||
interface INodeModuleFactory {
|
||||
export interface INodeModuleFactory { //{{SQL CARBON EDIT}} export interface
|
||||
readonly nodeModuleName: string | string[];
|
||||
load(request: string, parent: { filename: string; }, isMain: any, original: LoadFunction): any;
|
||||
alternaiveModuleName?(name: string): string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user