Conversation
Connect the CLI to existing Style.Builder.useTabs support without changing the default space-based indentation or formatting algorithms. Document style-dependent tab stops and add parser, argument-file, stdin, line-wrapping, dry-run/replace, and imports-only regression tests.
|
@cushon Since this is missing in 1.37.0 it would be great to get this merged soon and maybe even a new release ... ;) |
|
I hadn't completely decided if we were going to add the CLI counterpart for this one. I have no intention of trying to convince anyone to switch, I know some codebases use tabs, and I think this configuration is closer to #425 had a lot of votes, it was more clear it was a blocker to adoption of the formatter. I think the only request for tab support was in #1320, which only needed support in the API. In general it seems like there may be less usage of tabs for Java. Another potential difference from max line length is that it's easier to do this as a post-processing step, to replace leading spaces with tabs. For sbt-java-formatter would it be possible to use the API instead of the CLI, or maybe even post-process the output to replace leading spaces with tabs? |
|
I was just under the impression the CLI counterpart was just missed - didn't know that it was intentionally not implemented, thats why I came up with the PR. I guess its fine how it is - maybe lets just wait in both projects (google-java-format and sbt-java-formatter) if more requests come in. And yes, actually just doing post processing in sbt-java-formatter is definitely an options since that should really just be replacing leading white spaces. Anyway, I leave this PR option, maybe it will be considered in the future. Thanks! |
|
Thanks, that makes sense!
SGTM. I'm going to go ahead and close the PR for now, I filed #1470 to track demand for this. |
The pull request
added programmatic tab support through
JavaFormatterOptions.Style.Builder.useTabs(boolean), followingThis PR exposes that existing functionality through a
--use-tabsCLI flag.This lets CLI-based integrations, such as sbt-java-formatter, enable tabs without calling the formatter API directly.
The implementation only connects the parser to the existing style builder; it does not change the formatting algorithm or add another public API. Spaces remain the default. With
--use-tabs, tab stops are 2 columns for Google style and 4 columns for AOSP, with spaces retained where needed for alignment.