Update VS Code Java formatter instructions
Turns out that `git cl format` uses clang-format to format Java code, and the current instructions using JDT would produce formatting that can be quite different. Fix the instructions to make VS Code format Java files in the exact same way `git cl format` does. Change-Id: I7d0476bf9c2d84d2c9dfe3ca13be4811079d45b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4614846 Reviewed-by: Chase Phillips <cmp@chromium.org> Commit-Queue: Chase Phillips <cmp@chromium.org> Auto-Submit: Etienne Dechamps <edechamps@google.com> Cr-Commit-Position: refs/heads/main@{#1158331}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
57286214e2
commit
2fba525ab5
@ -282,6 +282,28 @@ that risks overwriting the generated `.classpath` file.
|
||||
[autogenerated](/base/android/jni_generator/README.md) `GEN_JNI` class. This
|
||||
is a known quirk of the JNI generator.
|
||||
|
||||
#### Automatic formatting
|
||||
|
||||
Java code in Chromium is formatted using [clang-format](/docs/clang_format.md).
|
||||
To get VS Code to use clang-format to format Java files, install the
|
||||
[*Clang-Format* extension](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
|
||||
and set it as the default formatter for Java in your workspace `settings.json`:
|
||||
|
||||
```json
|
||||
"[java]": {
|
||||
"editor.defaultFormatter": "xaver.clang-format"
|
||||
}
|
||||
```
|
||||
|
||||
To avoid potential formatting differences due to clang-format version skew, it
|
||||
makes sense to configure the extension to run clang-format in the same way
|
||||
`git cl format` would. You can do this by adding the following to your
|
||||
workspace `settings.json`:
|
||||
|
||||
```json
|
||||
"clang-format.executable": "<< PATH TO YOUR CHROMIUM WORKING COPY >>/src/buildtools/linux64/clang-format"
|
||||
```
|
||||
|
||||
## Setup For Chromium
|
||||
|
||||
VS Code is configured via JSON files. This paragraph contains JSON configuration
|
||||
|
@ -72,11 +72,6 @@
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnSaveMode": "modifications",
|
||||
|
||||
// Format Java code according to Android style. Requires the "Language Support
|
||||
// for Java(TM) by Red Hat" extension. Read the "Java/Android Support" section
|
||||
// in //docs/vscode.md *before* installing the extension.
|
||||
"java.format.settings.url": "https://raw.githubusercontent.com/android/platform_development/master/ide/eclipse/android-formatting.xml",
|
||||
|
||||
// Disable automatic task detection to speed up opening the task menu.
|
||||
"task.autoDetect": "off",
|
||||
|
||||
|
Reference in New Issue
Block a user