Skip to content

Commit

Permalink
Correct package.json syntax and refactor settings.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
browntarik committed Jul 31, 2024
1 parent b317f9a commit 2405597
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
18 changes: 7 additions & 11 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -823,18 +823,14 @@
"scope": "resource"
},
"C_Cpp.default.browse.path": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
{
"type": null
}
"type": [
"array",
"null"
],
"items": {
"type": "string"
},
"uniqueItems": true,
"default": null,
"markdownDescription": "%c_cpp.configuration.default.browse.path.markdownDescription%",
"scope": "machine-overridable"
Expand Down
29 changes: 14 additions & 15 deletions Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,19 @@ class Settings {
public getArrayOfStringsWithUndefinedDefault(section: string, allowNull: boolean): string[] | undefined | null;
public getArrayOfStringsWithUndefinedDefault(section: string, allowNull: boolean = false): string[] | undefined | null {
const info: any = this.settings.inspect<string[]>(section);
if (allowNull && info === null) {
return null;
}
if (info.workspaceFolderValue !== undefined) {
if (isArrayOfString(info.workspaceFolderValue)) {
if ((allowNull && info.workspaceFolderValue == null) || isArrayOfString(info.workspaceFolderValue)) {

Check failure on line 189 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 189 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 189 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='
return info.workspaceFolderValue;
}
} else if (info.workspaceValue !== undefined) {
}

if ((allowNull && info.workspaceValue == null) || info.workspaceValue !== undefined) {

Check failure on line 194 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 194 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 194 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='
if (isArrayOfString(info.workspaceValue)) {
return info.workspaceValue;
}
} else if (info.globalValue !== undefined) {
}

Check failure on line 198 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

Check failure on line 198 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

Check failure on line 198 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

if ((allowNull && info.globalValue == null) || info.globalValue !== undefined) {

Check failure on line 200 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 200 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='

Check failure on line 200 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Expected '===' and instead saw '=='
if (isArrayOfString(info.globalValue)) {
return info.globalValue;
}
Expand All @@ -211,11 +212,15 @@ class Settings {
if (isString(info.workspaceFolderValue)) {
return info.workspaceFolderValue;
}
} else if (info.workspaceValue !== undefined) {
}

Check failure on line 215 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

Check failure on line 215 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

Check failure on line 215 in Extension/src/LanguageServer/settings.ts

View workflow job for this annotation

GitHub Actions / job / build

Trailing spaces not allowed

if (info.workspaceValue !== undefined) {
if (isString(info.workspaceValue)) {
return info.workspaceValue;
}
} else if (info.globalValue !== undefined) {
}

if (info.globalValue !== undefined) {
if (isString(info.globalValue)) {
return info.globalValue;
}
Expand Down Expand Up @@ -340,7 +345,7 @@ export class CppSettings extends Settings {
public get clangTidyEnabled(): boolean { return this.getAsBoolean("codeAnalysis.clangTidy.enabled"); }
public get clangTidyConfig(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("codeAnalysis.clangTidy.config")); }
public get clangTidyFallbackConfig(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("codeAnalysis.clangTidy.fallbackConfig")); }
public get clangTidyHeaderFilter(): string | undefined { return this.getAsStringOrUndefined("codeAnalysis.clangTidy.headerFilter") ?? undefined; }
public get clangTidyHeaderFilter(): string | undefined { return this.getAsStringOrUndefined("codeAnalysis.clangTidy.headerFilter"); }
public get clangTidyArgs(): string[] { return this.getAsArrayOfStrings("codeAnalysis.clangTidy.args"); }
public get clangTidyUseBuildPath(): boolean { return this.getAsBoolean("codeAnalysis.clangTidy.useBuildPath"); }
public get clangTidyChecksEnabled(): string[] { return this.getAsArrayOfStrings("codeAnalysis.clangTidy.checks.enabled", true); }
Expand Down Expand Up @@ -520,9 +525,6 @@ export class CppSettings extends Settings {
// Returns the value of a setting as a string with proper type validation and checks for valid enum values while returning an undefined value if neccessary.
private getAsStringOrUndefined(settingName: string): string | undefined {
const value: any = super.Section.get<string | null>(settingName);
if (value === undefined) {
return undefined;
}
if (this.isValidEnum(settingName, value)) {
return value;
} else if (isString(value)) {
Expand All @@ -536,9 +538,6 @@ export class CppSettings extends Settings {
// Returns the value of a setting as a boolean with proper type validation and checks for valid enum values while returning an undefined value if neccessary.
private getAsBooleanOrUndefined(settingName: string): boolean | undefined {
const value: any = super.Section.get<boolean | null>(settingName);
if (value === undefined) {
return undefined;
}
if (isBoolean(value)) {
return value;
} else {
Expand Down

0 comments on commit 2405597

Please sign in to comment.