Skip to content

Commit 0b4d2dc

Browse files
author
Benjamin Pasero
committed
debt - reduce scope of local progress service
1 parent abac09b commit 0b4d2dc

17 files changed

Lines changed: 174 additions & 220 deletions

File tree

src/vs/editor/contrib/codeAction/codeActionCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo
1919
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2020
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2121
import { IMarkerService } from 'vs/platform/markers/common/markers';
22-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
22+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
2323
import { CodeActionModel, SUPPORTED_CODE_ACTIONS, CodeActionsState } from './codeActionModel';
2424
import { CodeActionAutoApply, CodeActionFilter, CodeActionKind, CodeActionTrigger } from './codeActionTrigger';
2525
import { CodeActionWidget } from './codeActionWidget';
@@ -52,7 +52,7 @@ export class QuickFixController extends Disposable implements IEditorContributio
5252
editor: ICodeEditor,
5353
@IMarkerService markerService: IMarkerService,
5454
@IContextKeyService contextKeyService: IContextKeyService,
55-
@ILocalProgressService progressService: ILocalProgressService,
55+
@IEditorProgressService progressService: IEditorProgressService,
5656
@IContextMenuService contextMenuService: IContextMenuService,
5757
@ICommandService private readonly _commandService: ICommandService,
5858
@IKeybindingService private readonly _keybindingService: IKeybindingService,

src/vs/editor/contrib/codeAction/codeActionModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Selection } from 'vs/editor/common/core/selection';
1414
import { CodeActionProviderRegistry } from 'vs/editor/common/modes';
1515
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1616
import { IMarkerService } from 'vs/platform/markers/common/markers';
17-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
17+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
1818
import { getCodeActions, CodeActionSet } from './codeAction';
1919
import { CodeActionTrigger } from './codeActionTrigger';
2020

@@ -167,7 +167,7 @@ export class CodeActionModel extends Disposable {
167167
private readonly _editor: ICodeEditor,
168168
private readonly _markerService: IMarkerService,
169169
contextKeyService: IContextKeyService,
170-
private readonly _progressService?: ILocalProgressService
170+
private readonly _progressService?: IEditorProgressService
171171
) {
172172
super();
173173
this._supportedCodeActions = SUPPORTED_CODE_ACTIONS.bindTo(contextKeyService);

src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
2525
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
2626
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2727
import { INotificationService } from 'vs/platform/notification/common/notification';
28-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
28+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
2929
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition, getDeclarationsAtPosition } from './goToDefinition';
3030
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
3131
import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState';
@@ -58,7 +58,7 @@ export class DefinitionAction extends EditorAction {
5858
}
5959
const notificationService = accessor.get(INotificationService);
6060
const editorService = accessor.get(ICodeEditorService);
61-
const progressService = accessor.get(ILocalProgressService);
61+
const progressService = accessor.get(IEditorProgressService);
6262
const symbolNavService = accessor.get(ISymbolNavigationService);
6363

6464
const model = editor.getModel();

