question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Java code formatter rules is ignored

See original GitHub issue

This 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
  1. 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CsCherrYYcommented, Oct 23, 2020

Hi, @CarlPer , it seems a formatter version bug. The formatter version of template in vscode-java is 13. And the current version of eclipse is 21. 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.

0reactions
CsCherrYYcommented, Mar 18, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found