Skip to content

Commit d33df69

Browse files
committed
debt - adopt UriDisplayService for reference search
1 parent 2ba14ee commit d33df69

5 files changed

Lines changed: 15 additions & 62 deletions

File tree

src/vs/editor/contrib/referenceSearch/referencesController.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,16 @@ import { onUnexpectedError } from 'vs/base/common/errors';
99
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
1010
import { TPromise } from 'vs/base/common/winjs.base';
1111
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
12-
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
12+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1414
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
15-
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
1615
import { IStorageService } from 'vs/platform/storage/common/storage';
1716
import * as editorCommon from 'vs/editor/common/editorCommon';
1817
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1918
import { ReferencesModel } from './referencesModel';
2019
import { ReferenceWidget, LayoutData } from './referencesWidget';
2120
import { Range } from 'vs/editor/common/core/range';
22-
import { ITextModelService } from 'vs/editor/common/services/resolverService';
23-
import { IThemeService } from 'vs/platform/theme/common/themeService';
2421
import { Position } from 'vs/editor/common/core/position';
25-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
2622
import { Location } from 'vs/editor/common/modes';
2723
import { INotificationService } from 'vs/platform/notification/common/notification';
2824
import { CancelablePromise } from 'vs/base/common/async';
@@ -56,14 +52,10 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
5652
editor: ICodeEditor,
5753
@IContextKeyService contextKeyService: IContextKeyService,
5854
@ICodeEditorService private readonly _editorService: ICodeEditorService,
59-
@ITextModelService private readonly _textModelResolverService: ITextModelService,
6055
@INotificationService private readonly _notificationService: INotificationService,
6156
@IInstantiationService private readonly _instantiationService: IInstantiationService,
62-
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
6357
@IStorageService private readonly _storageService: IStorageService,
64-
@IThemeService private readonly _themeService: IThemeService,
6558
@IConfigurationService private readonly _configurationService: IConfigurationService,
66-
@optional(IEnvironmentService) private _environmentService: IEnvironmentService
6759
) {
6860
this._editor = editor;
6961
this._referenceSearchVisible = ctxReferenceSearchVisible.bindTo(contextKeyService);
@@ -106,7 +98,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
10698
}));
10799
const storageKey = 'peekViewLayout';
108100
const data = <LayoutData>JSON.parse(this._storageService.get(storageKey, undefined, '{}'));
109-
this._widget = new ReferenceWidget(this._editor, this._defaultTreeKeyboardSupport, data, this._textModelResolverService, this._contextService, this._themeService, this._instantiationService, this._environmentService);
101+
this._widget = this._instantiationService.createInstance(ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, data);
110102
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
111103
this._widget.show(range);
112104
this._disposables.push(this._widget.onDidClose(() => {

src/vs/editor/contrib/referenceSearch/referencesModel.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { localize } from 'vs/nls';
88
import { Event, Emitter } from 'vs/base/common/event';
9-
import { basename, dirname } from 'vs/base/common/paths';
9+
import { basename } from 'vs/base/common/paths';
1010
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
1111
import * as strings from 'vs/base/common/strings';
1212
import URI from 'vs/base/common/uri';
@@ -46,14 +46,6 @@ export class OneReference {
4646
return this._parent.uri;
4747
}
4848

49-
public get name(): string {
50-
return this._parent.name;
51-
}
52-
53-
public get directory(): string {
54-
return this._parent.directory;
55-
}
56-
5749
public get range(): IRange {
5850
return this._range;
5951
}
@@ -135,14 +127,6 @@ export class FileReferences implements IDisposable {
135127
return this._uri;
136128
}
137129

138-
public get name(): string {
139-
return basename(this.uri.fsPath);
140-
}
141-
142-
public get directory(): string {
143-
return dirname(this.uri.fsPath);
144-
}
145-
146130
public get preview(): FilePreview {
147131
return this._preview;
148132
}

src/vs/editor/contrib/referenceSearch/referencesWidget.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import 'vs/css!./media/referencesWidget';
88
import * as nls from 'vs/nls';
99
import { onUnexpectedError } from 'vs/base/common/errors';
10-
import { getPathLabel } from 'vs/base/common/labels';
1110
import { Event, Emitter } from 'vs/base/common/event';
1211
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
1312
import { Schemas } from 'vs/base/common/network';
@@ -44,6 +43,9 @@ import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser
4443
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
4544
import { Location } from 'vs/editor/common/modes';
4645
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
46+
import { IUriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
47+
import { dirname, basenameOrAuthority } from 'vs/base/common/resources';
48+
4749

4850
class DecorationsManager implements IDisposable {
4951

@@ -530,11 +532,10 @@ export class ReferenceWidget extends PeekViewWidget {
530532
editor: ICodeEditor,
531533
private _defaultTreeKeyboardSupport: boolean,
532534
public layoutData: LayoutData,
533-
private _textModelResolverService: ITextModelService,
534-
private _contextService: IWorkspaceContextService,
535-
themeService: IThemeService,
536-
private _instantiationService: IInstantiationService,
537-
private _environmentService: IEnvironmentService
535+
@IThemeService themeService: IThemeService,
536+
@ITextModelService private _textModelResolverService: ITextModelService,
537+
@IInstantiationService private _instantiationService: IInstantiationService,
538+
@IUriDisplayService private _uriDisplay: IUriDisplayService
538539
) {
539540
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true });
540541

@@ -780,7 +781,7 @@ export class ReferenceWidget extends PeekViewWidget {
780781

781782
// Update widget header
782783
if (reference.uri.scheme !== Schemas.inMemory) {
783-
this.setTitle(reference.name, getPathLabel(reference.directory, this._environmentService, this._contextService));
784+
this.setTitle(basenameOrAuthority(reference.uri), this._uriDisplay.getLabel(dirname(reference.uri), false));
784785
} else {
785786
this.setTitle(nls.localize('peekView.alternateTitle', "References"));
786787
}

src/vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
'use strict';
66

77
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
8-
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
8+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
99
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1010
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
11-
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
1211
import { IStorageService } from 'vs/platform/storage/common/storage';
1312
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1413
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
15-
import { ITextModelService } from 'vs/editor/common/services/resolverService';
16-
import { IThemeService } from 'vs/platform/theme/common/themeService';
17-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1814
import { INotificationService } from 'vs/platform/notification/common/notification';
1915
import { ReferencesController } from 'vs/editor/contrib/referenceSearch/referencesController';
2016

@@ -24,28 +20,20 @@ export class StandaloneReferencesController extends ReferencesController {
2420
editor: ICodeEditor,
2521
@IContextKeyService contextKeyService: IContextKeyService,
2622
@ICodeEditorService editorService: ICodeEditorService,
27-
@ITextModelService textModelResolverService: ITextModelService,
2823
@INotificationService notificationService: INotificationService,
2924
@IInstantiationService instantiationService: IInstantiationService,
30-
@IWorkspaceContextService contextService: IWorkspaceContextService,
3125
@IStorageService storageService: IStorageService,
32-
@IThemeService themeService: IThemeService,
3326
@IConfigurationService configurationService: IConfigurationService,
34-
@optional(IEnvironmentService) environmentService: IEnvironmentService
3527
) {
3628
super(
3729
true,
3830
editor,
3931
contextKeyService,
4032
editorService,
41-
textModelResolverService,
4233
notificationService,
4334
instantiationService,
44-
contextService,
4535
storageService,
46-
themeService,
4736
configurationService,
48-
environmentService
4937
);
5038
}
5139
}

src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
7+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
88
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
99
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
10-
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
1110
import { IStorageService } from 'vs/platform/storage/common/storage';
1211
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1312
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
14-
import { ITextModelService } from 'vs/editor/common/services/resolverService';
15-
import { IThemeService } from 'vs/platform/theme/common/themeService';
16-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1713
import { INotificationService } from 'vs/platform/notification/common/notification';
1814
import { ReferencesController } from 'vs/editor/contrib/referenceSearch/referencesController';
1915
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
@@ -23,29 +19,21 @@ export class WorkbenchReferencesController extends ReferencesController {
2319
public constructor(
2420
editor: ICodeEditor,
2521
@IContextKeyService contextKeyService: IContextKeyService,
26-
@ICodeEditorService codeEditorService: ICodeEditorService,
27-
@ITextModelService textModelResolverService: ITextModelService,
22+
@ICodeEditorService editorService: ICodeEditorService,
2823
@INotificationService notificationService: INotificationService,
2924
@IInstantiationService instantiationService: IInstantiationService,
30-
@IWorkspaceContextService contextService: IWorkspaceContextService,
3125
@IStorageService storageService: IStorageService,
32-
@IThemeService themeService: IThemeService,
3326
@IConfigurationService configurationService: IConfigurationService,
34-
@optional(IEnvironmentService) environmentService: IEnvironmentService
3527
) {
3628
super(
3729
false,
3830
editor,
3931
contextKeyService,
40-
codeEditorService,
41-
textModelResolverService,
32+
editorService,
4233
notificationService,
4334
instantiationService,
44-
contextService,
4535
storageService,
46-
themeService,
4736
configurationService,
48-
environmentService
4937
);
5038
}
5139
}

0 commit comments

Comments
 (0)