Skip to content

Commit 225143f

Browse files
authored
Add settings for 'reduce', 'priority' and internal 'order' of recursive includes. (#13374)
1 parent bd80509 commit 225143f

File tree

8 files changed

+188
-22
lines changed

8 files changed

+188
-22
lines changed

Diff for: Extension/c_cpp_properties.schema.json

+40-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@
180180
"mergeConfigurations": {
181181
"markdownDescription": "Set to `true` to merge include paths, defines, and forced includes with those from a configuration provider.",
182182
"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.",
183-
"type": "boolean"
183+
"type": [
184+
"boolean",
185+
"string"
186+
]
184187
},
185188
"browse": {
186189
"type": "object",
@@ -208,6 +211,42 @@
208211
},
209212
"additionalProperties": false
210213
},
214+
"recursiveIncludes": {
215+
"type": "object",
216+
"properties": {
217+
"reduce": {
218+
"markdownDescription": "Set to `always` to always 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 headers are included. Set to `never` 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. The `default` value is currently to reduce the number of recursive include paths provided to IntelliSense.",
219+
"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.",
220+
"type": "string",
221+
"enum": [
222+
"always",
223+
"never",
224+
"default",
225+
"${default}"
226+
]
227+
},
228+
"priority": {
229+
"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. `beforeSystemIncludes` would more closely reflect the search order of a compiler, while `afterSystemIncludes` may result in improved performance.",
230+
"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.",
231+
"type": "string",
232+
"enum": [
233+
"beforeSystemIncludes",
234+
"afterSystemIncludes",
235+
"${default}"
236+
]
237+
},
238+
"order": {
239+
"markdownDescription": "The order in which subdirectories of recursive includes are searched.",
240+
"type": "string",
241+
"enum": [
242+
"depthFirst",
243+
"breadthFirst",
244+
"${default}"
245+
]
246+
}
247+
},
248+
"additionalProperties": false
249+
},
211250
"customConfigurationVariables": {
212251
"type": "object",
213252
"markdownDescription": "Custom variables that can be queried through the command `${cpptools:activeConfigCustomVariable}` to use for the input variables in `launch.json` or `tasks.json`.",

Diff for: Extension/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,37 @@
897897
"markdownDescription": "%c_cpp.configuration.default.dotConfig.markdownDescription%",
898898
"scope": "resource"
899899
},
900+
"C_Cpp.default.recursiveIncludes.reduce": {
901+
"type": "string",
902+
"enum": [
903+
"always",
904+
"never",
905+
"default"
906+
],
907+
"default": "default",
908+
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription%",
909+
"scope": "resource"
910+
},
911+
"C_Cpp.default.recursiveIncludes.priority": {
912+
"type": "string",
913+
"enum": [
914+
"beforeSystemIncludes",
915+
"afterSystemIncludes"
916+
],
917+
"default": "afterSystemIncludes",
918+
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.priority.markdownDescription%",
919+
"scope": "resource"
920+
},
921+
"C_Cpp.default.recursiveIncludes.order": {
922+
"type": "string",
923+
"enum": [
924+
"depthFirst",
925+
"breadthFirst"
926+
],
927+
"default": "depthFirst",
928+
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.order.markdownDescription%",
929+
"scope": "resource"
930+
},
900931
"C_Cpp.configurationWarnings": {
901932
"type": "string",
902933
"enum": [

Diff for: Extension/package.nls.json

+20-2
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
]
683683
},
684684
"c_cpp.configuration.default.mergeConfigurations.markdownDescription": {
685-
"message": "Set to `true` to merge include paths, defines, and forced includes with those from a configuration provider.",
685+
"message": "The value to use in a configuration if `mergeConfigurations` is either not specified or set to `${default}`.",
686686
"comment": [
687687
"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."
688688
]
@@ -724,7 +724,25 @@
724724
]
725725
},
726726
"c_cpp.configuration.default.dotConfig.markdownDescription": {
727-
"message": "The value to use in a configuration if `dotConfig` is not specified, or the value to insert if `${default}` is present in `dotConfig`.",
727+
"message": "The value to use in a configuration if `dotConfig` is either not specified or set to `${default}`.",
728+
"comment": [
729+
"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."
730+
]
731+
},
732+
"c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription": {
733+
"message": "The value to use in a configuration if `recursiveIncludes.reduce` is either not specified or set to `${default}`.",
734+
"comment": [
735+
"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."
736+
]
737+
},
738+
"c_cpp.configuration.default.recursiveIncludes.priority.markdownDescription": {
739+
"message": "The value to use in a configuration if `recursiveIncludes.priority` is either not specified or set to `${default}`.",
740+
"comment": [
741+
"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."
742+
]
743+
},
744+
"c_cpp.configuration.default.recursiveIncludes.order.markdownDescription": {
745+
"message": "The value to use in a configuration if `recursiveIncludes.order` is either not specified or set to `${default}`.",
728746
"comment": [
729747
"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."
730748
]

Diff for: Extension/src/LanguageServer/configurations.ts

+22-19
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ export interface Configuration {
8383
forcedInclude?: string[];
8484
configurationProviderInCppPropertiesJson?: string;
8585
configurationProvider?: string;
86-
mergeConfigurations?: boolean;
86+
mergeConfigurations?: boolean | string;
8787
browse?: Browse;
88+
recursiveIncludes?: RecursiveIncludes;
8889
customConfigurationVariables?: { [key: string]: string };
8990
}
9091

@@ -107,6 +108,12 @@ export interface Browse {
107108
databaseFilename?: string;
108109
}
109110

111+
export interface RecursiveIncludes {
112+
reduce?: string;
113+
priority?: string;
114+
order?: string;
115+
}
116+
110117
export interface KnownCompiler {
111118
path: string;
112119
isC: boolean;
@@ -813,13 +820,16 @@ export class CppProperties {
813820
return resolvedGlob;
814821
}
815822

816-
private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env: Environment, acceptBlank?: boolean): string | undefined {
823+
private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env?: Environment, acceptBlank?: boolean): string | undefined {
817824
if (property === null || property === undefined || property === "${default}") {
818825
property = defaultValue;
819826
}
820827
if (property === null || property === undefined || (acceptBlank !== true && property === "")) {
821828
return undefined;
822829
}
830+
if (env === undefined) {
831+
return property;
832+
}
823833
return util.resolveVariables(property, env);
824834
}
825835

@@ -843,29 +853,16 @@ export class CppProperties {
843853
return paths;
844854
}
845855

846-
private updateConfigurationStringOrBoolean(property: string | boolean | undefined | null, defaultValue: boolean | undefined | null, env: Environment): string | boolean | undefined {
847-
if (!property || property === "${default}") {
848-
property = defaultValue;
849-
}
850-
if (!property || property === "") {
851-
return undefined;
852-
}
853-
if (typeof property === "boolean") {
854-
return property;
855-
}
856-
return util.resolveVariables(property, env);
857-
}
858-
859-
private updateConfigurationBoolean(property: boolean | undefined | null, defaultValue: boolean | undefined | null): boolean | undefined {
860-
if (property === null || property === undefined) {
856+
private updateConfigurationBoolean(property: boolean | string | undefined | null, defaultValue: boolean | undefined | null): boolean | undefined {
857+
if (property === null || property === undefined || property === "${default}") {
861858
property = defaultValue;
862859
}
863860

864861
if (property === null) {
865862
return undefined;
866863
}
867864

868-
return property;
865+
return property === true || property === "true";
869866
}
870867

871868
private updateConfigurationStringDictionary(property: { [key: string]: string } | undefined, defaultValue: { [key: string]: string } | undefined, env: Environment): { [key: string]: string } | undefined {
@@ -939,6 +936,12 @@ export class CppProperties {
939936
configuration.cStandardIsExplicit = configuration.cStandardIsExplicit || settings.defaultCStandard !== "";
940937
configuration.cppStandardIsExplicit = configuration.cppStandardIsExplicit || settings.defaultCppStandard !== "";
941938
configuration.mergeConfigurations = this.updateConfigurationBoolean(configuration.mergeConfigurations, settings.defaultMergeConfigurations);
939+
if (!configuration.recursiveIncludes) {
940+
configuration.recursiveIncludes = {};
941+
}
942+
configuration.recursiveIncludes.reduce = this.updateConfigurationString(configuration.recursiveIncludes.reduce, settings.defaultRecursiveIncludesReduce);
943+
configuration.recursiveIncludes.priority = this.updateConfigurationString(configuration.recursiveIncludes.priority, settings.defaultRecursiveIncludesPriority);
944+
configuration.recursiveIncludes.order = this.updateConfigurationString(configuration.recursiveIncludes.order, settings.defaultRecursiveIncludesOrder);
942945
if (!configuration.compileCommands) {
943946
// compile_commands.json already specifies a compiler. compilerPath overrides the compile_commands.json compiler so
944947
// don't set a default when compileCommands is in use.
@@ -1002,7 +1005,7 @@ export class CppProperties {
10021005
configuration.browse.path = this.updateConfigurationPathsArray(configuration.browse.path, settings.defaultBrowsePath, env);
10031006
}
10041007

1005-
configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfigurationStringOrBoolean(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders, env);
1008+
configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfigurationBoolean(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders);
10061009
configuration.browse.databaseFilename = this.updateConfigurationString(configuration.browse.databaseFilename, settings.defaultDatabaseFilename, env);
10071010

10081011
if (i === this.CurrentConfigurationIndex) {

Diff for: Extension/src/LanguageServer/settings.ts

+3
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ export class CppSettings extends Settings {
444444
public get defaultBrowsePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.browse.path"); }
445445
public get defaultDatabaseFilename(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.browse.databaseFilename")); }
446446
public get defaultLimitSymbolsToIncludedHeaders(): boolean { return this.getAsBoolean("default.browse.limitSymbolsToIncludedHeaders"); }
447+
public get defaultRecursiveIncludesReduce(): string { return this.getAsString("default.recursiveIncludes.reduce"); }
448+
public get defaultRecursiveIncludesPriority(): string { return this.getAsString("default.recursiveIncludes.priority"); }
449+
public get defaultRecursiveIncludesOrder(): string { return this.getAsString("default.recursiveIncludes.order"); }
447450
public get defaultSystemIncludePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.systemIncludePath"); }
448451
public get defaultEnableConfigurationSquiggles(): boolean { return this.getAsBoolean("default.enableConfigurationSquiggles"); }
449452
public get defaultCustomConfigurationVariables(): Associations | undefined { return this.getAsAssociations("default.customConfigurationVariables", true) ?? undefined; }

Diff for: Extension/src/LanguageServer/settingsPanel.ts

+21
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ const elementId: { [key: string]: string } = {
5252
mergeConfigurations: "mergeConfigurations",
5353
configurationProvider: "configurationProvider",
5454
forcedInclude: "forcedInclude",
55+
recursiveIncludesReduce: "recursiveIncludes.reduce",
56+
recursiveIncludesPriority: "recursiveIncludes.priority",
57+
recursiveIncludesOrder: "recursiveIncludes.order",
5558

5659
// Browse properties
5760
browsePath: "browsePath",
@@ -351,6 +354,24 @@ export class SettingsPanel {
351354
case elementId.forcedInclude:
352355
this.configValues.forcedInclude = splitEntries(message.value);
353356
break;
357+
case elementId.recursiveIncludesReduce:
358+
if (!this.configValues.recursiveIncludes) {
359+
this.configValues.recursiveIncludes = {};
360+
}
361+
this.configValues.recursiveIncludes.reduce = message.value;
362+
break;
363+
case elementId.recursiveIncludesPriority:
364+
if (!this.configValues.recursiveIncludes) {
365+
this.configValues.recursiveIncludes = {};
366+
}
367+
this.configValues.recursiveIncludes.priority = message.value;
368+
break;
369+
case elementId.recursiveIncludesOrder:
370+
if (!this.configValues.recursiveIncludes) {
371+
this.configValues.recursiveIncludes = {};
372+
}
373+
this.configValues.recursiveIncludes.order = message.value;
374+
break;
354375
case elementId.browsePath:
355376
if (!this.configValues.browse) {
356377
this.configValues.browse = {};

Diff for: Extension/ui/settings.html

+43
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,49 @@
722722
</div>
723723
</div>
724724

725+
<div class="section">
726+
<div class="section-title" data-loc-id="recursiveIncludes.reduce">Recursive includes: priority</div>
727+
<div class="section-text">
728+
<span data-loc-id="recursiveIncludes.reduce.description">Set to <code>always</code> 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>never</code> 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>
729+
</div>
730+
<div>
731+
<select name="inputValue" id="recursiveIncludes.reduce" class="select-default">
732+
<option value="${default}">${default}</option>
733+
<option value="always">always</option>
734+
<option value="never">never</option>
735+
<option value="default">default</option>
736+
</select>
737+
</div>
738+
</div>
739+
740+
<div class="section">
741+
<div class="section-title" data-loc-id="recursiveIncludes.priority">Recursive includes: priority</div>
742+
<div class="section-text">
743+
<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>
744+
</div>
745+
<div>
746+
<select name="inputValue" id="recursiveIncludes.priority" class="select-default">
747+
<option value="${default}">${default}</option>
748+
<option value="beforeSystemIncludes">beforeSystemIncludes</option>
749+
<option value="afterSystemIncludes">afterSystemIncludes</option>
750+
</select>
751+
</div>
752+
</div>
753+
754+
<div class="section">
755+
<div class="section-title" data-loc-id="recursiveIncludes.order">Recursive includes: priority</div>
756+
<div class="section-text">
757+
<span data-loc-id="recursiveIncludes.order.description">The order in which subdirectories under recursive include paths are searched.</span>
758+
</div>
759+
<div>
760+
<select name="inputValue" id="recursiveIncludes.order" class="select-default">
761+
<option value="${default}">${default}</option>
762+
<option value="depthFirst">depthFirst</option>
763+
<option value="breadthFirst">breadthFirst</option>
764+
</select>
765+
</div>
766+
</div>
767+
725768
</div> <!-- advanced settings end -->
726769

727770
<!-- sections end -->

0 commit comments

Comments
 (0)