Skip to content

Commit c8e8ade

Browse files
authored
Add TOML version catalog formatter step (#2917)
2 parents ed86b24 + 35356db commit c8e8ade

13 files changed

Lines changed: 869 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ 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))
1516
### Fixed
1617
- 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))
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)