Skip to content

Commit 7edc91c

Browse files
committed
Merge remote-tracking branch 'origin/main' into jfriend/respect-git-config-global
2 parents 22ca994 + c8e8ade commit 7edc91c

26 files changed

Lines changed: 1210 additions & 57 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link')
9292
curl --location "$download_link" -o idea.tar.gz
9393
tar -xf idea.tar.gz
94-
cd idea-IC*
94+
cd idea-IU*
9595
export PATH=${PATH}:$(pwd)/bin
9696
cd ..
9797
./gradlew testIdea

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1111

1212
## [Unreleased]
1313
### Added
14+
- Add `versionCatalog` step for formatting and sorting Gradle version catalog (`.toml`) files. ([#2916](https://github.com/diffplug/spotless/issues/2916))
1415
- Add `javaparserVersion` option to the Cleanthat step, allowing callers to override the JavaParser version pulled in transitively by Cleanthat. ([#2903](https://github.com/diffplug/spotless/pull/2903))
16+
### Fixed
17+
- Fix non-idempotent formatting when `importOrder()` is combined with `greclipse()`: a single catch-all group no longer strips blank lines that `greclipse()` independently inserted between import groups. ([#2914](https://github.com/diffplug/spotless/pull/2914))
1518
### Changes
1619
- Bump default `cleanthat` version `2.24` -> `2.25`. ([#2903](https://github.com/diffplug/spotless/pull/2903))
1720
- Bump default `eclipse-jdt` version from `4.35` to `4.39`. ([#2912](https://github.com/diffplug/spotless/pull/2912))

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ sortpom-sorter = "com.github.ekryd.sortpom:sortpom-sorter:4.0.0"
5757
tabletest-formatter-core = "org.tabletest:tabletest-formatter-core:1.1.1"
5858
zjsonpatch = "com.flipkart.zjsonpatch:zjsonpatch:0.4.16"
5959

60-
rewrite-recipe-migrate-java = "org.openrewrite.recipe:rewrite-migrate-java:3.30.0"
61-
rewrite-recipe-static-analysis = "org.openrewrite.recipe:rewrite-static-analysis:2.30.0"
62-
rewrite-recipe-third-party = "org.openrewrite.recipe:rewrite-third-party:0.36.2"
60+
rewrite-recipe-migrate-java = "org.openrewrite.recipe:rewrite-migrate-java:3.34.0"
61+
rewrite-recipe-static-analysis = "org.openrewrite.recipe:rewrite-static-analysis:2.34.0"
62+
rewrite-recipe-third-party = "org.openrewrite.recipe:rewrite-third-party:0.38.1"
6363

6464
errorprone-core = "com.google.errorprone:error_prone_core:2.42.0"
6565

lib/src/main/java/com/diffplug/spotless/java/ImportSorter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2026 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Scanner;
2121
import java.util.Set;
22+
import java.util.stream.Collectors;
2223

2324
/**
2425
* @author Vojtech Krasa
@@ -91,6 +92,15 @@ String format(String raw, String lineFormat) {
9192

9293
List<String> sortedImports = ImportSorterImpl.sort(imports, importsOrder, wildcardsLast, semanticSort,
9394
treatAsPackage, treatAsClass, lineFormat);
95+
boolean sortedHasNoBlanks = sortedImports.stream().noneMatch(N::equals);
96+
if (sortedHasNoBlanks && firstImportLine > 0) {
97+
List<String> originalFormatted = imports.stream()
98+
.map(i -> lineFormat.formatted(i) + N)
99+
.collect(Collectors.toList());
100+
if (sortedImports.equals(originalFormatted)) {
101+
return raw;
102+
}
103+
}
94104
return applyImportsToDocument(raw, firstImportLine, lastImportLine, sortedImports);
95105
}
96106

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# VersionCatalogStep — Known Limitations & Future Work
2+
3+
Tracked issues found during review against the TOML v1.1.0 spec (https://toml.io/en/v1.1.0).
4+
5+
## Fixed
6+
7+
- [x] Comments inside sections are silently dropped (data loss for annotated catalogs)
8+
- [x] Inline comments after values break inline-table/array formatting
9+
- [x] Blank lines in preamble are dropped
10+
- [x] Sort uses raw string including quote characters instead of logical key name
11+
- [x] Multi-line inline tables are not parsed correctly (split across lines and corrupted)
12+
- [x] Long lines can be split into multi-line inline tables (configurable `maxLineLength`)
13+
- [x] Short multi-line inline tables are joined into single lines when they fit
14+
15+
## TODO — TOML spec edge cases
16+
17+
These are valid TOML constructs that the current implementation does not handle correctly.
18+
They are uncommon (or impossible) in typical Gradle version catalogs, but should be
19+
addressed for full TOML spec compliance.
20+
21+
### Parsing
22+
23+
- [ ] `ENTRY_LINE` regex `^([^=]+)=(.+)$` is not quote-aware — breaks on quoted keys
24+
containing `=`, e.g. `"key=val" = "foo"`. Needs a state-machine parser to find
25+
the separator `=` outside quoting context.
26+
- [ ] `TABLE_HEADER` regex only matches bare keys — rejects dotted table headers
27+
(`[section.subsection]`) and quoted table headers (`["quoted.key"]`).
28+
Their entries are silently dropped.
29+
30+
### String handling in `splitTopLevel`
31+
32+
- [ ] Single-quoted (literal) strings `'...'` are not recognized — commas or `=` inside
33+
them will incorrectly split or match.
34+
- [ ] Multiline string delimiters (`"""`, `'''`) confuse the single-char quote toggle.
35+
- [ ] Double-backslash before closing quote (`"value\\"`) is misidentified as an escaped
36+
quote. Needs odd/even backslash counting instead of single-char lookbehind.

0 commit comments

Comments
 (0)