Coder Social home page Coder Social logo

Comments (4)

cushon avatar cushon commented on June 7, 2024 1

@vorburger the illegal escape character error is because you're running the formatting on JDK 17, which predates string template support. Using JDK 21 instead will resolve that error.

from google-java-format.

sormuras avatar sormuras commented on June 7, 2024

Agreed. The extra line-break happens with 1.19.2, version 1.19.1 does not introduce it.

from google-java-format.

cushon avatar cushon commented on June 7, 2024

I agree this is not ideal. I think the specific change in 1.19.2 was 38de9c4, prior to that code inside \{ ... } wasn't getting reformatted at all. I think we want to keep formatting complex expressions inside placeholders, but it would be nice to avoid the line breaks in this situation.

from google-java-format.

vorburger avatar vorburger commented on June 7, 2024

This works great (~leaves it alone) for "single line", e.g. var html = STR."<table class="{cssClass}">";

Or does it? I just ran into the following, and am surprised I didn't run into this previously (it's likely because I reinstalled tools from scratch, so it's possible my google-java-format changed and upgraded, it looks like it's running the latest 1.19.2 now, as configured, it's possible I may have been running an older version before somehow, I'm not 100% sure anymore):

$ git clone https://github.com/enola-dev/enola.git
$ git checkout 983f7ee
$ ./test.sh
$ source .venv/bin/activate [.fish, or not; depending on your shell]
$ pre-commit run --all-files

Google Java Formatter....................................................Failed
- hook id: pretty-format-java
- exit code: 1

[cwd=/home/vorburger/git/github.com/vorburger/enola] Run command: ('java', '-version')
[return_code=0] | 
	stderr: openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-2)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-2, mixed mode, sharing)

Downloading https://github.com/google/google-java-format/releases/download/v1.19.2/google-java-format-1.19.2-all-deps.jar
[cwd=/home/vorburger/git/github.com/vorburger/enola] Run command: ('java', '--add-exports', 'jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED', '--add-exports', 'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED', '--add-exports', 'jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED', '--add-exports', 'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED', '--add-exports', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED', '-jar', '/home/vorburger/.cache/pre-commit/google-java-formatter1.19.2.jar', '--set-exit-if-changed', '--aosp', '--replace', 

(...)

[return_code=1] | 
	stderr: tools/hello/src/main/java/dev/enola/common/hello/Hello.java:30:30: error: illegal escape character
tools/hello/src/main/java/dev/enola/common/hello/Library.java:27:30: error: illegal escape character
web/ui/src/main/java/dev/enola/web/ui/ThingUI.java:72:50: error: illegal escape character
web/ui/src/main/java/dev/enola/web/ui/ThingUI.java:73:34: error: illegal escape character

from google-java-format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.