mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Add openQueryDocument API (#16117)
* Add openQueryDocument API * Remove open call * Change try name
This commit is contained in:
@@ -16,6 +16,8 @@ import { IQueryManagementService } from 'sql/workbench/services/query/common/que
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadQueryEditor)
|
||||
export class MainThreadQueryEditor extends Disposable implements MainThreadQueryEditorShape {
|
||||
@@ -29,7 +31,8 @@ export class MainThreadQueryEditor extends Disposable implements MainThreadQuery
|
||||
@IQueryModelService private _queryModelService: IQueryModelService,
|
||||
@IEditorService private _editorService: IEditorService,
|
||||
@IQueryManagementService private _queryManagementService: IQueryManagementService,
|
||||
@ILogService private _logService: ILogService
|
||||
@ILogService private _logService: ILogService,
|
||||
@IQueryEditorService private _queryEditorService: IQueryEditorService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
@@ -145,4 +148,9 @@ export class MainThreadQueryEditor extends Disposable implements MainThreadQuery
|
||||
public $setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void> {
|
||||
return this._queryManagementService.setQueryExecutionOptions(fileUri, options);
|
||||
}
|
||||
|
||||
public async $createQueryDocument(options?: { content?: string }, providerId?: string): Promise<URI> {
|
||||
const queryInput = await this._queryEditorService.newSqlEditor({ initalContent: options.content }, providerId);
|
||||
return queryInput.resource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as azdata from 'azdata';
|
||||
import { IQueryEvent } from 'sql/workbench/services/query/common/queryModel';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
class ExtHostQueryDocument implements azdata.queryeditor.QueryDocument {
|
||||
constructor(
|
||||
@@ -77,4 +78,7 @@ export class ExtHostQueryEditor implements ExtHostQueryEditorShape {
|
||||
});
|
||||
}
|
||||
|
||||
public createQueryDocument(options?: { content?: string }, providerId?: string): Promise<URI> {
|
||||
return this._proxy.$createQueryDocument(options, providerId).then(data => URI.revive(data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import { IExtensionApiFactory as vsIApiFactory, createApiFactoryAndRegisterActor
|
||||
import { IExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { ExtHostWorkspace } from 'sql/workbench/api/common/extHostWorkspace';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export interface IAzdataExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof azdata;
|
||||
@@ -96,7 +97,6 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
const extHostNotebookDocumentsAndEditors = rpcProtocol.set(SqlExtHostContext.ExtHostNotebookDocumentsAndEditors, new ExtHostNotebookDocumentsAndEditors(rpcProtocol));
|
||||
const extHostExtensionManagement = rpcProtocol.set(SqlExtHostContext.ExtHostExtensionManagement, new ExtHostExtensionManagement(rpcProtocol));
|
||||
const extHostWorkspace = rpcProtocol.set(SqlExtHostContext.ExtHostWorkspace, new ExtHostWorkspace(rpcProtocol));
|
||||
|
||||
return {
|
||||
azdata: function (extension: IExtensionDescription): typeof azdata {
|
||||
// namespace: connection
|
||||
@@ -506,6 +506,15 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
|
||||
getQueryDocument(fileUri: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
return extHostQueryEditor.$getQueryDocument(fileUri);
|
||||
},
|
||||
|
||||
openQueryDocument(options?: { content?: string; }, providerId?: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
let uriPromise: Thenable<URI>;
|
||||
|
||||
uriPromise = extHostQueryEditor.createQueryDocument(options, providerId);
|
||||
return uriPromise.then(uri => {
|
||||
return extHostQueryEditor.$getQueryDocument(uri.toString());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
createMainContextProxyIdentifier as createMainId,
|
||||
createExtHostContextProxyIdentifier as createExtId
|
||||
} from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
@@ -847,6 +847,7 @@ export interface MainThreadQueryEditorShape extends IDisposable {
|
||||
$setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void>;
|
||||
$registerQueryInfoListener(handle: number): void;
|
||||
$unregisterQueryInfoListener(handle: number): void;
|
||||
$createQueryDocument(options?: { content?: string }, providerId?: string): Promise<URI>;
|
||||
}
|
||||
|
||||
export interface ExtHostNotebookShape {
|
||||
|
||||
Reference in New Issue
Block a user