Commit 8909446
committed
TomlParserVisitor: strip quotes from quoted-key identifier name
`Toml.Identifier.name` previously held the verbatim source for both bare
and quoted simple keys, so `"foo"` and `foo` produced different `name`
values even though the TOML spec treats them as the same key. Consumers
that matched on `getName()` had to strip quotes themselves at every site.
The class already has a separate `source` field for round-trip fidelity;
populate `name` with the unquoted form for simple keys while keeping
`source` as-is so the printer still emits the original.
Dotted keys are out of scope for this change. Without a dedicated
multi-segment AST type the parser cannot tell `site."google.com"` (two
segments, the second containing a literal dot) apart from `site.google.com`
(three segments) once both are flattened into a single `name` string, so
quoted segments inside a dotted key remain unstripped for now.1 parent c4774bb commit 8909446
2 files changed
Lines changed: 45 additions & 8 deletions
File tree
- rewrite-toml/src
- main/java/org/openrewrite/toml/internal
- test/java/org/openrewrite/toml
Lines changed: 31 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
165 | 189 | | |
166 | 190 | | |
167 | 191 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
314 | 327 | | |
315 | 328 | | |
316 | 329 | | |
| |||
0 commit comments