src/vs/editor/contrib/rename/rename.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
77
import { illegalArgument, onUnexpectedError } from 'vs/base/common/errors';
88
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
99
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
10-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
10+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
1111
import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction, EditorCommand, registerEditorCommand, registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions';
1212
import { IEditorContribution } from 'vs/editor/common/editorCommon';
1313
import { ITextModel } from 'vs/editor/common/model';
@@ -114,7 +114,7 @@ class RenameController extends Disposable implements IEditorContribution {
114114
private readonly editor: ICodeEditor,
115115
@INotificationService private readonly _notificationService: INotificationService,
116116
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
117-
@ILocalProgressService private readonly _progressService: ILocalProgressService,
117+
@IEditorProgressService private readonly _progressService: IEditorProgressService,
118118
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
119119
@IThemeService private readonly _themeService: IThemeService,
120120
) {

src/vs/editor/standalone/browser/simpleServices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe
3838
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
3939
import { ILabelService, ResourceLabelFormatter } from 'vs/platform/label/common/label';
4040
import { INotification, INotificationHandle, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
41-
import { IProgressRunner, ILocalProgressService } from 'vs/platform/progress/common/progress';
41+
import { IProgressRunner, IEditorProgressService } from 'vs/platform/progress/common/progress';
4242
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
4343
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
4444
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
@@ -137,7 +137,7 @@ export class SimpleEditorModelResolverService implements ITextModelService {
137137
}
138138
}
139139

140-
export class SimpleLocalProgressService implements ILocalProgressService {
140+
export class SimpleEditorProgressService implements IEditorProgressService {
141141
_serviceBrand: any;
142142

143143
private static NULL_PROGRESS_RUNNER: IProgressRunner = {
@@ -149,7 +149,7 @@ export class SimpleLocalProgressService implements ILocalProgressService {
149149
show(infinite: true, delay?: number): IProgressRunner;
150150
show(total: number, delay?: number): IProgressRunner;
151151
show(): IProgressRunner {
152-
return SimpleLocalProgressService.NULL_PROGRESS_RUNNER;
152+
return SimpleEditorProgressService.NULL_PROGRESS_RUNNER;
153153
}
154154

155155
showWhile(promise: Promise<any>, delay?: number): Promise<void> {

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
1313
import { IModelService } from 'vs/editor/common/services/modelService';
1414
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
1515
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
16-
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleLocalProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
16+
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleEditorProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
1717
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
1818
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
1919
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
@@ -36,7 +36,7 @@ import { ILogService, NullLogService } from 'vs/platform/log/common/log';
3636
import { MarkerService } from 'vs/platform/markers/common/markerService';
3737
import { IMarkerService } from 'vs/platform/markers/common/markers';
3838
import { INotificationService } from 'vs/platform/notification/common/notification';
39-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
39+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
4040
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
4141
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
4242
import { IThemeService } from 'vs/platform/theme/common/themeService';
@@ -154,7 +154,7 @@ export module StaticServices {
154154

155155
export const codeEditorService = define(ICodeEditorService, (o) => new StandaloneCodeEditorServiceImpl(standaloneThemeService.get(o)));
156156

157-
export const localProgressService = define(ILocalProgressService, () => new SimpleLocalProgressService());
157+
export const editorProgressService = define(IEditorProgressService, () => new SimpleEditorProgressService());
158158

159159
export const storageService = define(IStorageService, () => new InMemoryStorageService());
160160

src/vs/platform/progress/common/progress.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ export interface IProgressService {
2020
withProgress<R = any>(options: IProgressOptions | IProgressNotificationOptions | IProgressCompositeOptions, task: (progress: IProgress<IProgressStep>) => Promise<R>, onDidCancel?: () => void): Promise<R>;
2121
}
2222

23-
export const ILocalProgressService = createDecorator<ILocalProgressService>('localProgressService');
24-
25-
/**
26-
* A progress service that will report progress local to the UI piece triggered from. E.g.
27-
* if used from an action of a viewlet, the progress will be reported in that viewlet.
28-
*/
29-
export interface ILocalProgressService {
30-
31-
_serviceBrand: ServiceIdentifier<ILocalProgressService>;
23+
export interface IProgressIndicator {
3224

3325
/**
3426
* Show progress customized with the provided flags.
@@ -132,7 +124,7 @@ export class LongRunningOperation extends Disposable {
132124
private currentProgressTimeout: any;
133125

134126
constructor(
135-
private localProgressService: ILocalProgressService
127+
private progressIndicator: IProgressIndicator
136128
) {
137129
super();
138130
}
@@ -147,7 +139,7 @@ export class LongRunningOperation extends Disposable {
147139
const newOperationToken = new CancellationTokenSource();
148140
this.currentProgressTimeout = setTimeout(() => {
149141
if (newOperationId === this.currentOperationId) {
150-
this.currentProgressRunner = this.localProgressService.show(true);
142+
this.currentProgressRunner = this.progressIndicator.show(true);
151143
}
152144
}, progressDelay);
153145

@@ -173,3 +165,13 @@ export class LongRunningOperation extends Disposable {
173165
}
174166
}
175167
}
168+
169+
export const IEditorProgressService = createDecorator<IEditorProgressService>('editorProgressService');
170+
171+
/**
172+
* A progress service that will report progress local to the editor triggered from.
173+
*/
174+
export interface IEditorProgressService extends IProgressIndicator {
175+
176+
_serviceBrand: ServiceIdentifier<IEditorProgressService>;
177+
}

src/vs/workbench/browser/parts/compositePart.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ import { IAction } from 'vs/base/common/actions';
1818
import { Part, IPartOptions } from 'vs/workbench/browser/part';
1919
import { Composite, CompositeRegistry } from 'vs/workbench/browser/composite';
2020
import { IComposite } from 'vs/workbench/common/composite';
21-
import { ScopedProgressService } from 'vs/workbench/services/progress/browser/localProgressService';
21+
import { CompositeProgressIndicator } from 'vs/workbench/services/progress/browser/progressIndicator';
2222
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
2323
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
2424
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2525
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
26-
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
27-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
26+
import { IProgressIndicator } from 'vs/platform/progress/common/progress';
2827
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2928
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3029
import { IThemeService } from 'vs/platform/theme/common/themeService';
@@ -50,7 +49,7 @@ export interface ICompositeTitleLabel {
5049
interface CompositeItem {
5150
composite: Composite;
5251
disposable: IDisposable;
53-
localProgressService: ILocalProgressService;
52+
progress: IProgressIndicator;
5453
}
5554

5655
export abstract class CompositePart<T extends Composite> extends Part {
@@ -169,17 +168,18 @@ export abstract class CompositePart<T extends Composite> extends Part {
169168
// Instantiate composite from registry otherwise
170169
const compositeDescriptor = this.registry.getComposite(id);
171170
if (compositeDescriptor) {
172-
const localProgressService = this.instantiationService.createInstance(ScopedProgressService, this.progressBar, compositeDescriptor.id, isActive);
173-
const compositeInstantiationService = this.instantiationService.createChild(new ServiceCollection([ILocalProgressService, localProgressService]));
174-
175-
const composite = compositeDescriptor.instantiate(compositeInstantiationService);
176-
const disposables = new DisposableStore();
171+
const composite = compositeDescriptor.instantiate(this.instantiationService);
172+
const disposable = new DisposableStore();
177173

178174
// Remember as Instantiated
179-
this.instantiatedCompositeItems.set(id, { composite, disposable: disposables, localProgressService });
175+
this.instantiatedCompositeItems.set(id, {
176+
composite,
177+
disposable,
178+
progress: this._register(this.instantiationService.createInstance(CompositeProgressIndicator, this.progressBar, compositeDescriptor.id, isActive))
179+
});
180180

181181
// Register to title area update events from the composite
182-
disposables.add(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId()), this));
182+
disposable.add(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId()), this));
183183

184184
return composite;
185185
}
@@ -451,10 +451,10 @@ export abstract class CompositePart<T extends Composite> extends Part {
451451
return contentContainer;
452452
}
453453

454-
getProgressIndicator(id: string): ILocalProgressService | null {
454+
getProgressIndicator(id: string): IProgressIndicator | null {
455455
const compositeItem = this.instantiatedCompositeItems.get(id);
456456

457-
return compositeItem ? compositeItem.localProgressService : null;
457+
return compositeItem ? compositeItem.progress : null;
458458
}
459459

460460
protected getActions(): ReadonlyArray<IAction> {

src/vs/workbench/browser/parts/editor/editorControl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } fr
1111
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
1212
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
1313
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
14-
import { ILocalProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress';
14+
import { IEditorProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress';
1515
import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
1616
import { Event, Emitter } from 'vs/base/common/event';
1717
import { IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
@@ -47,11 +47,11 @@ export class EditorControl extends Disposable {
4747
private groupView: IEditorGroupView,
4848
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
4949
@IInstantiationService private readonly instantiationService: IInstantiationService,
50-
@ILocalProgressService localProgressService: ILocalProgressService
50+
@IEditorProgressService editorProgressService: IEditorProgressService
5151
) {
5252
super();
5353

54-
this.editorOperation = this._register(new LongRunningOperation(localProgressService));
54+
this.editorOperation = this._register(new LongRunningOperation(editorProgressService));
5555
}
5656

5757
get activeControl(): IVisibleEditor | null {

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import { Themable, EDITOR_GROUP_HEADER_TABS_BORDER, EDITOR_GROUP_HEADER_TABS_BAC
2020
import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind, EditorsOrder, GroupsOrder, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
2121
import { TabsTitleControl } from 'vs/workbench/browser/parts/editor/tabsTitleControl';
2222
import { EditorControl } from 'vs/workbench/browser/parts/editor/editorControl';
23-
import { ILocalProgressService } from 'vs/platform/progress/common/progress';
24-
import { LocalProgressService } from 'vs/workbench/services/progress/browser/localProgressService';
23+
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
24+
import { EditorProgressService } from 'vs/workbench/services/progress/browser/editorProgressService';
2525
import { localize } from 'vs/nls';
2626
import { isPromiseCanceledError } from 'vs/base/common/errors';
2727
import { dispose, MutableDisposable } from 'vs/base/common/lifecycle';
@@ -178,7 +178,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
178178
const scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element));
179179
this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection(
180180
[IContextKeyService, scopedContextKeyService],
181-
[ILocalProgressService, new LocalProgressService(this.progressBar)]
181+
[IEditorProgressService, new EditorProgressService(this.progressBar)]
182182
));
183183

184184
// Context keys

0 commit comments

Comments
 (0)