in client/src/extension.ts [743:799]
public async update(): Promise<void> {
async function _update<T>(config: WorkspaceConfiguration, section: string, newValue: MigrationElement<T>, target: ConfigurationTarget): Promise<void> {
if (!newValue.changed) {
return;
}
await config.update(section, newValue.value, target);
}
async function _updateLanguageSetting(config: WorkspaceConfiguration, section: string, settings: LanguageSettings | undefined, newValue: MigrationElement<CodeActionsOnSave>, target: ConfigurationTarget): Promise<void> {
if (!newValue.changed) {
return;
}
if (settings === undefined) {
settings = Object.create(null) as object;
}
if (settings['editor.codeActionsOnSave'] === undefined) {
settings['editor.codeActionsOnSave'] = {};
}
settings['editor.codeActionsOnSave'] = newValue.value;
await config.update(section, settings, target);
}
try {
await _update(this.editorConfig, 'codeActionsOnSave', this.codeActionOnSave.global, ConfigurationTarget.Global);
await _update(this.editorConfig, 'codeActionsOnSave', this.codeActionOnSave.workspace, ConfigurationTarget.Workspace);
await _update(this.editorConfig, 'codeActionsOnSave', this.codeActionOnSave.workspaceFolder, ConfigurationTarget.WorkspaceFolder);
await _update(this.eslintConfig, 'autoFixOnSave', this.autoFixOnSave.global, ConfigurationTarget.Global);
await _update(this.eslintConfig, 'autoFixOnSave', this.autoFixOnSave.workspace, ConfigurationTarget.Workspace);
await _update(this.eslintConfig, 'autoFixOnSave', this.autoFixOnSave.workspaceFolder, ConfigurationTarget.WorkspaceFolder);
await _update(this.eslintConfig, 'validate', this.validate.global, ConfigurationTarget.Global);
await _update(this.eslintConfig, 'validate', this.validate.workspace, ConfigurationTarget.Workspace);
await _update(this.eslintConfig, 'validate', this.validate.workspaceFolder, ConfigurationTarget.WorkspaceFolder);
await _update(this.eslintConfig, 'workingDirectories', this.workingDirectories.global, ConfigurationTarget.Global);
await _update(this.eslintConfig, 'workingDirectories', this.workingDirectories.workspace, ConfigurationTarget.Workspace);
await _update(this.eslintConfig, 'workingDirectories', this.workingDirectories.workspaceFolder, ConfigurationTarget.WorkspaceFolder);
for (const language of this.languageSpecificSettings.keys()) {
const value = this.languageSpecificSettings.get(language)!;
if (MigrationData.needsUpdate(value)) {
const section = `[${language}]`;
const current = this.workspaceConfig.inspect<LanguageSettings>(section);
await _updateLanguageSetting(this.workspaceConfig, section, current?.globalValue, value.global, ConfigurationTarget.Global);
await _updateLanguageSetting(this.workspaceConfig, section, current?.workspaceValue, value.workspace, ConfigurationTarget.Workspace);
await _updateLanguageSetting(this.workspaceConfig, section, current?.workspaceFolderValue, value.workspaceFolder, ConfigurationTarget.WorkspaceFolder);
}
}
} finally {
if (this.didChangeConfiguration) {
this.didChangeConfiguration();
this.didChangeConfiguration = undefined;
}
}
}