Skip to content

Commit

Permalink
Merge pull request #8663 from microsoft/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms authored Jan 12, 2022
2 parents 29e8ff6 + 4f2b7e2 commit 7b175d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"license": "SEE LICENSE IN LICENSE.txt",
"engines": {
"vscode": "^1.61.0"
"vscode": "^1.63.0"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-cpptools/issues",
Expand Down
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 7b175d4

Please sign in to comment.