Skip to content

Commit f4694c5

Browse files
committed
Work in progress
1 parent fcda971 commit f4694c5

File tree

6 files changed

+98
-22
lines changed

6 files changed

+98
-22
lines changed

Extension/c_cpp_properties.schema.json

Lines changed: 28 additions & 1 deletion
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,30 @@
208211
},
209212
"additionalProperties": false
210213
},
214+
"recursiveIncludes": {
215+
"type": "object",
216+
"properties": {
217+
"reduce": {
218+
"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.",
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": [
221+
"boolean",
222+
"string"
223+
]
224+
},
225+
"priority": {
226+
"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.",
227+
"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.",
228+
"type": "string",
229+
"enum": [
230+
"beforeSystemIncludes",
231+
"afterSystemIncludes",
232+
"${default}"
233+
]
234+
}
235+
},
236+
"additionalProperties": false
237+
},
211238
"customConfigurationVariables": {
212239
"type": "object",
213240
"markdownDescription": "Custom variables that can be queried through the command `${cpptools:activeConfigCustomVariable}` to use for the input variables in `launch.json` or `tasks.json`.",

Extension/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,20 @@
897897
"markdownDescription": "%c_cpp.configuration.default.dotConfig.markdownDescription%",
898898
"scope": "resource"
899899
},
900+
"C_Cpp.default.recursiveIncludes.reduce": {
901+
"type": "boolean",
902+
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription%",
903+
"scope": "resource"
904+
},
905+
"C_Cpp.default.recursiveIncludes.priority": {
906+
"type": "string",
907+
"enum": [
908+
"beforeSystemIncludes",
909+
"afterSystemIncludes"
910+
],
911+
"markdownDescription": "%c_cpp.configuration.default.recursiveIncludes.priority.markdownDescription%",
912+
"scope": "resource"
913+
},
900914
"C_Cpp.configurationWarnings": {
901915
"type": "string",
902916
"enum": [

Extension/package.nls.json

Lines changed: 14 additions & 2 deletions
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 not specified, or the value to insert if `${default}` is present in `mergeConfigurations`.",
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
]
@@ -729,13 +729,25 @@
729729
"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."
730730
]
731731
},
732-
"c_cpp.configuration.updateChannel.deprecationMessage": "This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
733732
"c_cpp.configuration.default.dotConfig.markdownDescription": {
734733
"message": "The value to use in a configuration if `dotConfig` is not specified, or the value to insert if `${default}` is present in `dotConfig`.",
735734
"comment": [
736735
"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."
737736
]
738737
},
738+
"c_cpp.configuration.default.recursiveIncludes.reduce.markdownDescription": {
739+
"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`.",
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.priority.markdownDescription": {
745+
"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`.",
746+
"comment": [
747+
"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."
748+
]
749+
},
750+
"c_cpp.configuration.updateChannel.deprecationMessage": "This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
739751
"c_cpp.configuration.experimentalFeatures.description": "Controls whether \"experimental\" features are usable.",
740752
"c_cpp.configuration.suggestSnippets.markdownDescription": {
741753
"message": "If `true`, snippets are provided by the language server.",

Extension/src/LanguageServer/configurations.ts

Lines changed: 19 additions & 19 deletions
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,11 @@ export interface Browse {
107108
databaseFilename?: string;
108109
}
109110

111+
export interface RecursiveIncludes {
112+
reduce?: boolean | string;
113+
priority?: string;
114+
}
115+
110116
export interface KnownCompiler {
111117
path: string;
112118
isC: boolean;
@@ -813,13 +819,16 @@ export class CppProperties {
813819
return resolvedGlob;
814820
}
815821

816-
private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env: Environment, acceptBlank?: boolean): string | undefined {
822+
private updateConfigurationString(property: string | undefined | null, defaultValue: string | undefined | null, env?: Environment, acceptBlank?: boolean): string | undefined {
817823
if (property === null || property === undefined || property === "${default}") {
818824
property = defaultValue;
819825
}
820826
if (property === null || property === undefined || (acceptBlank !== true && property === "")) {
821827
return undefined;
822828
}
829+
if (env === undefined) {
830+
return property;
831+
}
823832
return util.resolveVariables(property, env);
824833
}
825834

@@ -843,29 +852,16 @@ export class CppProperties {
843852
return paths;
844853
}
845854

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) {
855+
private updateConfigurationBoolean(property: boolean | string | undefined | null, defaultValue: boolean | undefined | null): boolean | undefined {
856+
if (property === null || property === undefined || property === "${default}") {
861857
property = defaultValue;
862858
}
863859

864860
if (property === null) {
865861
return undefined;
866862
}
867863

868-
return property;
864+
return property === true || property === "true";
869865
}
870866

871867
private updateConfigurationStringDictionary(property: { [key: string]: string } | undefined, defaultValue: { [key: string]: string } | undefined, env: Environment): { [key: string]: string } | undefined {
@@ -939,6 +935,10 @@ export class CppProperties {
939935
configuration.cStandardIsExplicit = configuration.cStandardIsExplicit || settings.defaultCStandard !== "";
940936
configuration.cppStandardIsExplicit = configuration.cppStandardIsExplicit || settings.defaultCppStandard !== "";
941937
configuration.mergeConfigurations = this.updateConfigurationBoolean(configuration.mergeConfigurations, settings.defaultMergeConfigurations);
938+
if (configuration.recursiveIncludes) {
939+
configuration.recursiveIncludes.reduce = this.updateConfigurationBoolean(configuration.recursiveIncludes.reduce, settings.defaultRecursiveIncludesReduce);
940+
configuration.recursiveIncludes.priority = this.updateConfigurationString(configuration.recursiveIncludes.priority, settings.defaultRecursiveIncludesPriority);
941+
}
942942
if (!configuration.compileCommands) {
943943
// compile_commands.json already specifies a compiler. compilerPath overrides the compile_commands.json compiler so
944944
// don't set a default when compileCommands is in use.
@@ -1002,7 +1002,7 @@ export class CppProperties {
10021002
configuration.browse.path = this.updateConfigurationPathsArray(configuration.browse.path, settings.defaultBrowsePath, env);
10031003
}
10041004

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

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

Extension/src/LanguageServer/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ export class CppSettings extends Settings {
445445
public get defaultBrowsePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.browse.path"); }
446446
public get defaultDatabaseFilename(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.browse.databaseFilename")); }
447447
public get defaultLimitSymbolsToIncludedHeaders(): boolean { return this.getAsBoolean("default.browse.limitSymbolsToIncludedHeaders"); }
448+
public get defaultRecursiveIncludesReduce(): boolean { return this.getAsBoolean("default.recursiveIncludes.reduce"); }
449+
public get defaultRecursiveIncludesPriority(): string { return this.getAsString("default.recursiveIncludes.priority"); }
448450
public get defaultSystemIncludePath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.systemIncludePath"); }
449451
public get defaultEnableConfigurationSquiggles(): boolean { return this.getAsBoolean("default.enableConfigurationSquiggles"); }
450452
public get defaultCustomConfigurationVariables(): Associations | undefined { return this.getAsAssociations("default.customConfigurationVariables", true) ?? undefined; }

Extension/ui/settings.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,27 @@
722722
</div>
723723
</div>
724724

725+
<div class="section">
726+
<div class="section-title" data-loc-id="recursiveIncludes.reduce">Recursive includes: reduce</div>
727+
<input type="checkbox" id="recursiveIncludes.reduce" style="vertical-align: middle; transform: scale(1.5)">
728+
<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>
729+
</input>
730+
</div>
731+
732+
<div class="section">
733+
<div class="section-title" data-loc-id="recursiveIncludes.priority">Recursive includes: priority</div>
734+
<div class="section-text">
735+
<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>
736+
</div>
737+
<div>
738+
<select name="inputValue" id="recursiveIncludes.priority" class="select-default">
739+
<option value="${default}">${default}</option>
740+
<option value="beforeSystemIncludes">beforeSystemIncludes</option>
741+
<option value="afterSystemIncludes">afterSystemIncludes</option>
742+
</select>
743+
</div>
744+
</div>
745+
725746
</div> <!-- advanced settings end -->
726747

727748
<!-- sections end -->

0 commit comments

Comments
 (0)