Skip to content

Commit f63a8da

Browse files
authored
Remove syntactic colorization in favor of text mate colorization (#3821)
1 parent fd314b1 commit f63a8da

6 files changed

Lines changed: 50 additions & 151 deletions

File tree

Documentation/LanguageServer/colorization.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# VS Code C/C++ Extension - Enhanced Colorization
33

4-
The VS Code C/C++ extension now supports lexical/syntactic and semantic colorization, when IntelliSense is enabled. Enhanced colorization can be enabled using the enhancedColorization setting:
4+
The VS Code C/C++ extension now supports semantic colorization, when IntelliSense is enabled. Enhanced colorization can be enabled using the enhancedColorization setting:
55

66
```
77
"C_Cpp.enhancedColorization": "Enabled"
@@ -20,41 +20,32 @@ Colors are associated with [TextMate scopes](https://macromates.com/manual/en/la
2020
| Token | Scope |
2121
| ------------- |:-------------:|
2222
| Class Template | entity.name.class.template |
23-
| Comment | comment |
2423
| Enumerator | variable.other.enummember |
2524
| Event (C++/CLI) | variable.other.event |
2625
| Function | entity.name.function |
2726
| Function Template | entity.name.function.template |
2827
| Generic Type (C++/CLI) | entity.name.class.generic |
2928
| Global Variable | variable.other.global |
3029
| Identifier | <span>entity.name</span> |
31-
| Keyword | keyword.control |
3230
| Label | entity.name.label |
3331
| Local Variable | variable.other.local |
3432
| Macro | entity.name.function.preprocessor |
3533
| Member Field | variable.other.member |
3634
| Member Function | entity.name.function.member |
3735
| Member Operator | keyword.operator.member |
38-
| Namespace | entity.name.namespace |
36+
| Namespace | entity.name.type.namespace |
3937
| New / Delete | keyword.operator.new |
40-
| Number Literal | constant.numeric |
41-
| Operator | keyword.operator |
4238
| Operator Function | entity.name.function.operator |
4339
| Parameter | variable.parameter |
44-
| Preprocessor Keyword | keyword.control.directive |
4540
| Property (C++/CLI) | variable.other.property |
4641
| Reference Type (C++/CLI) | entity.name.class.reference |
4742
| Static Member Field | variable.other.member.static |
4843
| Static Member Function | entity.name.function.member.static |
49-
| String Literal | string.quoted |
5044
| Type | entity.name.type |
51-
| User-Defined Literal Number | entity.name.user-defined-literal.number |
45+
| User-Defined Literal - Number | entity.name.user-defined-literal.number |
5246
| User-Defined Literal - Raw | entity.name.user-defined-literal |
5347
| User-Defined Literal - String | entity.name.user-defined-literal.string |
5448
| Value Type (C++/CLI) | entity.name.class.value |
55-
| Variable | variable |
56-
| Xml Doc Comment | comment.xml.doc |
57-
| Xml Doc Tag | comment.xml.doc.tag |
5849

5950
Many of the tokens recognized by IntelliSense do not directly map to existing scopes in the VS Code's default C/C++ TextMate grammar, so are likely not colored by existing VS Code themes.
6051

@@ -259,7 +250,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S
259250
}
260251
},
261252
{
262-
"scope": "entity.name.namespace",
253+
"scope": "entity.name.type.namespace",
263254
"settings": {
264255
"foreground": "#C8C8C8"
265256
}
@@ -480,7 +471,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual
480471
}
481472
},
482473
{
483-
"scope": "entity.name.namespace",
474+
"scope": "entity.name.type.namespace",
484475
"settings": {
485476
"foreground": "#000000"
486477
}

Extension/CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
# C/C++ for Visual Studio Code Change Log
22

3+
## Version 0.24.0-insiders2: June 25, 2019
4+
### Minor Changes
5+
* Change `C_Cpp.clang_format_path` to `machine` scope. [#3774](https://github.com/microsoft/vscode-cpptools/issues/3774)
6+
* Removed syntactic/lexical colorization from `enhancedColorization`. [PR #3821](https://github.com/microsoft/vscode-cpptools/pull/3821)
7+
8+
### Bug Fixes
9+
* Fix crash when tag parsing Objective-C code. [#3776](https://github.com/microsoft/vscode-cpptools/issues/3776)
10+
* Fix duplicate slashes getting added to `c_cpp_properties.json`. [PR #3778](https://github.com/microsoft/vscode-cpptools/pull/3778)
11+
* Fix incorrect "file already opened in editor" message on Linux/Mac. [#3786](https://github.com/microsoft/vscode-cpptools/issues/3786)
12+
* Fix colorization for themes with background colors equal to the editor background color. [#3780](https://github.com/microsoft/vscode-cpptools/issues/3780)
13+
* Improve performance of colorization. [#3781](https://github.com/microsoft/vscode-cpptools/issues/3781)
14+
* Fix regression crash on hover. [#3792](https://github.com/microsoft/vscode-cpptools/issues/3792)
15+
316
## Version 0.24.0-insiders: June 14, 2019
417
### New Features
5-
* Syntactic/lexical and semantic colorization [PR #3651](https://github.com/microsoft/vscode-cpptools/pull/3651) [Documentation](https://github.com/microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/colorization.md)
18+
* Semantic colorization [Documentation](https://github.com/microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/colorization.md) [#230](https://github.com/microsoft/vscode-cpptools/issues/230)
619
* Add `Rescan Workspace` command. [microsoft/vscode-cpptools-api#11](https://github.com/microsoft/vscode-cpptools-api/issues/11)
720

821
### Minor Changes

Extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"C_Cpp.dimInactiveRegions": {
147147
"type": "boolean",
148148
"default": true,
149-
"description": "Controls whether inactive preprocessor blocks are colored differently than active code. This setting is ignored by the Tag Parser engine.",
149+
"description": "Controls whether inactive preprocessor blocks are colored differently than active code. This setting has no effect if IntelliSense is disabled or if using the Default High Contrast theme.",
150150
"scope": "resource"
151151
},
152152
"C_Cpp.inactiveRegionOpacity": {
@@ -504,7 +504,7 @@
504504
"Disabled"
505505
],
506506
"default": "Disabled",
507-
"description": "If enabled, code is colorized based on IntelliSense. This setting has no effect if IntelliSense is disabled.",
507+
"description": "If enabled, code is colorized based on IntelliSense. This setting has no effect if IntelliSense is disabled or if using the Default High Contrast theme.",
508508
"scope": "resource"
509509
}
510510
}

Extension/src/LanguageServer/client.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ interface OutputNotificationBody {
8282
output: string;
8383
}
8484

85-
interface SyntacticColorizationRegionsParams {
86-
uri: string;
87-
regions: InputColorizationRegion[];
88-
editVersion: number;
89-
}
90-
9185
interface SemanticColorizationRegionsParams {
9286
uri: string;
9387
regions: InputColorizationRegion[];
@@ -159,12 +153,12 @@ interface DidChangeVisibleRangesParams {
159153
ranges: Range[];
160154
}
161155

162-
interface SyntacticColorizationRegionsReceiptParams {
156+
interface SemanticColorizationRegionsReceiptParams {
163157
uri: string;
164158
}
165159

166-
interface SemanticColorizationRegionsReceiptParams {
167-
uri: string;
160+
interface ColorThemeChangedParams {
161+
name: string;
168162
}
169163

170164
// Requests
@@ -193,8 +187,8 @@ const CustomBrowseConfigurationNotification: NotificationType<CustomBrowseConfig
193187
const ClearCustomConfigurationsNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/clearCustomConfigurations');
194188
const RescanFolderNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/rescanFolder');
195189
const DidChangeVisibleRangesNotification: NotificationType<DidChangeVisibleRangesParams, void> = new NotificationType<DidChangeVisibleRangesParams, void>('cpptools/didChangeVisibleRanges');
196-
const SyntacticColorizationRegionsReceiptNotification: NotificationType<SyntacticColorizationRegionsReceiptParams, void> = new NotificationType<SyntacticColorizationRegionsReceiptParams, void>('cpptools/syntacticColorizationRegionsReceipt');
197190
const SemanticColorizationRegionsReceiptNotification: NotificationType<SemanticColorizationRegionsReceiptParams, void> = new NotificationType<SemanticColorizationRegionsReceiptParams, void>('cpptools/semanticColorizationRegionsReceipt');
191+
const ColorThemeChangedNotification: NotificationType<ColorThemeChangedParams, void> = new NotificationType<ColorThemeChangedParams, void>('cpptools/colorThemeChanged');
198192

199193
// Notifications from the server
200194
const ReloadWindowNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/reloadWindow');
@@ -204,7 +198,6 @@ const ReportTagParseStatusNotification: NotificationType<ReportStatusNotificatio
204198
const ReportStatusNotification: NotificationType<ReportStatusNotificationBody, void> = new NotificationType<ReportStatusNotificationBody, void>('cpptools/reportStatus');
205199
const DebugProtocolNotification: NotificationType<OutputNotificationBody, void> = new NotificationType<OutputNotificationBody, void>('cpptools/debugProtocol');
206200
const DebugLogNotification: NotificationType<OutputNotificationBody, void> = new NotificationType<OutputNotificationBody, void>('cpptools/debugLog');
207-
const SyntacticColorizationRegionsNotification: NotificationType<SyntacticColorizationRegionsParams, void> = new NotificationType<SyntacticColorizationRegionsParams, void>('cpptools/syntacticColorizationRegions');
208201
const SemanticColorizationRegionsNotification: NotificationType<SemanticColorizationRegionsParams, void> = new NotificationType<SemanticColorizationRegionsParams, void>('cpptools/semanticColorizationRegions');
209202
const CompileCommandsPathsNotification: NotificationType<CompileCommandsPaths, void> = new NotificationType<CompileCommandsPaths, void>('cpptools/compileCommandsPaths');
210203
const UpdateClangFormatPathNotification: NotificationType<string, void> = new NotificationType<string, void>('cpptools/updateClangFormatPath');
@@ -479,7 +472,6 @@ class DefaultClient implements Client {
479472
autocomplete: settings.autoComplete,
480473
errorSquiggles: settings.errorSquiggles,
481474
dimInactiveRegions: settings.dimInactiveRegions,
482-
textMateColorization: settings.textMateColorization,
483475
enhancedColorization: settings.enhancedColorization,
484476
suggestSnippets: settings.suggestSnippets,
485477
loggingLevel: settings.loggingLevel,
@@ -528,9 +520,6 @@ class DefaultClient implements Client {
528520
}
529521

530522
public onDidChangeSettings(event: vscode.ConfigurationChangeEvent): { [key: string] : string } {
531-
if (event.affectsConfiguration("C_Cpp.textMateColorization", this.RootUri)) {
532-
this.colorizationSettings.updateGrammars();
533-
}
534523
let colorizationNeedsReload: boolean = event.affectsConfiguration("workbench.colorTheme")
535524
|| event.affectsConfiguration("editor.tokenColorCustomizations");
536525

@@ -541,6 +530,12 @@ class DefaultClient implements Client {
541530
|| event.affectsConfiguration("C_Cpp.inactiveRegionForegroundColor", this.RootUri)
542531
|| event.affectsConfiguration("C_Cpp.inactiveRegionBackgroundColor", this.RootUri);
543532

533+
let colorThemeChanged: boolean = event.affectsConfiguration("workbench.colorTheme", this.RootUri);
534+
if (colorThemeChanged) {
535+
let otherSettings: OtherSettings = new OtherSettings(this.RootUri);
536+
this.languageClient.sendNotification(ColorThemeChangedNotification, { name: otherSettings.colorTheme } );
537+
}
538+
544539
if (colorizationNeedsReload) {
545540
this.colorizationSettings.reload();
546541
}
@@ -1000,7 +995,6 @@ class DefaultClient implements Client {
1000995
this.languageClient.onNotification(ReportNavigationNotification, (e) => this.navigate(e));
1001996
this.languageClient.onNotification(ReportStatusNotification, (e) => this.updateStatus(e));
1002997
this.languageClient.onNotification(ReportTagParseStatusNotification, (e) => this.updateTagParseStatus(e));
1003-
this.languageClient.onNotification(SyntacticColorizationRegionsNotification, (e) => this.updateSyntacticColorizationRegions(e));
1004998
this.languageClient.onNotification(SemanticColorizationRegionsNotification, (e) => this.updateSemanticColorizationRegions(e));
1005999
this.languageClient.onNotification(CompileCommandsPathsNotification, (e) => this.promptCompileCommands(e));
10061000
this.setupOutputHandlers();
@@ -1216,21 +1210,6 @@ class DefaultClient implements Client {
12161210
return colorizationState;
12171211
}
12181212

1219-
private updateSyntacticColorizationRegions(params: SyntacticColorizationRegionsParams): void {
1220-
// Convert the params to vscode.Range's before passing to colorizationState.updateSyntactic()
1221-
let syntacticRanges: vscode.Range[][] = new Array<vscode.Range[]>(TokenKind.Count);
1222-
for (let i: number = 0; i < TokenKind.Count; i++) {
1223-
syntacticRanges[i] = [];
1224-
}
1225-
params.regions.forEach(element => {
1226-
let newRange : vscode.Range = new vscode.Range(element.range.start.line, element.range.start.character, element.range.end.line, element.range.end.character);
1227-
syntacticRanges[element.kind].push(newRange);
1228-
});
1229-
let colorizationState: ColorizationState = this.getColorizationState(params.uri);
1230-
colorizationState.updateSyntactic(params.uri, syntacticRanges, params.editVersion);
1231-
this.languageClient.sendNotification(SyntacticColorizationRegionsReceiptNotification, { uri: params.uri });
1232-
}
1233-
12341213
private updateSemanticColorizationRegions(params: SemanticColorizationRegionsParams): void {
12351214
// Convert the params to vscode.Range's before passing to colorizationState.updateSemantic()
12361215
let semanticRanges: vscode.Range[][] = new Array<vscode.Range[]>(TokenKind.Count);

0 commit comments

Comments
 (0)