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

enable semantic highlighting by default #1584

Merged
merged 1 commit into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ The following settings are supported:
Default launch mode is `Hybrid`. Legacy mode is `Standard`
* `java.sources.organizeImports.starThreshold`: Specifies the number of imports added before a star-import declaration is used, default is 99.
* `java.sources.organizeImports.staticStarThreshold`: Specifies the number of static imports added before a star-import declaration is used, default is 99.
* `java.semanticHighlighting.enabled`: Enable/disable [Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) for Java files. Defaults to `false`.
* `java.semanticHighlighting.enabled`: Enable/disable [Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) for Java files. Defaults to `true`.
* `java.requirements.JDK11Warning`: Enable/disable a warning about the impending requirement of Java 11. Defaults to `true`.
* `java.refactor.renameFromFileExplorer`: Specifies whether to update imports and package declarations when renaming files from File Explorer. Defaults to `prompt`.
- `never`: Don't enable refactoring for rename operations on File Explorer.
Expand All @@ -175,10 +175,6 @@ Semantic Highlighting
===============
[Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) is controlled by the `java.semanticHighlighting.enabled` preference. When enabled, it fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience different small issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server, when opening a new file or when typing.

You will be prompted to enable or disable it on startup:

![](https://user-images.githubusercontent.com/148698/80595049-65d2f000-8a24-11ea-8d9c-19b05b9cac15.png)

Troubleshooting
===============
1. Check the status of the language tools on the lower right corner (marked with A on image below).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
},
"java.semanticHighlighting.enabled": {
"type": "boolean",
"default": false,
"default": true,
"description": "Enable/disable the semantic highlighting.",
"scope": "window"
},
Expand Down
14 changes: 2 additions & 12 deletions src/semanticTokenProvider.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import * as vscode from 'vscode';
import { Commands } from './commands';
import { getJavaConfiguration, isPreferenceOverridden } from './utils';
import { getJavaConfiguration } from './utils';

const semanticHighlightingKey = 'java.semanticHighlighting.enabled';

export function registerSemanticTokensProvider(context: vscode.ExtensionContext) {
if (!vscode.languages.registerDocumentSemanticTokensProvider) { // in case Theia doesn't support this API
return;
}
if (!isPreferenceOverridden(semanticHighlightingKey)) {
const enable = "Enable";
const disable = "Disable";
vscode.window.showInformationMessage("Enable [Semantic highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) for Java by default?", enable, disable).then(selection => {
if (selection === enable) {
vscode.workspace.getConfiguration().update(semanticHighlightingKey, true, vscode.ConfigurationTarget.Global);
} else if (selection === disable) {
vscode.workspace.getConfiguration().update(semanticHighlightingKey, false, vscode.ConfigurationTarget.Global);
}
});
}

if (isSemanticHighlightingEnabled()) {
getSemanticTokensLegend().then(legend => {
const documentSelector = [
Expand Down