Skip to content

Commit f0930b5

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-expand-wildcard-jdk-xml-types
2 parents ed0eddc + c8e8ade commit f0930b5

25 files changed

Lines changed: 1207 additions & 54 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
- Fix `expandWildcardImports` failing on JDK XML types such as `org.xml.sax.InputSource`. ([#2921](https://github.com/diffplug/spotless/pull/2921))
1720
- Bump default `cleanthat` version `2.24` -> `2.25`. ([#2903](https://github.com/diffplug/spotless/pull/2903))

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)