in Extension/src/LanguageServer/settingsTracker.ts [38:88]
private collectSettings(filter: FilterFunction): { [key: string]: string } {
const settingsResourceScope: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", this.resource);
const settingsNonScoped: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp");
const selectCorrectlyScopedSettings = (rawSetting: any): vscode.WorkspaceConfiguration =>
(!rawSetting || rawSetting.scope === "resource" || rawSetting.scope === "machine-overridable") ? settingsResourceScope : settingsNonScoped;
const result: { [key: string]: string } = {};
for (const key in settingsResourceScope) {
const rawSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + key];
const correctlyScopedSettings: vscode.WorkspaceConfiguration = selectCorrectlyScopedSettings(rawSetting);
const val: any = this.getSetting(correctlyScopedSettings, key);
if (val === undefined) {
continue;
}
// Iterate through dotted "sub" settings.
const collectSettingsRecursive = (key: string, val: Object, depth: number) => {
if (depth > 4) {
// Limit settings recursion to 4 dots (not counting the first one in: `C_Cpp.`)
return;
}
for (const subKey in val) {
const newKey: string = key + "." + subKey;
const newRawSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + newKey];
const correctlyScopedSubSettings: vscode.WorkspaceConfiguration = selectCorrectlyScopedSettings(newRawSetting);
const subVal: any = this.getSetting(correctlyScopedSubSettings, newKey);
if (subVal === undefined) {
continue;
}
if (subVal instanceof Object && !(subVal instanceof Array)) {
collectSettingsRecursive(newKey, subVal, depth + 1);
} else {
const entry: KeyValuePair | undefined = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter);
if (entry && entry.key && entry.value) {
result[entry.key] = entry.value;
}
}
}
};
if (val instanceof Object && !(val instanceof Array)) {
collectSettingsRecursive(key, val, 1);
continue;
}
const entry: KeyValuePair | undefined = this.filterAndSanitize(key, val, correctlyScopedSettings, filter);
if (entry && entry.key && entry.value) {
result[entry.key] = entry.value;
}
}
return result;
}