Crate workspacer_consolidate

Source

Structs§

ConsolidatedCrateInterface
ConsolidationOptions
A collection of user-defined toggles controlling how items are gathered and displayed.
CrateInterfaceItem
A single top-level item (fn, struct, etc.), with docs, attributes, and an optional body.
CrateInterfaceItemBuilder
Builder for CrateInterfaceItem.
ImplBlockInterface
InterstitialSegment
InterstitialSegmentBuilder
Builder for InterstitialSegment.
ModuleInterface

Enums§

ConsolidatedItem
An enum representing any consolidated item that can live in a module. You could also store them separately if you like, but an enum is convenient.
CrateInterfaceItemBuilderError
Error type for CrateInterfaceItemBuilder
IndentPolicy
A simple enum to choose how we handle final indentation.
InterstitialSegmentBuilderError
Error type for InterstitialSegmentBuilder

Traits§

ConsolidateCrateInterface

Functions§

clamp_indent_at_4
“Clamp” logic that:
compute_effective_range
Returns a TextRange for node excluding any leading/trailing normal comments and whitespace. Doc comments (///, //!, /**, /*! etc.) remain inside. Normal // or /* ... */ is trimmed.
conditional_dedent_all
“Dedent” lines by the minimal leading‐space among all lines that have indent>0, ignoring blank or brace‐only lines or lines that already have 0. If none found, does nothing.
full_format_flow
Strip out { ... } if the entire snippet is enclosed in them.Split into lines (the caller typically does lines()).Normalize blank lines (trim leading/trailing, collapse consecutive).Dedent or clamp depending on your policy:either conditional_dedent_all if you want a minimal-based dedentor clamp_indent_at_4 if you want to ensure no line exceeds 4 spaces. (Or optionally do both. Up to you.)
gather_all_attrs
Gather all the raw attributes from a node (e.g. #[derive(Debug)], #[cfg(feature="xyz")], possibly multiline like #[my_attr(\n Something\n)]), returning them as separate lines— one per distinct Attr node. If you want to force each #[...] node into a single line (removing internal newlines), you can strip out \n and \r. That way “multiline” attributes become one joined line. This matches some test scenarios that expect one line per attribute.
gather_assoc_type_aliases
Gathers all associated type aliases in an impl block, respecting skip logic and collecting docs/attrs.
gather_crate_items
gather_fn_item
gather_impl_methods
Gathers all fn items from within an impl block, excluding any that should_skip_item_fn determines should be skipped (e.g., private methods, test methods if not .include_test_items(), or with #[some_other_attr], etc.).
gather_interstitial_segments
gather_items_in_node
Gathers Rust items (fn, struct, enum, mod, trait, etc.) from parent_node. In older RA versions, top-level items appear in a SourceFile or ItemList. We’ll check those first; if that fails, we fallback to iterating .children().
gather_module
Gathers an inline mod foo { ... } node into a ModuleInterface, recursing to collect items.
generate_impl_signature
guess_is_function
A small helper to decide if a CrateInterfaceItem<T> should be rendered as a function.
has_cfg_test_attr
is_in_test_module
Returns true if any ancestor is a mod that has #[cfg(test)].
is_in_trait_impl_block
Returns true if node is anywhere inside impl SomeTrait for SomeType { ... }.
leading_spaces
Count how many leading spaces in line.
maybe_build_enum
maybe_build_function
maybe_build_impl_block
maybe_build_macro_call
maybe_build_macro_rules
maybe_build_module
maybe_build_struct
maybe_build_trait
maybe_build_type_alias
merge_doc_attrs
merge_in_place
A local helper to merge one crate interface into another in-place.
normalize_blank_lines
Collapses or removes blank lines:
should_skip_impl
should_skip_item
snippet_for_logging
Simple helper to return a short snippet from a node’s text for logging
strip_outer_braces
Removes outer braces { ... } from a block snippet, if present.
trim_to_60
try_cast_and_build_item
The top-level aggregator that tries each “maybe_build_*” helper in sequence.