Java code formatter rules is ignored
See original GitHub issueThis rule is ignored when formatting:
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
Environment
- Operating System: Windows 10 Enterprise v.1909
- JDK version: Amazon Corretto jdk1.8.0_252
- Visual Studio Code version: 1.49.2
- Java extension version: 0.68.0
Steps To Reproduce
- Format : List<String> fromJson = new Gson().fromJson(“String”, new TypeToken<List<String>>() {}.getType());
Current Result
List<String> fromJson = new Gson().fromJson("String", new TypeToken<List<String>>() {
}.getType());
Expected Result
List<String> fromJson = new Gson().fromJson("String", new TypeToken<List<String>>() {}.getType());
Additional Informations
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How can a consistent Java code format be enforced?
Now the code will by default be formatted the way the template has been written. Or use Ctrl +Shift+ F as the eclipse...
Read more >Google Java Style Guide
1 Introduction. This document serves as the complete definition of Google's coding standards for source code in the Java™ Programming Language.
Read more >Reformat code | IntelliJ IDEA Documentation - JetBrains
You can select formatting rules which will be ignored when you reformat the code. For example, you can adjust the IDE to keep...
Read more >User and Workspace Settings - Visual Studio Code
Errors due to incorrect setting names or JSON formatting are also highlighted. IntelliSense for settings.json open in the editor. Some settings can only...
Read more >Formatter (Java Platform SE 7 ) - Oracle Help Center
Also, Java formatting is more strict than C's; for example, if a conversion is incompatible with a flag, an exception will be thrown....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, @CarlPer , it seems a formatter version bug. The formatter version of template in
vscode-java
is13
. And the current version of eclipse is21
. There are some differences between the two versions so your settings may be ignored. We are trying to add a formatter version updater into the language server, and it will make effect at the next jdt version. Now you can simply replace this setting by<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/>
to solve this problem as a workaround.@rgrunber Yes. https://github.com/eclipse/eclipse.jdt.ls/pull/1675/commits/704e50bf09711ebb72f09e91a7c1fef66ffc9d72 uses the utility you mentioned to check if there is any need to update the profile.