From 314bd0e212b6ef2f0db744eac998a1c84dc16de3 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Thu, 15 Aug 2019 13:43:08 -0700 Subject: [PATCH] run the whole thing instead of current statement (#6757) * run the whole thing instead of current statement * backward compact --- src/sql/azdata.d.ts | 4 +++- src/sql/workbench/api/browser/mainThreadQueryEditor.ts | 8 ++++++-- src/sql/workbench/api/common/extHostQueryEditor.ts | 4 ++-- src/sql/workbench/api/common/sqlExtHost.api.impl.ts | 4 ++-- src/sql/workbench/api/common/sqlExtHost.protocol.ts | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sql/azdata.d.ts b/src/sql/azdata.d.ts index 2675a60a6a..e2c556f6c0 100644 --- a/src/sql/azdata.d.ts +++ b/src/sql/azdata.d.ts @@ -4035,8 +4035,10 @@ declare module 'azdata' { /** * Run query if it is a query editor and it is already opened. * @param fileUri file URI for the query editor + * @param options options + * @param runCurrentQuery true: run current query only, false: run all the queries in the file, default is true. */ - export function runQuery(fileUri: string, options?: Map): void; + export function runQuery(fileUri: string, options?: Map, runCurrentQuery?: boolean): void; /** * Register a query event listener diff --git a/src/sql/workbench/api/browser/mainThreadQueryEditor.ts b/src/sql/workbench/api/browser/mainThreadQueryEditor.ts index 1c7a5d2967..ec0ca64570 100644 --- a/src/sql/workbench/api/browser/mainThreadQueryEditor.ts +++ b/src/sql/workbench/api/browser/mainThreadQueryEditor.ts @@ -67,13 +67,17 @@ export class MainThreadQueryEditor implements MainThreadQueryEditorShape { }); } - public $runQuery(fileUri: string): void { + public $runQuery(fileUri: string, runCurrentQuery: boolean = true): void { let filteredEditors = this._editorService.visibleControls.filter(editor => editor.input.getResource().toString() === fileUri); if (filteredEditors && filteredEditors.length > 0) { let editor = filteredEditors[0]; if (editor instanceof QueryEditor) { let queryEditor: QueryEditor = editor; - queryEditor.runCurrentQuery(); + if (runCurrentQuery) { + queryEditor.runCurrentQuery(); + } else { + queryEditor.runQuery(); + } } } } diff --git a/src/sql/workbench/api/common/extHostQueryEditor.ts b/src/sql/workbench/api/common/extHostQueryEditor.ts index ab02d594e4..f91c9f1f36 100644 --- a/src/sql/workbench/api/common/extHostQueryEditor.ts +++ b/src/sql/workbench/api/common/extHostQueryEditor.ts @@ -44,8 +44,8 @@ export class ExtHostQueryEditor implements ExtHostQueryEditorShape { return this._proxy.$connect(fileUri, connectionId); } - public $runQuery(fileUri: string): void { - return this._proxy.$runQuery(fileUri); + public $runQuery(fileUri: string, runCurrentQuery: boolean = true): void { + return this._proxy.$runQuery(fileUri, runCurrentQuery); } public $registerQueryInfoListener(providerId: string, listener: azdata.queryeditor.QueryEventListener): void { diff --git a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts index c1186cb625..7c98d3c754 100644 --- a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts @@ -834,8 +834,8 @@ export function createAzdataApiFactory(accessor: ServicesAccessor): IAzdataExten return extHostQueryEditor.$connect(fileUri, connectionId); }, - runQuery(fileUri: string, options?: Map): void { - extHostQueryEditor.$runQuery(fileUri); + runQuery(fileUri: string, options?: Map, runCurrentQuery: boolean = true): void { + extHostQueryEditor.$runQuery(fileUri, runCurrentQuery); }, registerQueryEventListener(listener: azdata.queryeditor.QueryEventListener): void { diff --git a/src/sql/workbench/api/common/sqlExtHost.protocol.ts b/src/sql/workbench/api/common/sqlExtHost.protocol.ts index 6a377e678f..aad95f6aa5 100644 --- a/src/sql/workbench/api/common/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/common/sqlExtHost.protocol.ts @@ -813,7 +813,7 @@ export interface ExtHostQueryEditorShape { export interface MainThreadQueryEditorShape extends IDisposable { $connect(fileUri: string, connectionId: string): Thenable; - $runQuery(fileUri: string): void; + $runQuery(fileUri: string, runCurrentQuery?: boolean): void; $createQueryTab(fileUri: string, title: string, content: string): void; $setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable; $registerQueryInfoListener(handle: number, providerId: string): void;