files2 - adopt new methods

This commit is contained in:
Benjamin Pasero
2019-04-16 12:18:04 +02:00
parent 96d03958ae
commit 31ffdc0eb5
27 changed files with 106 additions and 112 deletions

View File

@@ -133,7 +133,7 @@ export class UserConfiguration extends Disposable {
async reload(): Promise<ConfigurationModel> {
try {
const content = await this.configurationFileService.resolveContent(this.configurationResource);
const content = await this.configurationFileService.readFile(this.configurationResource);
this.parser.parseContent(content);
return this.parser.configurationModel;
} catch (e) {
@@ -379,7 +379,7 @@ class FileServiceBasedWorkspaceConfiguration extends Disposable implements IWork
}
let contents = '';
try {
contents = await this.configurationFileService.resolveContent(this._workspaceIdentifier.configPath);
contents = await this.configurationFileService.readFile(this._workspaceIdentifier.configPath);
} catch (error) {
const exists = await this.configurationFileService.exists(this._workspaceIdentifier.configPath);
if (exists) {
@@ -547,7 +547,7 @@ class FileServiceBasedFolderConfiguration extends Disposable implements IFolderC
async loadConfiguration(): Promise<ConfigurationModel> {
const configurationContents = await Promise.all(this.configurationResources.map(async resource => {
try {
return await this.configurationFileService.resolveContent(resource);
return await this.configurationFileService.readFile(resource);
} catch (error) {
const exists = await this.configurationFileService.exists(resource);
if (exists) {

View File

@@ -49,7 +49,7 @@ export interface IConfigurationFileService {
whenProviderRegistered(scheme: string): Promise<void>;
watch(resource: URI): IDisposable;
exists(resource: URI): Promise<boolean>;
resolveContent(resource: URI): Promise<string>;
readFile(resource: URI): Promise<string>;
}
export class ConfigurationFileService implements IConfigurationFileService {
@@ -82,8 +82,8 @@ export class ConfigurationFileService implements IConfigurationFileService {
return this.fileService.exists(resource);
}
resolveContent(resource: URI): Promise<string> {
return this.fileService.resolveContent(resource, { encoding: 'utf8' }).then(content => content.value);
readFile(resource: URI): Promise<string> {
return this.fileService.readFile(resource).then(content => content.value.toString());
}
}

View File

@@ -51,9 +51,9 @@ export class ConfigurationFileService extends Disposable implements IConfigurati
return this._fileServiceBasedConfigurationFileService ? this._fileServiceBasedConfigurationFileService.exists(resource) : pfs.exists(resource.fsPath);
}
async resolveContent(resource: URI): Promise<string> {
async readFile(resource: URI): Promise<string> {
if (this._fileServiceBasedConfigurationFileService) {
return this._fileServiceBasedConfigurationFileService.resolveContent(resource);
return this._fileServiceBasedConfigurationFileService.readFile(resource);
} else {
const contents = await pfs.readFile(resource.fsPath);
return contents.toString();