Skip to content

Commit 31ffdc0

Browse files
author
Benjamin Pasero
committed
files2 - adopt new methods
1 parent 96d0395 commit 31ffdc0

27 files changed

Lines changed: 106 additions & 112 deletions

File tree

src/vs/platform/files/common/files.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ export interface IFileService {
101101
*/
102102
exists(resource: URI): Promise<boolean>;
103103

104-
/**
105-
* @deprecated use readFile() instead.
106-
*/
107-
resolveContent(resource: URI, options?: IReadTextFileOptions): Promise<IContent>;
108-
109104
/**
110105
* Read the contents of the provided resource unbuffered.
111106
*/
@@ -1203,6 +1198,4 @@ export interface ILegacyFileService extends IDisposable {
12031198
onAfterOperation: Event<FileOperationEvent>;
12041199

12051200
registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable;
1206-
1207-
resolveContent(resource: URI, options?: IReadTextFileOptions): Promise<IContent>;
12081201
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
1515
import { ResourceViewerContext, ResourceViewer } from 'vs/workbench/browser/parts/editor/resourceViewer';
1616
import { URI } from 'vs/base/common/uri';
1717
import { Dimension, size, clearNode } from 'vs/base/browser/dom';
18-
import { IFileService } from 'vs/platform/files/common/files';
18+
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
1919
import { CancellationToken } from 'vs/base/common/cancellation';
2020
import { dispose } from 'vs/base/common/lifecycle';
2121
import { IStorageService } from 'vs/platform/storage/common/storage';
@@ -47,7 +47,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
4747
callbacks: IOpenCallbacks,
4848
telemetryService: ITelemetryService,
4949
themeService: IThemeService,
50-
@IFileService private readonly _fileService: IFileService,
50+
@ITextFileService private readonly textFileService: ITextFileService,
5151
@IStorageService storageService: IStorageService
5252
) {
5353
super(id, telemetryService, themeService, storageService);
@@ -89,7 +89,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
8989
// Render Input
9090
this.resourceViewerContext = ResourceViewer.show(
9191
{ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag(), mime: model.getMime() },
92-
this._fileService,
92+
this.textFileService,
9393
this.binaryContainer,
9494
this.scrollbar,
9595
resource => this.handleOpenInternalCallback(input, options),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ export class ChangeEncodingAction extends Action {
11441144
@IEditorService private readonly editorService: IEditorService,
11451145
@IQuickInputService private readonly quickInputService: IQuickInputService,
11461146
@ITextResourceConfigurationService private readonly textResourceConfigurationService: ITextResourceConfigurationService,
1147-
@IFileService private readonly fileService: IFileService
1147+
@IFileService private readonly fileService: IFileService,
1148+
@ITextFileService private readonly textFileService: ITextFileService
11481149
) {
11491150
super(actionId, actionLabel);
11501151
}
@@ -1195,7 +1196,7 @@ export class ChangeEncodingAction extends Action {
11951196
return Promise.resolve(null); // encoding detection only possible for resources the file service can handle
11961197
}
11971198

1198-
return this.fileService.resolveContent(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null);
1199+
return this.textFileService.read(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null);
11991200
})
12001201
.then((guessedEncoding: string) => {
12011202
const isReopenWithEncoding = (action === reopenWithEncodingPick);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Action } from 'vs/base/common/actions';
2121
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2222
import { memoize } from 'vs/base/common/decorators';
2323
import * as platform from 'vs/base/common/platform';
24-
import { IFileService } from 'vs/platform/files/common/files';
24+
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
2525

2626
export interface IResourceDescriptor {
2727
readonly resource: URI;
@@ -72,7 +72,7 @@ export class ResourceViewer {
7272

7373
static show(
7474
descriptor: IResourceDescriptor,
75-
fileService: IFileService,
75+
textFileService: ITextFileService,
7676
container: HTMLElement,
7777
scrollbar: DomScrollableElement,
7878
openInternalClb: (uri: URI) => void,
@@ -85,7 +85,7 @@ export class ResourceViewer {
8585

8686
// Images
8787
if (ResourceViewer.isImageResource(descriptor)) {
88-
return ImageView.create(container, descriptor, fileService, scrollbar, openExternalClb, metadataClb);
88+
return ImageView.create(container, descriptor, textFileService, scrollbar, openExternalClb, metadataClb);
8989
}
9090

9191
// Large Files
@@ -114,13 +114,13 @@ class ImageView {
114114
static create(
115115
container: HTMLElement,
116116
descriptor: IResourceDescriptor,
117-
fileService: IFileService,
117+
textFileService: ITextFileService,
118118
scrollbar: DomScrollableElement,
119119
openExternalClb: (uri: URI) => void,
120120
metadataClb: (meta: string) => void
121121
): ResourceViewerContext {
122122
if (ImageView.shouldShowImageInline(descriptor)) {
123-
return InlineImageView.create(container, descriptor, fileService, scrollbar, metadataClb);
123+
return InlineImageView.create(container, descriptor, textFileService, scrollbar, metadataClb);
124124
}
125125

126126
return LargeImageView.create(container, descriptor, openExternalClb, metadataClb);
@@ -357,7 +357,7 @@ class InlineImageView {
357357
static create(
358358
container: HTMLElement,
359359
descriptor: IResourceDescriptor,
360-
fileService: IFileService,
360+
textFileService: ITextFileService,
361361
scrollbar: DomScrollableElement,
362362
metadataClb: (meta: string) => void
363363
) {
@@ -559,7 +559,7 @@ class InlineImageView {
559559
}
560560
}));
561561

562-
InlineImageView.imageSrc(descriptor, fileService).then(dataUri => {
562+
InlineImageView.imageSrc(descriptor, textFileService).then(dataUri => {
563563
const imgs = container.getElementsByTagName('img');
564564
if (imgs.length) {
565565
imgs[0].src = dataUri;
@@ -569,12 +569,12 @@ class InlineImageView {
569569
return context;
570570
}
571571

572-
private static imageSrc(descriptor: IResourceDescriptor, fileService: IFileService): Promise<string> {
572+
private static imageSrc(descriptor: IResourceDescriptor, textFileService: ITextFileService): Promise<string> {
573573
if (descriptor.resource.scheme === Schemas.data) {
574574
return Promise.resolve(descriptor.resource.toString(true /* skip encoding */));
575575
}
576576

577-
return fileService.resolveContent(descriptor.resource, { encoding: 'base64' }).then(data => {
577+
return textFileService.read(descriptor.resource, { encoding: 'base64' }).then(data => {
578578
const mime = getMime(descriptor);
579579

580580
return `data:${mime};base64,${data.value}`;

src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class LanguageConfigurationFileHandler {
9797
}
9898

9999
private _handleConfigFile(languageIdentifier: LanguageIdentifier, configFileLocation: URI): void {
100-
this._fileService.resolveContent(configFileLocation, { encoding: 'utf8' }).then((contents) => {
100+
this._fileService.readFile(configFileLocation).then((contents) => {
101101
const errors: ParseError[] = [];
102102
const configuration = <ILanguageConfiguration>parse(contents.value.toString(), errors);
103103
if (errors.length) {

src/vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ class Launch extends AbstractLaunch implements ILaunch {
559559
const resource = this.uri;
560560
let created = false;
561561

562-
return this.fileService.resolveContent(resource).then(content => content.value, err => {
562+
return this.fileService.readFile(resource).then(content => content.value, err => {
563563
// launch.json not found: create one by collecting launch configs from debugConfigProviders
564564
return this.configurationManager.guessDebugger(type).then(adapter => {
565565
if (adapter) {
@@ -585,10 +585,11 @@ class Launch extends AbstractLaunch implements ILaunch {
585585
if (!content) {
586586
return { editor: null, created: false };
587587
}
588-
const index = content.indexOf(`"${this.configurationManager.selectedConfiguration.name}"`);
588+
const contentValue = content.toString();
589+
const index = contentValue.indexOf(`"${this.configurationManager.selectedConfiguration.name}"`);
589590
let startLineNumber = 1;
590591
for (let i = 0; i < index; i++) {
591-
if (content.charAt(i) === '\n') {
592+
if (contentValue.charAt(i) === '\n') {
592593
startLineNumber++;
593594
}
594595
}

src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { IExperimentService, ExperimentActionType, ExperimentState } from 'vs/wo
4545
import { CancellationToken } from 'vs/base/common/cancellation';
4646
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
4747
import { extname } from 'vs/base/common/resources';
48+
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
4849

4950
const milliSecondsInADay = 1000 * 60 * 60 * 24;
5051
const choiceNever = localize('neverShowAgain', "Don't Show Again");
@@ -108,6 +109,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
108109
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
109110
@IExtensionsWorkbenchService private readonly extensionWorkbenchService: IExtensionsWorkbenchService,
110111
@IExperimentService private readonly experimentService: IExperimentService,
112+
@ITextFileService private readonly textFileService: ITextFileService
111113
) {
112114
super();
113115

@@ -325,8 +327,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
325327
return Promise.resolve(null);
326328
}
327329

328-
return Promise.resolve(this.fileService.resolveContent(workspace.configuration)
329-
.then(content => <IExtensionsConfigContent>(json.parse(content.value)['extensions']), err => null));
330+
return Promise.resolve(this.fileService.readFile(workspace.configuration)
331+
.then(content => <IExtensionsConfigContent>(json.parse(content.value.toString())['extensions']), err => null));
330332
}
331333

332334
/**
@@ -336,8 +338,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
336338
const extensionsJsonUri = workspaceFolder.toResource(EXTENSIONS_CONFIG);
337339

338340
return Promise.resolve(this.fileService.resolve(extensionsJsonUri)
339-
.then(() => this.fileService.resolveContent(extensionsJsonUri))
340-
.then(content => <IExtensionsConfigContent>json.parse(content.value), err => null));
341+
.then(() => this.fileService.readFile(extensionsJsonUri))
342+
.then(content => <IExtensionsConfigContent>json.parse(content.value.toString()), err => null));
341343
}
342344

343345
/**
@@ -956,7 +958,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
956958

957959
const storageKey = 'extensionsAssistant/dynamicWorkspaceRecommendations';
958960
const workspaceUri = this.contextService.getWorkspace().folders[0].uri;
959-
return Promise.all([getHashedRemotesFromUri(workspaceUri, this.fileService, false), getHashedRemotesFromUri(workspaceUri, this.fileService, true)]).then(([hashedRemotes1, hashedRemotes2]) => {
961+
return Promise.all([getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, false), getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, true)]).then(([hashedRemotes1, hashedRemotes2]) => {
960962
const hashedRemotes = (hashedRemotes1 || []).concat(hashedRemotes2 || []);
961963
if (!hashedRemotes.length) {
962964
return undefined;

src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
2222
import { ShowViewletAction } from 'vs/workbench/browser/viewlet';
2323
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
2424
import { Query } from 'vs/workbench/contrib/extensions/common/extensionQuery';
25-
import { IFileService, IContent } from 'vs/platform/files/common/files';
25+
import { IFileService, IFileContent } from 'vs/platform/files/common/files';
2626
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
2727
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
2828
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -2031,7 +2031,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
20312031

20322032
protected openWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise<any> {
20332033
return this.getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile)
2034-
.then(content => this.getSelectionPosition(content.value, content.resource, ['extensions', 'recommendations']))
2034+
.then(content => this.getSelectionPosition(content.value.toString(), content.resource, ['extensions', 'recommendations']))
20352035
.then(selection => this.editorService.openEditor({
20362036
resource: workspaceConfigurationFile,
20372037
options: {
@@ -2045,7 +2045,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
20452045
return this.getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile)
20462046
.then(content => {
20472047
const extensionIdLowerCase = extensionId.toLowerCase();
2048-
const workspaceExtensionsConfigContent: IExtensionsConfigContent = (json.parse(content.value) || {})['extensions'] || {};
2048+
const workspaceExtensionsConfigContent: IExtensionsConfigContent = (json.parse(content.value.toString()) || {})['extensions'] || {};
20492049
let insertInto = shouldRecommend ? workspaceExtensionsConfigContent.recommendations || [] : workspaceExtensionsConfigContent.unwantedRecommendations || [];
20502050
let removeFrom = shouldRecommend ? workspaceExtensionsConfigContent.unwantedRecommendations || [] : workspaceExtensionsConfigContent.recommendations || [];
20512051

@@ -2105,26 +2105,26 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
21052105
}
21062106

21072107
protected getWorkspaceExtensionsConfigContent(extensionsFileResource: URI): Promise<IExtensionsConfigContent> {
2108-
return Promise.resolve(this.fileService.resolveContent(extensionsFileResource))
2108+
return Promise.resolve(this.fileService.readFile(extensionsFileResource))
21092109
.then(content => {
2110-
return (json.parse(content.value) || {})['extensions'] || {};
2110+
return (json.parse(content.value.toString()) || {})['extensions'] || {};
21112111
}, err => ({ recommendations: [], unwantedRecommendations: [] }));
21122112
}
21132113

21142114
protected getWorkspaceFolderExtensionsConfigContent(extensionsFileResource: URI): Promise<IExtensionsConfigContent> {
2115-
return Promise.resolve(this.fileService.resolveContent(extensionsFileResource))
2115+
return Promise.resolve(this.fileService.readFile(extensionsFileResource))
21162116
.then(content => {
2117-
return (<IExtensionsConfigContent>json.parse(content.value));
2117+
return (<IExtensionsConfigContent>json.parse(content.value.toString()));
21182118
}, err => ({ recommendations: [], unwantedRecommendations: [] }));
21192119
}
21202120

2121-
private getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise<IContent> {
2122-
return Promise.resolve(this.fileService.resolveContent(workspaceConfigurationFile))
2121+
private getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise<IFileContent> {
2122+
return Promise.resolve(this.fileService.readFile(workspaceConfigurationFile))
21232123
.then(content => {
2124-
const workspaceRecommendations = <IExtensionsConfigContent>json.parse(content.value)['extensions'];
2124+
const workspaceRecommendations = <IExtensionsConfigContent>json.parse(content.value.toString())['extensions'];
21252125
if (!workspaceRecommendations || !workspaceRecommendations.recommendations) {
21262126
return this.jsonEditingService.write(workspaceConfigurationFile, { key: 'extensions', value: { recommendations: [] } }, true)
2127-
.then(() => this.fileService.resolveContent(workspaceConfigurationFile));
2127+
.then(() => this.fileService.readFile(workspaceConfigurationFile));
21282128
}
21292129
return content;
21302130
});
@@ -2153,8 +2153,8 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
21532153
}
21542154

21552155
private getOrCreateExtensionsFile(extensionsFileResource: URI): Promise<{ created: boolean, extensionsFileResource: URI, content: string }> {
2156-
return Promise.resolve(this.fileService.resolveContent(extensionsFileResource)).then(content => {
2157-
return { created: false, extensionsFileResource, content: content.value };
2156+
return Promise.resolve(this.fileService.readFile(extensionsFileResource)).then(content => {
2157+
return { created: false, extensionsFileResource, content: content.value.toString() };
21582158
}, err => {
21592159
return this.textFileService.write(extensionsFileResource, ExtensionsConfigurationInitialContent).then(() => {
21602160
return { created: true, extensionsFileResource, content: ExtensionsConfigurationInitialContent };

src/vs/workbench/contrib/extensions/node/extensionsWorkbenchService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Extension implements IExtension {
236236
}
237237

238238
if (this.local && this.local.readmeUrl) {
239-
return this.fileService.resolveContent(this.local.readmeUrl, { encoding: 'utf8' }).then(content => content.value);
239+
return this.fileService.readFile(this.local.readmeUrl).then(content => content.value.toString());
240240
}
241241

242242
if (this.type === ExtensionType.System) {
@@ -277,7 +277,7 @@ ${this.description}
277277
return Promise.reject(new Error('not available'));
278278
}
279279

280-
return this.fileService.resolveContent(changelogUrl, { encoding: 'utf8' }).then(content => content.value);
280+
return this.fileService.readFile(changelogUrl).then(content => content.value.toString());
281281
}
282282

283283
get dependencies(): string[] {

src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
1212
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
1313
import { URI } from 'vs/base/common/uri';
1414
import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
15-
import { IFileService } from 'vs/platform/files/common/files';
1615
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1716
import { IStorageService } from 'vs/platform/storage/common/storage';
17+
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
1818

1919
/**
2020
* An implementation of editor for binary files like images.
@@ -26,10 +26,10 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
2626
constructor(
2727
@ITelemetryService telemetryService: ITelemetryService,
2828
@IThemeService themeService: IThemeService,
29-
@IFileService fileService: IFileService,
3029
@IWindowsService private readonly windowsService: IWindowsService,
3130
@IEditorService private readonly editorService: IEditorService,
32-
@IStorageService storageService: IStorageService
31+
@IStorageService storageService: IStorageService,
32+
@ITextFileService textFileService: ITextFileService
3333
) {
3434
super(
3535
BinaryFileEditor.ID,
@@ -39,7 +39,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
3939
},
4040
telemetryService,
4141
themeService,
42-
fileService,
42+
textFileService,
4343
storageService
4444
);
4545
}

0 commit comments

Comments
 (0)