提交 419c2dc0 编写于 作者: J Johannes Rieken

add withScmProgress to begin with

上级 ace744e4
......@@ -29,6 +29,8 @@ declare module 'vscode' {
*/
export function withWindowProgress(task: (progress: Progress<string>, token: CancellationToken) => Thenable<any>): void;
export function withScmProgress(task: (progress: Progress<number>) => Thenable<any>): void;
export function sampleFunction(): Thenable<any>;
}
......
......@@ -309,7 +309,10 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
},
withWindowProgress: proposedApiFunction(extension, <R>(task: (progress: vscode.Progress<string>, token: vscode.CancellationToken) => Thenable<R>): Thenable<R> => {
return extHostProgress.withWindowProgress(task);
return extHostProgress.withWindowProgress(extension, task);
}),
withScmProgress: proposedApiFunction(extension, (task: (progress: vscode.Progress<number>) => Thenable<any>) => {
return extHostProgress.withScmProgress(extension, task);
}),
createOutputChannel(name: string): vscode.OutputChannel {
return extHostOutputService.createOutputChannel(name);
......
......@@ -185,7 +185,7 @@ export abstract class MainThreadOutputServiceShape {
}
export abstract class MainThreadProgressShape {
$progressStart(handle: number, location: string): void { throw ni(); }
$progressStart(handle: number, extensionId: string, location: string): void { throw ni(); }
$progressReport(handle: number, message: string): void { throw ni(); }
$progressEnd(handle: number, err?: any): void { throw ni(); }
}
......
......@@ -6,6 +6,7 @@
import { Progress, CancellationToken } from 'vscode';
import { MainThreadProgressShape } from './extHost.protocol';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
export class ExtHostProgress {
......@@ -16,18 +17,18 @@ export class ExtHostProgress {
this._proxy = proxy;
}
withWindowProgress<R>(task: (progress: Progress<string>, token: CancellationToken) => Thenable<R>): Thenable<R> {
return this._withProgress('window', task);
withWindowProgress<R>(extension: IExtensionDescription, task: (progress: Progress<string>, token: CancellationToken) => Thenable<R>): Thenable<R> {
return this._withProgress(extension, 'window', task);
}
withScmViewletProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R> {
return this._withProgress('scm', task);
withScmProgress<R>(extension: IExtensionDescription, task: (progress: Progress<number>) => Thenable<R>): Thenable<R> {
return this._withProgress(extension, 'scm', task);
}
private _withProgress<R>(type: string, task: (progress: Progress<any>, token: CancellationToken) => Thenable<R>): Thenable<R> {
private _withProgress<R>(extension: IExtensionDescription, type: string, task: (progress: Progress<any>, token: CancellationToken) => Thenable<R>): Thenable<R> {
const handle = this._handles++;
this._proxy.$progressStart(handle, type);
this._proxy.$progressStart(handle, extension.id, type);
const progress = {
report: (message: string) => {
this._proxy.$progressReport(handle, message);
......
......@@ -21,7 +21,7 @@ export class MainThreadProgress extends MainThreadProgressShape {
}
$progressStart(handle: number, where: string): void {
$progressStart(handle: number, extensionId: string, where: string): void {
const task = (progress: IProgress<any>) => {
return new TPromise<any>((resolve, reject) => {
......@@ -34,7 +34,8 @@ export class MainThreadProgress extends MainThreadProgressShape {
this._progressService.withWindowProgress(task);
break;
case 'scm':
this._progressService.withViewletProgress('workbench.view.git', task);
this._progressService.withViewletProgress('workbench.view.scm', task);
break;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册