mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -3,15 +3,24 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
|
||||
export const IProgressService = createDecorator<IProgressService>('progressService');
|
||||
|
||||
/**
|
||||
* A progress service that can be used to report progress to various locations of the UI.
|
||||
*/
|
||||
export interface IProgressService {
|
||||
_serviceBrand: any;
|
||||
|
||||
_serviceBrand: ServiceIdentifier<IProgressService>;
|
||||
|
||||
withProgress<R = any>(options: IProgressOptions | IProgressNotificationOptions | IProgressCompositeOptions, task: (progress: IProgress<IProgressStep>) => Promise<R>, onDidCancel?: () => void): Promise<R>;
|
||||
}
|
||||
|
||||
export interface IProgressIndicator {
|
||||
|
||||
/**
|
||||
* Show progress customized with the provided flags.
|
||||
@@ -44,23 +53,20 @@ export interface IProgressOptions {
|
||||
}
|
||||
|
||||
export interface IProgressNotificationOptions extends IProgressOptions {
|
||||
location: ProgressLocation.Notification;
|
||||
primaryActions?: IAction[];
|
||||
secondaryActions?: IAction[];
|
||||
readonly location: ProgressLocation.Notification;
|
||||
readonly primaryActions?: ReadonlyArray<IAction>;
|
||||
readonly secondaryActions?: ReadonlyArray<IAction>;
|
||||
}
|
||||
|
||||
export interface IProgressCompositeOptions extends IProgressOptions {
|
||||
location: ProgressLocation.Explorer | ProgressLocation.Extensions | ProgressLocation.Scm | string;
|
||||
delay?: number;
|
||||
}
|
||||
|
||||
export interface IProgressStep {
|
||||
message?: string;
|
||||
increment?: number;
|
||||
}
|
||||
|
||||
export const IProgressService2 = createDecorator<IProgressService2>('progressService2');
|
||||
|
||||
export interface IProgressService2 {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
withProgress<R = any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => Promise<R>, onDidCancel?: () => void): Promise<R>;
|
||||
total?: number;
|
||||
}
|
||||
|
||||
export interface IProgressRunner {
|
||||
@@ -69,6 +75,8 @@ export interface IProgressRunner {
|
||||
done(): void;
|
||||
}
|
||||
|
||||
export const emptyProgress: IProgress<IProgressStep> = { report: () => { } };
|
||||
|
||||
export const emptyProgressRunner: IProgressRunner = Object.freeze({
|
||||
total() { },
|
||||
worked() { },
|
||||
@@ -79,8 +87,6 @@ export interface IProgress<T> {
|
||||
report(item: T): void;
|
||||
}
|
||||
|
||||
export const emptyProgress: IProgress<any> = Object.freeze({ report() { } });
|
||||
|
||||
export class Progress<T> implements IProgress<T> {
|
||||
|
||||
private _callback: (data: T) => void;
|
||||
@@ -111,15 +117,17 @@ export interface IOperation {
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
export class LongRunningOperation {
|
||||
export class LongRunningOperation extends Disposable {
|
||||
private currentOperationId = 0;
|
||||
private currentOperationDisposables: IDisposable[] = [];
|
||||
private readonly currentOperationDisposables = this._register(new DisposableStore());
|
||||
private currentProgressRunner: IProgressRunner;
|
||||
private currentProgressTimeout: any;
|
||||
|
||||
constructor(
|
||||
private progressService: IProgressService
|
||||
) { }
|
||||
private progressIndicator: IProgressIndicator
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
start(progressDelay: number): IOperation {
|
||||
|
||||
@@ -131,15 +139,13 @@ export class LongRunningOperation {
|
||||
const newOperationToken = new CancellationTokenSource();
|
||||
this.currentProgressTimeout = setTimeout(() => {
|
||||
if (newOperationId === this.currentOperationId) {
|
||||
this.currentProgressRunner = this.progressService.show(true);
|
||||
this.currentProgressRunner = this.progressIndicator.show(true);
|
||||
}
|
||||
}, progressDelay);
|
||||
|
||||
this.currentOperationDisposables.push(
|
||||
toDisposable(() => clearTimeout(this.currentProgressTimeout)),
|
||||
toDisposable(() => newOperationToken.cancel()),
|
||||
toDisposable(() => this.currentProgressRunner ? this.currentProgressRunner.done() : undefined)
|
||||
);
|
||||
this.currentOperationDisposables.add(toDisposable(() => clearTimeout(this.currentProgressTimeout)));
|
||||
this.currentOperationDisposables.add(toDisposable(() => newOperationToken.cancel()));
|
||||
this.currentOperationDisposables.add(toDisposable(() => this.currentProgressRunner ? this.currentProgressRunner.done() : undefined));
|
||||
|
||||
return {
|
||||
id: newOperationId,
|
||||
@@ -155,11 +161,17 @@ export class LongRunningOperation {
|
||||
|
||||
private doStop(operationId: number): void {
|
||||
if (this.currentOperationId === operationId) {
|
||||
this.currentOperationDisposables = dispose(this.currentOperationDisposables);
|
||||
this.currentOperationDisposables.clear();
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.currentOperationDisposables = dispose(this.currentOperationDisposables);
|
||||
}
|
||||
}
|
||||
|
||||
export const IEditorProgressService = createDecorator<IEditorProgressService>('editorProgressService');
|
||||
|
||||
/**
|
||||
* A progress service that will report progress local to the editor triggered from.
|
||||
*/
|
||||
export interface IEditorProgressService extends IProgressIndicator {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<IEditorProgressService>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user