Returns a TextRange for node excluding any leading/trailing
normal comments and whitespace. Doc comments (///, //!,
/**, /*! etc.) remain inside. Normal // or /* ... */ is trimmed.
“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.
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 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.
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.).
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().