Crate workspacer_format_imports

Source

Structs§

GatherCommentsState
Tracks what we’ve collected and where we are in the scanning process.
UseItemInfo
Private struct => changed to public to avoid E0616
UseItemInfoBuilder
Builder for UseItemInfo.

Enums§

SortAndFormatImportsError
UseItemInfoBuilderError
Error type for UseItemInfoBuilder

Traits§

SortAndFormatImports
Our trait for sorting and formatting imports in a crate or workspace. The goal:

Functions§

build_new_use_lines
Updated build_new_use_lines to accept the trailing_comments map as a third parameter. If your existing tests only pass two arguments, just add &BTreeMap::new() as the third.
collect_comment_token
combine_new_uses_with_remainder
The key fix: remove the trim_start() on the remainder.
We want to preserve leading blank lines in the remainder so that if there was a blank line after some block comment, it stays in the final output.
detect_trailing_comment_same_line
Detects a same-line trailing // comment starting just after offset pos (e.g. after the semicolon). If found, returns (comment_text, total_length) so we can store that comment text and expand the removal range. If none found, returns None.
dispatch_token_by_kind
dissect_use_statement
fallback_scan_node_text
gather_leading_comment_lines
gather_leading_token_comments
gather_sibling_comments_above
gather_token_comments_above
gather_use_items
group_and_sort_uses
Now we always return three items: (grouped_map, comment_map, trailing_comments). If you have code/tests that only care about grouped_map & comment_map, just destructure as: let (grouped_map, comment_map, _trailing) = group_and_sort_uses(…); ignoring the trailing_comments value.
parse_and_validate_syntax
peek_next_non_whitespace
process_other_token
process_upward_node
process_whitespace_token
remove_old_use_statements
scan_preceding_tokens_for_comments
skip_node_plus_trailing_whitespace
Skip exactly one node plus any preceding whitespace tokens, returning the next NodeOrToken above. This is used when:
skip_upward_node_with_whitespace
sort_and_format_imports_in_text
split_path_into_prefix_and_final
try_extract_embedded_comment_in_whitespace