Skip to content

Commit

Permalink
microsoft#59645 Move progress service to platform
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Oct 23, 2018
1 parent 24c93a6 commit cb82a53
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 60 deletions.
1 change: 0 additions & 1 deletion src/tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@
"./vs/workbench/services/mode/common/workbenchModeService.ts",
"./vs/workbench/services/panel/common/panelService.ts",
"./vs/workbench/services/part/common/partService.ts",
"./vs/workbench/services/progress/common/progress.ts",
"./vs/workbench/services/scm/common/scm.ts",
"./vs/workbench/services/scm/common/scmService.ts",
"./vs/workbench/services/search/node/legacy/search.ts",
Expand Down
30 changes: 30 additions & 0 deletions src/vs/platform/progress/common/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ export interface IProgressService {
showWhile(promise: Thenable<any>, delay?: number): Thenable<void>;
}

export const enum ProgressLocation {
Explorer = 1,
Scm = 3,
Extensions = 5,
Window = 10,
Notification = 15
}

export interface IProgressOptions {
location: ProgressLocation | string;
title?: string;
source?: string;
total?: number;
cancellable?: boolean;
}

export interface IProgressStep {
message?: string;
increment?: number;
}

export const IProgressService2 = createDecorator<IProgressService2>('progressService2');

export interface IProgressService2 {

_serviceBrand: any;

withProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => P, onDidCancel?: () => void): P;
}

export interface IProgressRunner {
total(value: number): void;
worked(value: number): void;
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/api/electron-browser/mainThreadProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IProgress } from 'vs/platform/progress/common/progress';
import { IProgress, IProgressService2, IProgressStep, IProgressOptions } from 'vs/platform/progress/common/progress';
import { MainThreadProgressShape, MainContext, IExtHostContext, ExtHostProgressShape, ExtHostContext } from '../node/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { IProgressService2, IProgressStep, IProgressOptions } from 'vs/workbench/services/progress/common/progress';

