Repository navigation
Commit fa9cdfb
Rewrite the missing-space rule without a negative lookahead
`//foo` gets a space after its slashes unless the comment is an IDE
marker, `//noinspection` or `//$NON-NLS-n$`, which the tools recognise
only as written. The exemption was a negative lookahead inside the
matching pattern; it is now a second pattern that names the markers,
checked after the first one matches. The two forms accept the same
lines: the first pattern needs a non-space, non-slash character right
after the slashes, so the lookahead was always evaluated after the whole
run of slashes, which is where the second pattern looks as well.
Taken from google/google-java-format#1460, whose motivation stands here
too: regex engines without backtracking do not support lookahead, and
the markers are easier to read, and to share with doc/Comment as #23
asks, as a pattern of their own. The rest of that change does not apply:
`Strings.repeat` is already `String.repeat` here, and the markdown
branch belongs to google-java-format's own `///` handling.
FormatterTest pins the behaviour before and after: both markers, a
marker followed by text, `//foo`, `///foo`, and comments that already
have their space.1 parent 2fbf175 commit fa9cdfb
2 files changed
Lines changed: 32 additions & 3 deletions
File tree
- open-java-format/src
- main/java/com/palantir/javaformat/java
- test/java/com/palantir/javaformat/java
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | | - | |
173 | | - | |
| 174 | + | |
| 175 | + | |
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
| |||
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
188 | | - | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
370 | 397 | | |
371 | 398 | | |
372 | 399 | | |
| |||
0 commit comments