Comments (4)
@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.
Agreed. The extra line-break happens with 1.19.2
, version 1.19.1
does not introduce it.
from google-java-format.
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.
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)
- The unused method cannot be detected HOT 2
- Import Ordering configuration suppressed on README HOT 2
- help HOT 4
- Version 1.20.0 hasn't been published to MavenCentral HOT 1
- 1.20.0 binaries reports incorrect version (HEAD-SNAPSHOT) when called with the -v flag HOT 2
- Request google-java-format IntelliJ plugin version 1.18 HOT 1
- Before commit reformatting option in IntelliJ does invoke plugin
- google-java-format_linux-x86-64: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./google-java-format_linux-x86-64) HOT 6
- The google-java-formatter eclipse plugin doesn't change the format of my code HOT 2
- IllegalAccessError from com.sun.tools.javac.util
- Omit the redundant method isReal() to make it simpler
- Excess indentation with method-receiving text blocks HOT 2
- compatibility with Gradle 9.x
- Inconsistent blank line between license and package statement HOT 1
- Inconsistent formatting of text blocks in 1.21.0 HOT 7
- bug report: 1.21.0 IntelliJ vs jar inconsistency HOT 3
- Misleading message for --dry-run with --replace
- MAX_LINE_LENGTH parameterized HOT 1
- Error processing case statements using JVM "17-ea (Azul Systems, Inc. 17-ea+12)" HOT 2
- google-java-format Idea plugin does not work on jdk21 version.Please provide support if possible. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-java-format.