Module clippy_utils::source
source · Expand description
Utils for extracting, inspecting or transforming source code
Functions
Expand a span to include a preceding comma
Like
snippet_block
, but add braces if the expr is not an ExprKind::Block
.
Also takes an Option<String>
which can be put inside the braces.Returns a new Span that extends the original Span to the first non-whitespace char of the first
line.
Returns the indentation of the line of a span
Extends the span to the beginning of the spans line, incl. whitespaces.
Returns the position just before rarrow
Reindent a multiline string with possibility of ignoring the first line.
Converts a span to a code snippet if available, otherwise returns the default.
Converts a span (from a block) to a code snippet if available, otherwise use default.
Same as
snippet_block
, but adapts the applicability level by the rules of
snippet_with_applicability
.Gets a snippet of the indentation of the line of a span
Converts a span to a code snippet. Returns
None
if not available.Same as
snippet
, but it adapts the applicability level by following rules:Same as
snippet_with_applicability
, but first walks the span up to the given context. This
will result in the macro call, rather then the expansion, if the span is from a child context.
If the span is not from a child context, it will be used directly instead.Same as
snippet
, but should only be used when it’s clear that the input span is
not a macro argument.Trims the whitespace from the start and the end of the span.
Walks the span up to the target context, thereby returning the macro call site if the span is
inside a macro expansion, or the original span if it is not. Note this will return
None
in the
case of the span being in a macro expansion, but the target context is from expanding a macro
argument.Removes block comments from the given
Vec
of lines.