private filterAndSanitize()

in Extension/src/LanguageServer/settingsTracker.ts [141:201]


    private filterAndSanitize(key: string, val: any, settings: vscode.WorkspaceConfiguration, filter: FilterFunction): KeyValuePair | undefined {
        if (filter(key, val, settings)) {
            let value: string;
            this.previousCppSettings[key] = val;
            switch (key) {
                case "clang_format_style":
                case "clang_format_fallbackStyle": {
                    const newKey: string = key + "2";
                    if (val) {
                        switch (String(val).toLowerCase()) {
                            case "emulated visual studio":
                            case "visual studio":
                            case "llvm":
                            case "google":
                            case "chromium":
                            case "mozilla":
                            case "webkit":
                            case "file":
                            case "none": {
                                value = String(this.previousCppSettings[key]);
                                break;
                            }
                            default: {
                                value = "...";
                                break;
                            }
                        }
                    } else {
                        value = "null";
                    }
                    key = newKey;
                    break;
                }
                case "commentContinuationPatterns": {
                    key = "commentContinuationPatterns2";
                    value = this.areEqual(val, settings.inspect(key)?.defaultValue) ? "<default>" : "..."; // Track whether it's being used, but nothing specific about it.
                    break;
                }
                default: {
                    if (key === "clang_format_path" || key === "intelliSenseCachePath" || key.startsWith("default.")
                        || key === "codeAnalysis.clangTidy.path"
                        || key === "codeAnalysis.clangTidy.headerFilter" || key === "codeAnalysis.clangTidy.args"
                        || key === "codeAnalysis.clangTidy.config" || key === "codeAnalysis.clangTidy.fallbackConfig"

                        // Note: An existing bug prevents these settings of type "object" from getting processed here,
                        // so these checks are here just in case that bug gets fixed later on.
                        || key === "files.exclude" || key === "codeAnalysis.exclude"
                    ) {
                        value = this.areEqual(val, settings.inspect(key)?.defaultValue) ? "<default>" : "..."; // Track whether it's being used, but nothing specific about it.
                    } else {
                        value = String(this.previousCppSettings[key]);
                    }
                }
            }
            if (value && value.length > maxSettingLengthForTelemetry) {
                value = value.substr(0, maxSettingLengthForTelemetry) + "...";
            }
            return {key: key, value: value};
        }
        return undefined;
    }