Skip to content

What's the difference between google-java-format plugin and google java style xml file? #695

Closed as not planned
@jwcheong0420

Description

@jwcheong0420

Hello,

As far as I know, there are two ways to apply google java style for Intellij

  1. Install google-java-format plugin and enable it
  2. Download google style xml file and import it into File→Settings→Editor→Code Style

I expected the same result, but the two methods seem to produce different results as follows,

  • Location of @Getter when @Getter put on a field

    • Code reformatted with google-java-format plugin(1.13.0.0)
    @Getter private final String value;
    • Code reformatted with imported code style from xml file
    @Getter
    private final String value;
  • Indent of @ApiImplicitParams({})

    • Code reformatted with google-java-format plugin(1.13.0.0)
    @ApiImplicitParams({
      @ApiImplicitParam(name = "name", value = "user name", dataTypeClass = String.class),
    })
    • Code reformatted with imported code style from xml file
    @ApiImplicitParams({
        @ApiImplicitParam(name = "name", value = "user name", dataTypeClass = String.class),
    })
  • Line wrapping when using stream

    • Code reformatted with google-java-format plugin(1.13.0.0)
    @RequiredArgsConstructor
    List<Integer> numbers = Arrays.asList(10, 2, 5, 32, 2, 5, 12, 34);
    List<Integer> results =
        numbers.stream()
            .map(number -> number * number)
            .filter(number -> number < 100)
            .collect(Collectors.toList());
    • Code reformatted with imported code style from xml file
    List<Integer> numbers = Arrays.asList(10, 2, 5, 32, 2, 5, 12, 34);
    List<Integer> results = numbers.stream()
        .map(number -> number * number)
        .filter(number -> number < 100)
        .collect(Collectors.toList());

Is it right that the results are different?
I think the reformat result by the plugin is consistent with the google java convention.
Why did the reformat result by xml file come out like this?

Any help would be much appreciated. Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions