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

Json formatting arrays #4936

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

greg-at-moderne
Copy link
Contributor

What's changed?

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Comment on lines +18 to +19
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.Nullable;

return ret.getPadding().withValues(ensureCollectionHasNewLines(ret.getPadding().getValues()));
}

private static <J extends Json> @NotNull List<JsonRightPadded<J>> ensureCollectionHasNewLines(List<JsonRightPadded<J>> elements) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static <J extends Json> @NotNull List<JsonRightPadded<J>> ensureCollectionHasNewLines(List<JsonRightPadded<J>> elements) {
private static <J extends Json> List<JsonRightPadded<J>> ensureCollectionHasNewLines(List<JsonRightPadded<J>> elements) {

Comment on lines +18 to 19
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.Nullable;

for (int i = 0; i < indentMultiple; i++) {
if (style.getUseTabCharacter()) {
shiftedPrefixBuilder.append("\t");
private static @NotNull <J extends Json> List<JsonRightPadded<J>> ensureCollectionHasIndents(List<JsonRightPadded<J>> elements, String relativeIndent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static @NotNull <J extends Json> List<JsonRightPadded<J>> ensureCollectionHasIndents(List<JsonRightPadded<J>> elements, String relativeIndent) {
private static <J extends Json> List<JsonRightPadded<J>> ensureCollectionHasIndents(List<JsonRightPadded<J>> elements, String relativeIndent) {

@greg-at-moderne greg-at-moderne self-assigned this Jan 23, 2025
@greg-at-moderne greg-at-moderne changed the title Json formatting sequences Json formatting arrays Jan 24, 2025

@Override
public String getDescription() {
return "Indents JSON using the most common indentation size and tabs or space choice in use in the file.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this will be about more than indenting, we might want to make the description a bit more general.

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

Successfully merging this pull request may close these issues.

2 participants