MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / getAsString

Method getAsString

Extension/src/LanguageServer/settings.ts:610–632  ·  view source on GitHub ↗
(settingName: string, allowNull: boolean = false)

Source from the content-addressed store, hash-verified

608 private getAsString(settingName: string): string;
609 private getAsString(settingName: string, allowNull: boolean): string | null;
610 private getAsString(settingName: string, allowNull: boolean = false): string | null {
611 const value: any = super.Section.get<any>(settingName);
612 const setting = getRawSetting("C_Cpp." + settingName, true);
613 if (!this.isValidDefault(isString, setting.default, allowNull)) {
614 console.error(`Default value for ${settingName} is expected to be string${allowNull ? ' or null' : ''}.`);
615 }
616
617 if (allowNull && value === null) {
618 return null;
619 }
620
621 if (setting.enum !== undefined) {
622 if (settingName === "loggingLevel" && isString(value) && isNumber(Number(value)) && Number(value) >= 0) {
623 return value;
624 }
625 if (this.isValidEnum(setting.enum, value)) {
626 return value;
627 }
628 } else if (isString(value)) {
629 return value;
630 }
631 return setting.default as string;
632 }
633
634 // Returns the value of a setting as a number with proper type validation and checks if value falls within the specified range.
635 private getAsNumber(settingName: string): number;

Callers 15

clangTidyHeaderFilterMethod · 0.95
clangFormatStyleMethod · 0.95
experimentalFeaturesMethod · 0.95
intelliSenseEngineMethod · 0.95
errorSquigglesMethod · 0.95
autocompleteMethod · 0.95
loggingLevelMethod · 0.95
workspaceSymbolsMethod · 0.95
exclusionPolicyMethod · 0.95

Calls 7

isValidDefaultMethod · 0.95
isValidEnumMethod · 0.95
getRawSettingFunction · 0.90
isStringFunction · 0.90
isNumberFunction · 0.90
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected