Skip to content

Commit 37ff589

Browse files
authored
Merge branch 'main' into seanmcm/devbox2-wsl/agent164/clang-tidy-include-mappings
2 parents 40a5ffe + fbdb130 commit 37ff589

11 files changed

Lines changed: 238 additions & 106 deletions

File tree

‎.github/actions/package-lock.json‎

Lines changed: 39 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Extension/package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,12 @@
10551055
"description": "%c_cpp.configuration.hover.description%",
10561056
"scope": "resource"
10571057
},
1058+
"C_Cpp.hoverShowIntegralValuesInHexadecimal": {
1059+
"type": "boolean",
1060+
"default": false,
1061+
"markdownDescription": "%c_cpp.configuration.hoverShowIntegralValuesInHexadecimal.markdownDescription%",
1062+
"scope": "resource"
1063+
},
10581064
"C_Cpp.errorSquiggles": {
10591065
"type": "string",
10601066
"enum": [

‎Extension/package.nls.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,12 @@
779779
"c_cpp.configuration.markdownInComments.enabled.description": "Enable all markdown features in the hover tooltip.",
780780
"c_cpp.configuration.markdownInComments.disabled.description": "Disable all markdown features in the hover tooltip.",
781781
"c_cpp.configuration.hover.description": "If disabled, hover details are no longer provided by the language server.",
782+
"c_cpp.configuration.hoverShowIntegralValuesInHexadecimal.markdownDescription": {
783+
"message": "Displays integral constant values in hexadecimal in IntelliSense hovers. This setting only applies if `#C_Cpp.intelliSenseEngine#` is set to `default`.",
784+
"comment": [
785+
"Markdown text between `` should not be translated or localized (it represents literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
786+
]
787+
},
782788
"c_cpp.configuration.vcpkg.enabled.markdownDescription": {
783789
"message": "Enable integration services for the [vcpkg dependency manager](https://aka.ms/vcpkg/).",
784790
"comment": [

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { CustomConfigurationProvider1, getCustomConfigProviders, isSameProviderE
5555
import { DataBinding } from './dataBinding';
5656
import { cachedEditorConfigSettings, getEditorConfigSettings } from './editorConfig';
5757
import { CppSourceStr, clients, configPrefix, initializeIntervalTimer, isWritingCrashCallStack, updateLanguageConfigurations, usesCrashHandler, watchForCrashes } from './extension';
58+
import { IncludeCleanupPreferences, getIncludeCleanupPreferences } from './includeCleanupEditorConfig';
5859
import { InactiveRegion, InactiveRegionStore, getInactiveRegionStartLines } from './inactiveRegions';
5960
import { LanguageClient } from './languageClient';
6061
import { LocalizeStringParams, getLocaleId, getLocalizedString } from './localization';
@@ -507,6 +508,7 @@ interface TagParseStatus {
507508
interface VisibleEditorInfo {
508509
visibleRanges: Range[];
509510
originalEncoding: string;
511+
includeCleanupPreferences: IncludeCleanupPreferences;
510512
}
511513

512514
interface DidChangeVisibleTextEditorsParams {
@@ -1503,6 +1505,7 @@ export class DefaultClient implements Client {
15031505
clangTidyChecksDisabled: settings.clangTidyChecksDisabled,
15041506
markdownInComments: settings.markdownInComments,
15051507
hover: settings.hover,
1508+
hoverShowIntegralValuesInHexadecimal: settings.hoverShowIntegralValuesInHexadecimal,
15061509
vcFormatIndentBraces: settings.vcFormatIndentBraces,
15071510
vcFormatIndentMultiLineRelativeTo: settings.vcFormatIndentMultiLineRelativeTo,
15081511
vcFormatIndentWithinParentheses: settings.vcFormatIndentWithinParentheses,
@@ -1953,9 +1956,11 @@ export class DefaultClient implements Client {
19531956
// First, we just concat all ranges for the same file.
19541957
const uri: string = editor.document.uri.toString();
19551958
if (!visibileEditorInfo[uri]) {
1959+
const editorConfigSettings: any = getEditorConfigSettings(editor.document.uri.fsPath);
19561960
visibileEditorInfo[uri] = {
19571961
visibleRanges: [],
1958-
originalEncoding: editor.document.encoding
1962+
originalEncoding: editor.document.encoding,
1963+
includeCleanupPreferences: getIncludeCleanupPreferences(editorConfigSettings)
19591964
};
19601965
}
19611966
visibileEditorInfo[uri].visibleRanges = visibileEditorInfo[uri].visibleRanges.concat(editor.visibleRanges.map(makeLspRange));
@@ -2714,6 +2719,15 @@ export class DefaultClient implements Client {
27142719

27152720
private associations_for_did_change?: Set<string>;
27162721

2722+
private refreshEditorConfigSettings(): void {
2723+
cachedEditorConfigSettings.clear();
2724+
cachedEditorConfigLookups.clear();
2725+
this.updateActiveDocumentTextOptions();
2726+
2727+
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(editor => util.isCpp(editor.document));
2728+
void this.onDidChangeVisibleTextEditors(cppEditors).catch(logAndReturn.undefined);
2729+
}
2730+
27172731
/**
27182732
* listen for file created/deleted events under the ${workspaceFolder} folder
27192733
*/
@@ -2734,9 +2748,7 @@ export class DefaultClient implements Client {
27342748
}
27352749
const fileName: string = path.basename(uri.fsPath).toLowerCase();
27362750
if (fileName === ".editorconfig") {
2737-
cachedEditorConfigSettings.clear();
2738-
cachedEditorConfigLookups.clear();
2739-
this.updateActiveDocumentTextOptions();
2751+
this.refreshEditorConfigSettings();
27402752
}
27412753
if (fileName === ".clang-format" || fileName === "_clang-format") {
27422754
cachedEditorConfigLookups.clear();
@@ -2762,9 +2774,7 @@ export class DefaultClient implements Client {
27622774
const dotIndex: number = uri.fsPath.lastIndexOf('.');
27632775
const fileName: string = path.basename(uri.fsPath).toLowerCase();
27642776
if (fileName === ".editorconfig") {
2765-
cachedEditorConfigSettings.clear();
2766-
cachedEditorConfigLookups.clear();
2767-
this.updateActiveDocumentTextOptions();
2777+
this.refreshEditorConfigSettings();
27682778
}
27692779
const ext: string | undefined = dotIndex !== -1 ? uri.fsPath.substring(dotIndex + 1) : undefined;
27702780
const isTrackedFile: boolean = hasNativeFileTypeMappings()
@@ -2789,8 +2799,7 @@ export class DefaultClient implements Client {
27892799
}
27902800
const fileName: string = path.basename(uri.fsPath).toLowerCase();
27912801
if (fileName === ".editorconfig") {
2792-
cachedEditorConfigSettings.clear();
2793-
cachedEditorConfigLookups.clear();
2802+
this.refreshEditorConfigSettings();
27942803
}
27952804
if (fileName === ".clang-format" || fileName === "_clang-format") {
27962805
cachedEditorConfigLookups.clear();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All Rights Reserved.
3+
* See 'LICENSE' in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
6+
export interface IncludeCleanupPreferences {
7+
alternateFiles: string;
8+
excludedFiles: string;
9+
replacementFiles: string;
10+
requiredFiles: string;
11+
}
12+
13+
function normalizeSettingKeys(settings: any): Record<string, unknown> {
14+
return Object.fromEntries(Object.entries(settings ?? {}).map(([key, value]) => [key.toLowerCase(), value]));
15+
}
16+
17+
function getStringSetting(settings: Record<string, unknown>, key: string): string {
18+
const value: unknown = settings?.[key];
19+
if (typeof value !== 'string' || value.toLowerCase() === 'unset') {
20+
return '';
21+
}
22+
return value;
23+
}
24+
25+
export function getIncludeCleanupPreferences(settings: any): IncludeCleanupPreferences {
26+
const normalizedSettings: Record<string, unknown> = normalizeSettingKeys(settings);
27+
return {
28+
alternateFiles: getStringSetting(normalizedSettings, 'cpp_include_cleanup_alternate_files'),
29+
excludedFiles: getStringSetting(normalizedSettings, 'cpp_include_cleanup_excluded_files'),
30+
replacementFiles: getStringSetting(normalizedSettings, 'cpp_include_cleanup_replacement_files'),
31+
requiredFiles: getStringSetting(normalizedSettings, 'cpp_include_cleanup_required_files')
32+
};
33+
}

‎Extension/src/LanguageServer/settings.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export interface WorkspaceFolderSettingsParams {
7171
clangTidyChecksEnabled: string[] | undefined;
7272
clangTidyChecksDisabled: string[] | undefined;
7373
hover: string;
74+
hoverShowIntegralValuesInHexadecimal: boolean;
7475
markdownInComments: string;
7576
vcFormatIndentBraces: boolean;
7677
vcFormatIndentMultiLineRelativeTo: string;
@@ -488,6 +489,7 @@ export class CppSettings extends Settings {
488489
public get isCaseSensitiveFileSupportEnabled(): boolean { return !isWindows || this.getAsString("caseSensitiveFileSupport").toLowerCase() === "enabled"; }
489490
public get doxygenSectionTags(): string[] { return this.getAsArrayOfStrings("doxygen.sectionTags"); }
490491
public get hover(): string { return this.getAsString("hover"); }
492+
public get hoverShowIntegralValuesInHexadecimal(): boolean { return this.getAsBoolean("hoverShowIntegralValuesInHexadecimal"); }
491493
public get markdownInComments(): string { return this.getAsString("markdownInComments"); }
492494
public get legacyCompilerArgsBehavior(): boolean { return this.getAsBoolean("legacyCompilerArgsBehavior"); }
493495
public get inlayHintsAutoDeclarationTypes(): boolean { return this.getAsBoolean("inlayHints.autoDeclarationTypes.enabled"); }

‎Extension/src/nativeStrings.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,5 +797,25 @@
797797
"quick_info_alignment": {
798798
"text": "**Alignment:** %s B",
799799
"hint": "Alignment of a C or C++ type in bytes. %s is the numeric alignment. Translate B to a count-invariant byte unit symbol or abbreviation. {Locked=\"**\"} {Locked=\"%s\"}"
800+
},
801+
"help_allow_missing_workspace_config": {
802+
"text": "Allow the server to start even when the specified workspace config file does not exist.",
803+
"hint": "Describes the --allow-missing-workspace-config command-line option."
804+
},
805+
"help_deprecated_lsp_config": {
806+
"text": "Deprecated alias for --workspace-config.",
807+
"hint": "{Locked=\"--workspace-config\"}"
808+
},
809+
"help_deprecated_allow_missing_lsp_config": {
810+
"text": "Deprecated alias for --allow-missing-workspace-config.",
811+
"hint": "{Locked=\"--allow-missing-workspace-config\"}"
812+
},
813+
"error_conflicting_config_args": {
814+
"text": "--workspace-config cannot be combined with --lsp-config.",
815+
"hint": "Error shown when both configuration arguments are supplied. {Locked=\"--workspace-config\"} {Locked=\"--lsp-config\"}"
816+
},
817+
"error_config_arg_requires_path": {
818+
"text": "{0} requires a path.",
819+
"hint": "Error shown when a configuration argument is not followed by a path. {0} is the command-line option name. {Locked=\"{0}\"}"
800820
}
801821
}

0 commit comments

Comments
 (0)