Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple compile commands on client side (needs native server side support) #12960

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f346723
accept an array in compile commands schema
Nov 10, 2024
2dc0fa3
handle settings.json of multiple compile commands
yiftahw Nov 10, 2024
02a2812
update schemas
yiftahw Nov 10, 2024
280aee1
an array is returned from default settings only if non-empty with non…
yiftahw Nov 10, 2024
b934a92
basic handling of compile commands array in configurations
yiftahw Nov 11, 2024
e273731
Merge branch 'main' into handle-multiple-compile-commands
Nov 13, 2024
0c8ccb1
fixes after merge
Nov 13, 2024
8e84183
yarn lint
yiftahw Nov 14, 2024
22de1e0
unify check behavior
yiftahw Nov 14, 2024
62a8915
update desription in schema
yiftahw Nov 14, 2024
d7e2a4a
handle parsed values from c_cpp_properties.json
yiftahw Nov 14, 2024
b1614de
reverse logic to default as undefined
yiftahw Nov 14, 2024
7fe9904
squiggles for multi paths
yiftahw Nov 14, 2024
82c4e53
remove not needed optional guard
yiftahw Nov 14, 2024
69c4013
squiggles finalized
yiftahw Nov 14, 2024
d2bf51d
paths should be separated telemetry enabled for a single string
yiftahw Nov 14, 2024
6aa66f6
yarn lint
yiftahw Nov 14, 2024
45bb041
update UI to handle multiple compile commands files
yiftahw Nov 14, 2024
fbe7a2b
Merge branch 'main' into handle-multiple-compile-commands
yiftahw Dec 6, 2024
2438391
merge main
yiftahw Dec 12, 2024
dc3e543
typos and linter
yiftahw Dec 13, 2024
82d5c0b
Merge branch 'main' into handle-multiple-compile-commands
yiftahw Dec 13, 2024
c7a9c05
Merge branch 'main' into handle-multiple-compile-commands
yiftahw Dec 18, 2024
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
19 changes: 16 additions & 3 deletions Extension/c_cpp_properties.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,22 @@
]
},
"compileCommands": {
"markdownDescription": "Full path to `compile_commands.json` file for the workspace.",
"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"
"oneOf": [
{
"type": "string",
"default": ""
bobbrow marked this conversation as resolved.
Show resolved Hide resolved
},
{
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"default": []
}
],
"markdownDescription": "Full path or a list of full paths to `compile_commands.json` files for the workspace.",
"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."
},
"includePath": {
"markdownDescription": "A list of paths for the IntelliSense engine to use while searching for included headers. Searching on these paths is not recursive. Specify `**` to indicate recursive search. For example, `${workspaceFolder}/**` will search through all subdirectories while `${workspaceFolder}` will not. Usually, this should not include system includes; instead, set `C_Cpp.default.compilerPath`.",
Expand Down
15 changes: 14 additions & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,20 @@
"scope": "machine-overridable"
},
"C_Cpp.default.compileCommands": {
"type": "string",
"oneOf": [
{
"type": "string",
"default": ""
},
{
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"default": []
}
],
"markdownDescription": "%c_cpp.configuration.default.compileCommands.markdownDescription%",
"scope": "machine-overridable"
},
Expand Down
141 changes: 95 additions & 46 deletions Extension/src/LanguageServer/configurations.ts

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,26 @@ export class CppSettings extends Settings {
public get defaultDotconfig(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.dotConfig")); }
public get defaultMacFrameworkPath(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.macFrameworkPath"); }
public get defaultWindowsSdkVersion(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.windowsSdkVersion")); }
public get defaultCompileCommands(): string | undefined { return changeBlankStringToUndefined(this.getAsStringOrUndefined("default.compileCommands")); }
public get defaultForcedInclude(): string[] | undefined { return this.getArrayOfStringsWithUndefinedDefault("default.forcedInclude"); }
public get defaultIntelliSenseMode(): string | undefined { return this.getAsStringOrUndefined("default.intelliSenseMode"); }
public get defaultCompileCommands(): string[] | undefined {
// Try to get the value as a string.
const value: string | undefined = this.getAsStringOrUndefined("default.compileCommands");
if (value !== undefined) {
if (changeBlankStringToUndefined(value) === undefined) {
return undefined;
}
return [value];
}

// value is not a string, try to get it as an array of strings instead.
let valueArray: string[] | undefined = this.getAsArrayOfStringsOrUndefined("default.compileCommands");
valueArray = valueArray?.filter((value: string) => value.length > 0);
if (valueArray?.length === 0) {
return undefined;
}
return valueArray;
}
public get defaultCompilerPath(): string | null { return this.getAsString("default.compilerPath", true); }

public set defaultCompilerPath(value: string) {
Expand Down Expand Up @@ -650,7 +667,7 @@ export class CppSettings extends Settings {
}

if (isArrayOfString(value)) {
if (setting.items.enum && !allowUndefinedEnums) {
if (setting.items?.enum !== undefined && !allowUndefinedEnums) {
if (!value.every(x => this.isValidEnum(setting.items.enum, x))) {
return setting.default;
}
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/settingsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class SettingsPanel {
this.configValues.macFrameworkPath = splitEntries(message.value);
break;
case elementId.compileCommands:
this.configValues.compileCommands = message.value || undefined;
this.configValues.compileCommands = splitEntries(message.value);
break;
case elementId.dotConfig:
this.configValues.dotConfig = message.value || undefined;
Expand Down
7 changes: 4 additions & 3 deletions Extension/ui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,12 @@
<div class="section">
<div class="section-title" data-loc-id="compile.commands">Compile commands</div>
<div class="section-text">
<span data-loc-id="compile.commands.description">The full path to the <code>compile_commands.json</code> file for the workspace. The include paths and defines discovered in this file will be used instead of the values set for <code>includePath</code> and <code>defines</code> settings. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the <code>includePath</code> and <code>defines</code> settings instead.</span>
<span data-loc-id="compile.commands.description">A list of paths to <code>compile_commands.json</code> files for the workspace. The include paths and defines discovered in these files will be used instead of the values set for <code>includePath</code> and <code>defines</code> settings. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the <code>includePath</code> and <code>defines</code> settings instead.</span>
</div>
<div>
<input name="inputValue" id="compileCommands" style="width: 798px"></input>
<div id="compileCommandsInvalid" class="error" style="width: 800px"></div>
<div class="section-note" data-loc-id="one.compile.commands.path.per.line">One compile commands path per line.</div>
<textarea name="inputValue" id="compileCommands" rows="4" cols="93" style="width: 800px"></textarea>
<div id="compileCommandsInvalid" class="error" style="margin-top: -4px; width: 794px"></div>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion Extension/ui/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class SettingsApp {
// Advanced settings
(<HTMLInputElement>document.getElementById(elementId.windowsSdkVersion)).value = config.windowsSdkVersion ? config.windowsSdkVersion : "";
(<HTMLInputElement>document.getElementById(elementId.macFrameworkPath)).value = joinEntries(config.macFrameworkPath);
(<HTMLInputElement>document.getElementById(elementId.compileCommands)).value = config.compileCommands ? config.compileCommands : "";
(<HTMLInputElement>document.getElementById(elementId.compileCommands)).value = joinEntries(config.compileCommands);
(<HTMLInputElement>document.getElementById(elementId.mergeConfigurations)).checked = config.mergeConfigurations;
(<HTMLInputElement>document.getElementById(elementId.configurationProvider)).value = config.configurationProvider ? config.configurationProvider : "";
(<HTMLInputElement>document.getElementById(elementId.forcedInclude)).value = joinEntries(config.forcedInclude);
Expand Down
Loading