Skip to content

Commit

Permalink
Stop splitting ; or : in defines and compilerArgs. (#8661)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-mcmanus authored Jan 12, 2022
1 parent 2b44312 commit 144845c
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,18 @@ export class CppProperties {
return result;
}

private resolve(entries: string[] | undefined, defaultValue: string[] | undefined, env: Environment): string[] {
let result: string[] = [];
if (entries) {
entries = this.resolveDefaults(entries, defaultValue);
entries.forEach(entry => {
const entryResolved: string = util.resolveVariables(entry, env);
result = result.concat(entryResolved);
});
}
return result;
}

private resolveAndSplit(paths: string[] | undefined, defaultValue: string[] | undefined, env: Environment): string[] {
let result: string[] = [];
if (paths) {
Expand All @@ -721,14 +733,24 @@ export class CppProperties {

private updateConfigurationStringArray(property: string[] | undefined, defaultValue: string[] | undefined, env: Environment): string[] | undefined {
if (property) {
return this.resolveAndSplit(property, defaultValue, env);
return this.resolve(property, defaultValue, env);
}
if (!property && defaultValue) {
return this.resolveAndSplit(defaultValue, [], env);
return this.resolve(defaultValue, [], env);
}
return property;
}

private updateConfigurationPathsArray(paths: string[] | undefined, defaultValue: string[] | undefined, env: Environment): string[] | undefined {
if (paths) {
return this.resolveAndSplit(paths, defaultValue, env);
}
if (!paths && defaultValue) {
return this.resolveAndSplit(defaultValue, [], env);
}
return paths;
}

private updateConfigurationStringOrBoolean(property: string | boolean | undefined | null, defaultValue: boolean | undefined | null, env: Environment): string | boolean | undefined {
if (!property || property === "${default}") {
property = defaultValue;
Expand Down Expand Up @@ -774,17 +796,17 @@ export class CppProperties {
for (let i: number = 0; i < this.configurationJson.configurations.length; i++) {
const configuration: Configuration = this.configurationJson.configurations[i];

configuration.includePath = this.updateConfigurationStringArray(configuration.includePath, settings.defaultIncludePath, env);
configuration.includePath = this.updateConfigurationPathsArray(configuration.includePath, settings.defaultIncludePath, env);
// in case includePath is reset below
const origIncludePath: string[] | undefined = configuration.includePath;
if (userSettings.addNodeAddonIncludePaths) {
const includePath: string[] = origIncludePath || [];
configuration.includePath = includePath.concat(this.nodeAddonIncludes.filter(i => includePath.indexOf(i) < 0));
}
configuration.defines = this.updateConfigurationStringArray(configuration.defines, settings.defaultDefines, env);
configuration.macFrameworkPath = this.updateConfigurationStringArray(configuration.macFrameworkPath, settings.defaultMacFrameworkPath, env);
configuration.macFrameworkPath = this.updateConfigurationPathsArray(configuration.macFrameworkPath, settings.defaultMacFrameworkPath, env);
configuration.windowsSdkVersion = this.updateConfigurationString(configuration.windowsSdkVersion, settings.defaultWindowsSdkVersion, env);
configuration.forcedInclude = this.updateConfigurationStringArray(configuration.forcedInclude, settings.defaultForcedInclude, env);
configuration.forcedInclude = this.updateConfigurationPathsArray(configuration.forcedInclude, settings.defaultForcedInclude, env);
configuration.compileCommands = this.updateConfigurationString(configuration.compileCommands, settings.defaultCompileCommands, env);
configuration.compilerArgs = this.updateConfigurationStringArray(configuration.compilerArgs, settings.defaultCompilerArgs, env);
configuration.cStandard = this.updateConfigurationString(configuration.cStandard, settings.defaultCStandard, env);
Expand Down Expand Up @@ -863,7 +885,7 @@ export class CppProperties {
}
}
} else {
configuration.browse.path = this.updateConfigurationStringArray(configuration.browse.path, settings.defaultBrowsePath, env);
configuration.browse.path = this.updateConfigurationPathsArray(configuration.browse.path, settings.defaultBrowsePath, env);
}

configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfigurationStringOrBoolean(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders, env);
Expand Down

0 comments on commit 144845c

Please sign in to comment.