@extHostNamedCustomer(MainContext.MainThreadProgress)
export class MainThreadProgress implements MainThreadProgressShape {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IProgressService2, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common/progress';
import { localize } from 'vs/nls';
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { TaskSet } from 'vs/workbench/parts/tasks/common/tasks';
import { ITerminalDimensions } from 'vs/workbench/parts/terminal/common/terminal';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { IRPCProtocol, ProxyIdentifier, createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId } from 'vs/workbench/services/extensions/node/proxyIdentifier';
import { IProgressOptions, IProgressStep } from 'vs/workbench/services/progress/common/progress';
import { IProgressOptions, IProgressStep } from 'vs/platform/progress/common/progress';
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import * as vscode from 'vscode';

Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/api/node/extHostProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import { ProgressOptions } from 'vscode';
import { MainThreadProgressShape, ExtHostProgressShape } from './extHost.protocol';
import { ProgressLocation } from './extHostTypeConverters';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { Progress } from 'vs/platform/progress/common/progress';
import { Progress, IProgressStep } from 'vs/platform/progress/common/progress';
import { localize } from 'vs/nls';
import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation';
import { debounce } from 'vs/base/common/decorators';
import { IProgressStep } from 'vs/workbench/services/progress/common/progress';

export class ExtHostProgress implements ExtHostProgressShape {

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IDecorationOptions } from 'vs/editor/common/editorCommon';
import { EndOfLineSequence } from 'vs/editor/common/model';
import * as vscode from 'vscode';
import { URI } from 'vs/base/common/uri';
import { ProgressLocation as MainProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { ProgressLocation as MainProgressLocation } from 'vs/platform/progress/common/progress';
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import { IPosition } from 'vs/editor/common/core/position';
import { IRange } from 'vs/editor/common/core/range';
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/views/customView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { IViewsService, ITreeViewer, ITreeItem, TreeItemCollapsibleState, ITreeV
import { IViewletViewOptions, FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IProgressService2 } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2 } from 'vs/platform/progress/common/progress';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ICommandService } from 'vs/platform/commands/common/commands';
Expand Down Expand Up @@ -409,7 +409,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
private activate() {
this.hideMessage();
if (!this.activated) {
this.progressService.withProgress({ location: this.container }, () => this.extensionService.activateByEvent(`onView:${this.id}`))
this.progressService.withProgress({ location: this.container.id }, () => this.extensionService.activateByEvent(`onView:${this.id}`))
.then(() => timeout(2000))
.then(() => {
if (!this.dataProvider) {
Expand Down Expand Up @@ -465,7 +465,7 @@ class TreeDataSource implements IDataSource {

getChildren(tree: ITree, node: ITreeItem): TPromise<any[]> {
if (this.treeView.dataProvider) {
return this.progressService.withProgress({ location: this.container }, () => this.treeView.dataProvider.getChildren(node));
return this.progressService.withProgress({ location: this.container.id }, () => this.treeView.dataProvider.getChildren(node));
}
return Promise.resolve([]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import { TextFileService } from 'vs/workbench/services/textfile/electron-browser
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ISCMService } from 'vs/workbench/services/scm/common/scm';
import { SCMService } from 'vs/workbench/services/scm/common/scmService';
import { IProgressService2 } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2 } from 'vs/platform/progress/common/progress';
import { ProgressService2 } from 'vs/workbench/services/progress/browser/progressService2';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
import product from 'vs/platform/node/product';
import { ILogService } from 'vs/platform/log/common/log';
import { IProgressService2, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common/progress';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { groupBy } from 'vs/base/common/collections';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { TestContextService, TestWindowService } from 'vs/workbench/test/workben
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IProgressService2 } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2 } from 'vs/platform/progress/common/progress';
import { ProgressService2 } from 'vs/workbench/services/progress/browser/progressService2';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { URLService } from 'vs/platform/url/common/urlService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ProblemMatcherRegistry, NamedProblemMatcher } from 'vs/workbench/parts/tasks/common/problemMatcher';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IProgressService2, IProgressOptions, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2, IProgressOptions, ProgressLocation } from 'vs/platform/progress/common/progress';

import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IWindowService } from 'vs/platform/windows/common/windows';
Expand Down
12 changes: 5 additions & 7 deletions src/vs/workbench/services/progress/browser/progressService2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'vs/css!./media/progressService2';

import { localize } from 'vs/nls';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IProgressService2, IProgressOptions, IProgressStep, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgress, emptyProgress, Progress } from 'vs/platform/progress/common/progress';
import { IProgressService2, IProgressOptions, IProgressStep, ProgressLocation, IProgress, emptyProgress, Progress } from 'vs/platform/progress/common/progress';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { StatusbarAlignment, IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { TPromise } from 'vs/base/common/winjs.base';
Expand All @@ -17,7 +16,6 @@ import { ProgressBadge, IActivityService } from 'vs/workbench/services/activity/
import { INotificationService, Severity, INotificationHandle, INotificationActions } from 'vs/platform/notification/common/notification';
import { Action } from 'vs/base/common/actions';
import { once } from 'vs/base/common/event';
import { ViewContainer } from 'vs/workbench/common/views';

export class ProgressService2 implements IProgressService2 {

Expand All @@ -38,12 +36,12 @@ export class ProgressService2 implements IProgressService2 {
withProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => P, onDidCancel?: () => void): P {

const { location } = options;
if (location instanceof ViewContainer) {
const viewlet = this._viewletService.getViewlet(location.id);
if (typeof location === 'string') {
const viewlet = this._viewletService.getViewlet(location);
if (viewlet) {
return this._withViewletProgress(location.id, task);
return this._withViewletProgress(location, task);
}
console.warn(`Bad progress location: ${location.id}`);
console.warn(`Bad progress location: ${location}`);
return undefined;
}

Expand Down
38 changes: 0 additions & 38 deletions src/vs/workbench/services/progress/common/progress.ts

This file was deleted.

0 comments on commit cb82a53

Please sign in to comment.