mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
Some promise cleanup (#8092)
* Some promise cleanup * Handle more promise issues * Remove changes that aren't needed anymore * Use log service * another one * Be more explicit
This commit is contained in:
@@ -26,6 +26,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { IGridDataProvider, getResultsString } from 'sql/platform/query/common/gridDataProvider';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
export interface IEditSessionReadyEvent {
|
||||
ownerUri: string;
|
||||
@@ -103,7 +104,8 @@ export default class QueryRunner extends Disposable {
|
||||
@INotificationService private _notificationService: INotificationService,
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@ITextResourcePropertiesService private _textResourcePropertiesService: ITextResourcePropertiesService
|
||||
@ITextResourcePropertiesService private _textResourcePropertiesService: ITextResourcePropertiesService,
|
||||
@ILogService private _logService: ILogService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -347,11 +349,12 @@ export default class QueryRunner extends Disposable {
|
||||
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
|
||||
if (hasShowPlan) {
|
||||
this._isQueryPlan = true;
|
||||
|
||||
this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => {
|
||||
if (e.resultSubset.rows) {
|
||||
this._planXml.resolve(e.resultSubset.rows[0][0].displayValue);
|
||||
}
|
||||
});
|
||||
}).catch((e) => this._logService.error(e));
|
||||
}
|
||||
// we will just ignore the set if we already have it
|
||||
// ideally this should never happen
|
||||
@@ -374,6 +377,7 @@ export default class QueryRunner extends Disposable {
|
||||
if (hasShowPlan) {
|
||||
this._isQueryPlan = true;
|
||||
this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => {
|
||||
|
||||
if (e.resultSubset.rows) {
|
||||
let planXmlString = e.resultSubset.rows[0][0].displayValue;
|
||||
this._planXml.resolve(e.resultSubset.rows[0][0].displayValue);
|
||||
@@ -386,7 +390,7 @@ export default class QueryRunner extends Disposable {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}).catch((e) => this._logService.error(e));
|
||||
}
|
||||
if (batchSet) {
|
||||
// Store the result set in the batch and emit that a result set has completed
|
||||
@@ -525,10 +529,9 @@ export default class QueryRunner extends Disposable {
|
||||
/**
|
||||
* Disposes the Query from the service client
|
||||
*/
|
||||
public disposeQuery(): void {
|
||||
this._queryManagementService.disposeQuery(this.uri).then(() => {
|
||||
this.dispose();
|
||||
});
|
||||
public async disposeQuery(): Promise<void> {
|
||||
await this._queryManagementService.disposeQuery(this.uri);
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
@@ -547,9 +550,9 @@ export default class QueryRunner extends Disposable {
|
||||
* @param resultId The result id of the result to copy from
|
||||
* @param includeHeaders [Optional]: Should column headers be included in the copy selection
|
||||
*/
|
||||
copyResults(selection: Slick.Range[], batchId: number, resultId: number, includeHeaders?: boolean): void {
|
||||
async copyResults(selection: Slick.Range[], batchId: number, resultId: number, includeHeaders?: boolean): Promise<void> {
|
||||
let provider = this.getGridDataProvider(batchId, resultId);
|
||||
provider.copyResults(selection, includeHeaders);
|
||||
return provider.copyResults(selection, includeHeaders);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,14 +621,14 @@ export class QueryGridDataProvider implements IGridDataProvider {
|
||||
return this.queryRunner.getQueryRows(rowStart, numberOfRows, this.batchId, this.resultSetId);
|
||||
}
|
||||
|
||||
copyResults(selection: Slick.Range[], includeHeaders?: boolean): void {
|
||||
this.copyResultsAsync(selection, includeHeaders);
|
||||
copyResults(selection: Slick.Range[], includeHeaders?: boolean): Promise<void> {
|
||||
return this.copyResultsAsync(selection, includeHeaders);
|
||||
}
|
||||
|
||||
private async copyResultsAsync(selection: Slick.Range[], includeHeaders?: boolean): Promise<void> {
|
||||
try {
|
||||
let results = await getResultsString(this, selection, includeHeaders);
|
||||
this._clipboardService.writeText(results);
|
||||
await this._clipboardService.writeText(results);
|
||||
} catch (error) {
|
||||
this._notificationService.error(nls.localize('copyFailed', "Copy failed with error {0}", getErrorMessage(error)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user