Skip to content

Intellij plugin seems to stop working when Java 14/15 features are used #533

@fhediger

Description

@fhediger

I use the latest google-java-format Intellij plugin based on google-java-format 1.9. As I understand it, this version should support Java 14/15 features like switch expressions and text blocks. In our case if any of the mentioned language features are used formatting stops working.

Just wanted to ask whether this may be a bug in my setup or if you're seeing the same problems?

Intellij IDEA Version: Ultimate Edition 2020.2.3 (Build #IU-202.7660.26, built on October 6, 2020)

Operating System: Ubuntu 20.04.1 LTS

Here is a small example:

public class FormatTest {
  enum Test {
    A, B
  }
  public static void main(String[] args) {
    String foo =                  "This should not be here";
    Test t = Test.A;
    String foobar = switch(t) {
      case A -> "foobar";
      case B -> "barfoo";
    };
    String xyz = """
            """;
  }
}

When I try to format this inside the IDE nothing happens. It shows that it's reformatting the code but the formatting doesn't change.There is no error as far as I can see.

However, formatting it with google-java-format-1.9-all-deps.jar it outputs correctly:

public class FormatTest {
  enum Test {
    A,
    B
  }

  public static void main(String[] args) {
    String foo = "This should not be here";
    Test t = Test.A;
    String foobar =
        switch (t) {
          case A -> "foobar";
          case B -> "barfoo";
        };
    String xyz = """
            """;
  }
}

Any help concerning this issue would be very much appreciated! Thanks for your great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions