konsti
13f9a16e33
Rewrite placement logic ( #6040 )
...
## Summary
This is a rewrite of the main comment placement logic. `place_comment`
now has three parts:
- place own line comments
- between branches
- after a branch
- place end-of-line comments
- after colon
- after a branch
- place comments for specific nodes (that include module level comments)
The rewrite fixed three bugs: `class A: # trailing comment` comments now
stay end-of-line, `try: # comment` remains end-of-line and deeply
indented try-else-finally comments remain with the right nested
statement.
It will be much easier to give more alternative branches nodes since
this is abstracted away by `is_node_with_body` and the first/last child
helpers. Adding new node types can now be done by adding an entry to the
`place_comment` match. The code went from 1526 lines before #6033 to
1213 lines now.
It thinks it easier to just read the new `placement.rs` rather than
reviewing the diff.
## Test Plan
The existing fixtures staying the same or improving plus new ones for
the bug fixes.
2023-07-26 16:21:23 +00:00
..
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-21 12:07:51 +00:00
2023-07-11 06:08:08 +00:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-07-11 16:40:28 +02:00
2023-07-21 12:07:51 +00:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-07-19 11:47:56 +00:00
2023-07-19 11:47:56 +00:00
2023-07-15 15:50:47 +01:00
2023-07-10 12:32:15 +00:00
2023-06-30 06:32:50 +00:00
2023-07-11 16:40:28 +02:00
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-03 21:48:44 +02:00
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-19 17:28:07 +02:00
2023-07-19 17:28:07 +02:00
2023-07-24 07:04:40 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-07-19 17:28:07 +02:00
2023-07-13 08:57:29 +02:00
2023-07-11 06:08:08 +00:00
2023-06-30 06:32:50 +00:00
2023-07-04 07:07:20 +00:00
2023-07-14 09:01:33 +02:00
2023-07-14 09:01:33 +02:00
2023-07-13 09:27:25 +00:00
2023-06-30 06:32:50 +00:00
2023-07-14 09:01:33 +02:00
2023-07-21 12:07:51 +00:00
2023-07-14 09:01:33 +02:00
2023-06-30 06:32:50 +00:00
2023-07-03 21:48:44 +02:00
2023-07-13 08:57:29 +02:00
2023-07-21 12:07:51 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-07-11 16:51:24 +02:00
2023-06-30 06:32:50 +00:00
2023-07-26 16:21:23 +00:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-07-04 07:07:20 +00:00
2023-07-21 12:07:51 +00:00
2023-07-26 16:21:23 +00:00
2023-07-04 07:07:20 +00:00
2023-07-19 17:28:07 +02:00
2023-07-19 11:47:56 +00:00
2023-07-21 12:07:51 +00:00
2023-07-10 21:23:49 +02:00
2023-07-19 11:47:56 +00:00
2023-07-13 09:27:25 +00:00
2023-07-15 17:35:23 +01:00
2023-07-11 16:40:28 +02:00
2023-07-13 09:27:25 +00:00
2023-07-14 09:01:33 +02:00
2023-07-11 14:07:39 +02:00
2023-07-14 09:01:33 +02:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 10:13:23 +02:00
2023-07-11 16:40:28 +02:00
2023-07-25 11:49:05 +02:00
2023-07-24 18:30:42 +02:00
2023-07-20 10:07:22 +00:00
2023-06-27 09:29:40 +00:00
2023-07-11 16:51:24 +02:00
2023-07-14 17:54:58 +02:00
2023-07-20 10:07:22 +00:00
2023-07-23 14:32:16 +02:00
2023-07-19 13:01:58 +02:00
2023-07-10 15:55:19 +02:00
2023-07-21 15:48:45 +02:00
2023-07-24 14:44:36 +00:00
2023-07-03 21:48:44 +02:00
2023-07-10 12:32:15 +00:00
2023-07-20 10:07:22 +00:00
2023-07-20 15:05:18 +00:00
2023-07-25 11:49:05 +02:00
2023-07-14 17:54:58 +02:00
2023-07-10 21:23:49 +02:00
2023-07-11 14:07:39 +02:00
2023-07-21 12:07:51 +00:00
2023-07-21 12:07:51 +00:00
2023-07-08 12:33:18 +02:00
2023-07-13 10:51:25 +00:00
2023-07-14 09:01:33 +02:00
2023-07-13 16:00:49 +02:00
2023-07-13 10:51:25 +00:00
2023-06-26 14:15:55 +02:00
2023-07-26 16:21:23 +00:00
2023-07-23 14:32:16 +02:00
2023-07-13 08:57:29 +02:00
2023-07-18 13:40:15 +02:00
2023-07-26 16:21:23 +00:00
2023-07-04 07:07:20 +00:00
2023-07-04 07:07:20 +00:00
2023-07-13 08:57:29 +02:00
2023-07-26 16:21:23 +00:00
2023-07-19 17:28:07 +02:00
2023-07-13 08:57:29 +02:00
2023-07-24 18:12:07 +00:00
2023-06-26 14:15:55 +02:00