Skip to main content

get_docblock_before_position

Function get_docblock_before_position 

Source
pub fn get_docblock_before_position<'arena>(
    file: &File,
    trivias: &'arena [Trivia<'arena>],
    node_start_offset: u32,
) -> Option<&'arena Trivia<'arena>>
Expand description

Retrieves the docblock comment that appears before a specific position in the source code.

This function scans the trivia associated with the source code and returns the last docblock comment that appears before the specified position, ensuring that it is directly preceding the node without any non-whitespace characters in between.

§Arguments

  • file - The file from which the trivia is derived.
  • trivias - A slice of trivia associated with the source code.
  • node_start_offset - The start offset of the node for which to find the preceding docblock comment.

§Returns

An Option containing a reference to the Trivia representing the docblock comment if found,