Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f4694c5
Work in progress
Colengms Mar 14, 2025
ab635e9
Add defaults
Colengms Mar 14, 2025
951f442
Finish plugging into config UI
Colengms Mar 14, 2025
d6b7eef
Update a setting description
Colengms Mar 14, 2025
981e887
Merge branch 'main' into coleng/recursive_includes_settings
Colengms Mar 14, 2025
99bd55c
Add 'order' setting (depthFirst|breadthFirst)
Colengms Mar 15, 2025
db61e5a
Merge branch 'coleng/recursive_includes_settings' of https://github.c…
Colengms Mar 15, 2025
e3a3d7c
Merge branch 'main' into coleng/recursive_includes_settings
Colengms Mar 15, 2025
62f6213
Add requireHeaders config field
Colengms Mar 17, 2025
a8d4da6
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms Mar 17, 2025
acaa60e
Merge branch 'coleng/recursive_includes_settings' of https://github.c…
Colengms Mar 17, 2025
45fd8bc
Remove 'requiredHeader', and change 'reduce' to be an enum type, to s…
Colengms Mar 17, 2025
51e3a57
Merge branch 'main' into coleng/recursive_includes_settings
Colengms Mar 18, 2025
0d8d894
Merge branch 'main' into coleng/recursive_includes_settings
Colengms Mar 18, 2025
28ec9e6
Address PR feedback
Colengms Mar 18, 2025
465dd67
Address PR feedback
Colengms Mar 18, 2025
0471b61
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms Mar 18, 2025
a02062e
Address PR feedback
Colengms Mar 21, 2025
ebba7bb
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms Mar 21, 2025
36d034f
Merge branch 'main' into coleng/recursive_includes_settings
Colengms Mar 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion Extension/c_cpp_properties.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"mergeConfigurations": {
"markdownDescription": "Set to `true` to merge include paths, defines, and forced includes with those from a configuration provider.",
"descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
"type": "boolean"
"type": [
"boolean",
"string"
]
},
"browse": {
"type": "object",
Expand Down Expand Up @@ -208,6 +211,39 @@
},
"additionalProperties": false
},
"recursiveIncludes": {
"type": "object",
"properties": {
"reduce": {
"markdownDescription": "Set to `true` to reduce the number of recursive include paths provided to IntelliSense to only those paths currently referenced by #include statements. This requires first parsing files to determine which files are included. Set to `false` to provide all recursive include paths to IntelliSense. Reducing the number of recursive include paths may improve IntelliSense performance when a very large number of recursive include paths are involved. Not reducing the number of recursive include paths can improve IntelliSense performance by avoiding the need to parse files to determine which include paths to provide.",
"descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
"type": [
"boolean",
"string"
]
},
"priority": {
"markdownDescription": "The priority of recursive include paths. If set to `beforeSystemIncludes`, the recursive include paths will be searched before system include paths. If set to `afterSystemIncludes`, the recursive include paths will be searched after system include paths.",
"descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
"type": "string",
"enum": [
"beforeSystemIncludes",
"afterSystemIncludes",
"${default}"
]
},
"order": {
"markdownDescription": "The order in which subdirectories of recursive includes are searched.",
"type": "string",
"enum": [
"depthFirst",
"breadthFirst",
"${default}"
]
}
},
"additionalProperties": false
},
"customConfigurationVariables": {
"type": "object",
"markdownDescription": "Custom variables that can be queried through the command `${cpptools:activeConfigCustomVariable}` to use for the input variables in `launch.json` or `tasks.json`.",
Expand Down
26 changes: 26 additions & 0 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,32 @@
"markdownDescription": "%c_cpp.configuration.default.dotConfig.markdownDescription%",
"scope": "resource"
},
"C_Cpp.default.recursiveIncludes.reduce": {
"type": "boolean",
"default": false,
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription%",
"scope": "resource"
},
"C_Cpp.default.recursiveIncludes.priority": {
"type": "string",
"enum": [
"beforeSystemIncludes",
"afterSystemIncludes"
],
"default": "afterSystemIncludes",
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.priority.markdownDescription%",
"scope": "resource"
},
"C_Cpp.default.recursiveIncludes.order": {
"type": "string",
"enum": [
"depthFirst",
"breadthFirst"
],
"default": "depthFirst",
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.order.markdownDescription%",
"scope": "resource"
},
"C_Cpp.configurationWarnings": {
"type": "string",
"enum": [
Expand Down
22 changes: 20 additions & 2 deletions Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@
]
},
"c_cpp.configuration.default.mergeConfigurations.markdownDescription": {
"message": "Set to `true` to merge include paths, defines, and forced includes with those from a configuration provider.",
"message": "The value to use in a configuration if `mergeConfigurations` is either not specified or set to `${default}`.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
Expand Down Expand Up @@ -729,13 +729,31 @@
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.updateChannel.deprecationMessage": "This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
"c_cpp.configuration.default.dotConfig.markdownDescription": {
"message": "The value to use in a configuration if `dotConfig` is not specified, or the value to insert if `${default}` is present in `dotConfig`.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription": {
"message": "The value to use in a configuration if `recursiveIncludes.reduce` is not specified, or the value to insert if `${default}` is present in `recursiveIncludes.reduce`.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.default.recursiveIncludes.priority.markdownDescription": {
"message": "The value to use in a configuration if `recursiveIncludes.priority` is not specified, or the value to insert if `${default}` is present in `recursiveIncludes.priority`.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.default.recursiveIncludes.order.markdownDescription": {
"message": "The value to use in a configuration if `recursiveIncludes.order` is not specified, or the value to insert if `${default}` is present in `recursiveIncludes.order`.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.updateChannel.deprecationMessage": "This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
"c_cpp.configuration.experimentalFeatures.description": "Controls whether \"experimental\" features are usable.",
"c_cpp.configuration.suggestSnippets.markdownDescription": {
"message": "If `true`, snippets are provided by the language server.",
Expand Down
40 changes: 21 additions & 19 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ export interface Configuration {
forcedInclude?: string[];
configurationProviderInCppPropertiesJson?: string;
configurationProvider?: string;
mergeConfigurations?: boolean;
mergeConfigurations?: boolean | string;
browse?: Browse;
recursiveIncludes?: RecursiveIncludes;
customConfigurationVariables?: { [key: string]: string };
}

Expand All @@ -107,6 +108,12 @@ export interface Browse {
databaseFilename?: string;
}

export interface RecursiveIncludes {
reduce?: boolean | string;
priority?: string;
order?: string;
}

export interface KnownCompiler {
path: string;
isC: boolean;
Expand Down Expand Up @@ -813,13 +820,16 @@ export class CppProperties {
return resolvedGlob;
}

private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env: Environment, acceptBlank?: boolean): string | undefined {
private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env?: Environment, acceptBlank?: boolean): string | undefined {
if (property === null || property === undefined || property === "${default}") {
property = defaultValue;
}
if (property === null || property === undefined || (acceptBlank !== true && property === "")) {
return undefined;
}
if (env === undefined) {
return property;
}
return util.resolveVariables(property, env);
}

Expand All @@ -843,29 +853,16 @@ export class CppProperties {
return paths;
}

private updateConfigurationStringOrBoolean(property: string | boolean | undefined | null, defaultValue: boolean | undefined | null, env: Environment): string | boolean | undefined {
if (!property || property === "${default}") {
property = defaultValue;
}
if (!property || property === "") {
return undefined;
}
if (typeof property === "boolean") {
return property;
}
return util.resolveVariables(property, env);
}

private updateConfigurationBoolean(property: boolean | undefined | null, defaultValue: boolean | undefined | null): boolean | undefined {
if (property === null || property === undefined) {
private updateConfigurationBoolean(property: boolean | string | undefined | null, defaultValue: boolean | undefined | null): boolean | undefined {
if (property === null || property === undefined || property === "${default}") {
property = defaultValue;
}

if (property === null) {
return undefined;
}

return property;
return property === true || property === "true";
}

private updateConfigurationStringDictionary(property: { [key: string]: string } | undefined, defaultValue: { [key: string]: string } | undefined, env: Environment): { [key: string]: string } | undefined {
Expand Down Expand Up @@ -939,6 +936,11 @@ export class CppProperties {
configuration.cStandardIsExplicit = configuration.cStandardIsExplicit || settings.defaultCStandard !== "";
configuration.cppStandardIsExplicit = configuration.cppStandardIsExplicit || settings.defaultCppStandard !== "";
configuration.mergeConfigurations = this.updateConfigurationBoolean(configuration.mergeConfigurations, settings.defaultMergeConfigurations);
if (configuration.recursiveIncludes) {
configuration.recursiveIncludes.reduce = this.updateConfigurationBoolean(configuration.recursiveIncludes.reduce, settings.defaultRecursiveIncludesReduce);
configuration.recursiveIncludes.priority = this.updateConfigurationString(configuration.recursiveIncludes.priority, settings.defaultRecursiveIncludesPriority);
configuration.recursiveIncludes.order = this.updateConfigurationString(configuration.recursiveIncludes.order, settings.defaultRecursiveIncludesOrder);
}
if (!configuration.compileCommands) {
// compile_commands.json already specifies a compiler. compilerPath overrides the compile_commands.json compiler so
// don't set a default when compileCommands is in use.
Expand Down Expand Up @@ -1002,7 +1004,7 @@ export class CppProperties {
configuration.browse.path = this.updateConfigurationPathsArray(configuration.browse.path, settings.defaultBrowsePath, env);
}

configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfigurationStringOrBoolean(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders, env);
configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfigurationBoolean(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders);
configuration.browse.databaseFilename = this.updateConfigurationString(configuration.browse.databaseFilename, settings.defaultDatabaseFilename, env);

if (i === this.CurrentConfigurationIndex) {
Expand Down
3 changes: 3 additions & 0 deletions Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ export class CppSettings extends Settings {
public get defaultBrowsePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.browse.path"); }
public get defaultDatabaseFilename(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.browse.databaseFilename")); }
public get defaultLimitSymbolsToIncludedHeaders(): boolean { return this.getAsBoolean("default.browse.limitSymbolsToIncludedHeaders"); }
public get defaultRecursiveIncludesReduce(): boolean { return this.getAsBoolean("default.recursiveIncludes.reduce"); }
public get defaultRecursiveIncludesPriority(): string { return this.getAsString("default.recursiveIncludes.priority"); }
public get defaultRecursiveIncludesOrder(): string { return this.getAsString("default.recursiveIncludes.order"); }
public get defaultSystemIncludePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.systemIncludePath"); }
public get defaultEnableConfigurationSquiggles(): boolean { return this.getAsBoolean("default.enableConfigurationSquiggles"); }
public get defaultCustomConfigurationVariables(): Associations | undefined { return this.getAsAssociations("default.customConfigurationVariables", true) ?? undefined; }
Expand Down
21 changes: 21 additions & 0 deletions Extension/src/LanguageServer/settingsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const elementId: { [key: string]: string } = {
mergeConfigurations: "mergeConfigurations",
configurationProvider: "configurationProvider",
forcedInclude: "forcedInclude",
recursiveIncludesReduce: "recursiveIncludes.reduce",
recursiveIncludesPriority: "recursiveIncludes.priority",
recursiveIncludesOrder: "recursiveIncludes.order",

// Browse properties
browsePath: "browsePath",
Expand Down Expand Up @@ -351,6 +354,24 @@ export class SettingsPanel {
case elementId.forcedInclude:
this.configValues.forcedInclude = splitEntries(message.value);
break;
case elementId.recursiveIncludesReduce:
if (!this.configValues.recursiveIncludes) {
this.configValues.recursiveIncludes = {};
}
this.configValues.recursiveIncludes.reduce = message.value;
break;
case elementId.recursiveIncludesPriority:
if (!this.configValues.recursiveIncludes) {
this.configValues.recursiveIncludes = {};
}
this.configValues.recursiveIncludes.priority = message.value;
break;
case elementId.recursiveIncludesOrder:
if (!this.configValues.recursiveIncludes) {
this.configValues.recursiveIncludes = {};
}
this.configValues.recursiveIncludes.order = message.value;
break;
case elementId.browsePath:
if (!this.configValues.browse) {
this.configValues.browse = {};
Expand Down
35 changes: 35 additions & 0 deletions Extension/ui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,41 @@
</div>
</div>

<div class="section">
<div class="section-title" data-loc-id="recursiveIncludes.reduce">Recursive includes: reduce</div>
<input type="checkbox" id="recursiveIncludes.reduce" style="vertical-align: middle; transform: scale(1.5)">
<span data-loc-id="recursiveIncludes.reduce.checkbox">Set to <code>true</code> (or checked) to reduce the number of recursive include paths provided to IntelliSense to only those paths currently referenced by #include statements. This requires first parsing files to determine which files are included. Set to <code>false</code> (or unchecked) to provide all recursive include paths to IntelliSense. Reducing the number of recursive include paths may improve IntelliSense performance when a very large number of recursive include paths are involved. Not reducing the number of recursive include paths can improve IntelliSense performance by avoiding the need to parse files to determine which include paths to provide.</span>
</input>
</div>

<div class="section">
<div class="section-title" data-loc-id="recursiveIncludes.priority">Recursive includes: priority</div>
<div class="section-text">
<span data-loc-id="recursiveIncludes.priority.description">The priority of recursive include paths. If set to <code>beforeSystemIncludes</code>, the recursive include paths will be searched before system include paths. If set to <code>afterSystemIncludes</code>, the recursive include paths will be searched after system include paths.</span>
</div>
<div>
<select name="inputValue" id="recursiveIncludes.priority" class="select-default">
<option value="${default}">${default}</option>
<option value="beforeSystemIncludes">beforeSystemIncludes</option>
<option value="afterSystemIncludes">afterSystemIncludes</option>
</select>
</div>
</div>

<div class="section">
<div class="section-title" data-loc-id="recursiveIncludes.order">Recursive includes: priority</div>
<div class="section-text">
<span data-loc-id="recursiveIncludes.order.description">The order in which subdirectories under recursive include paths are searched.</span>
</div>
<div>
<select name="inputValue" id="recursiveIncludes.order" class="select-default">
<option value="${default}">${default}</option>
<option value="depthFirst">depthFirst</option>
<option value="breadthFirst">breadthFirst</option>
</select>
</div>
</div>

</div> <!-- advanced settings end -->

<!-- sections end -->
Expand Down
Loading