简体   繁体   中英

Google java format in IntelliJ IDEA

I am using the Google-java-formatter in IntelliJ IDEA. I tried all the option present under setting > editor > code Style > java but not able to change this behavior.

private void insertOfflinePreferences(String loginId, String clientId, List<AlertPrefsNgBO> alertPrefsNgBOS) {

List<SubscriptionAlertEntity> subscriptionAlertEntities = subscriptionAlertRepository.getSubscriptionAlertEntities(login);

This line is getting formatted as

private void insertOfflinePreferences(
  String loginId, String clientId, List<AlertPrefsNgBO> alertPrefsNgBOS) {


List<SubscriptionAlertEntity> subscriptionAlertEntities =
          subscriptionAlertRepository.getSubscriptionAlertEntities(login);

I don't want the line change. It is doing same for the stream operations in java.

Quoting the github page :

Note: There is no configurability as to the formatter's algorithm for formatting. This is a deliberate design decision to unify our code formatting on a single format.

Either use google-java-formatter, or don't. (I simply stopped caring about GJF's choices years ago, because I'm used to it; and even in cases where it doesn't format it exactly how I'd like, the formatting is not totally disagreeable).

If I understand well, you want the IntelliJ to stop wrapping your lines ?

For that you can set the Hard Wrap field to a higher value. The default is 120, which means that every line of more than 120 characters will be wrapped.

You can find this parameter in Settings>Editor>Code Style (And not in Settings>Editor>Code Style>Java)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM