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

Inconsistency between indent level in AOSP and non-aosp #1189

Open
blacksails opened this issue Nov 18, 2024 · 2 comments
Open

Inconsistency between indent level in AOSP and non-aosp #1189

blacksails opened this issue Nov 18, 2024 · 2 comments

Comments

@blacksails
Copy link

blacksails commented Nov 18, 2024

I am not entirely sure wether this is the intended behavior, so here is an issue. The the continuation of the long string doesn't indent with 8 spaces from the previous line which I would expect in AOSP.

Test.java

public class Test {
    String s = "asdfasdfasdfasdf asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
❯ java -jar ~/Downloads/google-java-format-1.24.0-all-deps.jar Test.java
public class Test {
  String s =
      "asdfasdfasdfasdf"
          + " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
❯ java -jar ~/Downloads/google-java-format-1.24.0-all-deps.jar --aosp Test.java
public class Test {
    String s =
            "asdfasdfasdfasdf"
                + " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}

I would expect the following output using AOSP style

public class Test {
    String s =
            "asdfasdfasdfasdf"
                    + " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}

I raised this issue in the spotless repo because I figured that spotless not indenting the same way as GJF would be a spotless bug.

If this is the intended behavior, please let me know, so that I can reraise the issue at spotless.

@blacksails
Copy link
Author

Spotless issue for reference: diffplug/spotless#2338

@cushon
Copy link
Collaborator

cushon commented Nov 19, 2024

Thanks for the report. The wrapping of long string literals is handled as a separate pass (--skip-reflowing-long-strings), and I think it's making non-AOSP assumptions instead of passing in the configuration.

I haven't double-checked if this is the exact culprit, but this comment looks suspicious:

width -= 6; // subsequent lines have a four-space continuation indent and a `+ `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants