[go: up one dir, main page]

Skip to main content

Comments

Struct Comments 

Source
pub struct Comments { /* private fields */ }
Expand description

Structure for holding all comments found in the document

Implementations§

Source§

impl Comments

Source

pub fn new(comments: Vec<Comment>) -> Self

Method for generating a new Comments struct, which sorts comments based on their starting span location

§Parameters
  • comments: mutable Vec<Comment> that will be sorted by span start
Source

pub fn parse_all_comments_from_file(file: &ParsedSqlFile) -> CommentResult<Self>

Build all leading comments from a parsed SQL file

§Parameters
§Errors
Source

pub fn scan_comments(src: &str) -> CommentResult<Self>

Scans the raw file and collects all comments

§Parameters
  • src which is the SQL file content as a str
§Errors
  • UnmatchedMultilineCommentStart : will return error if unable to find a starting /* for a multiline comment
  • UnterminatedMultiLineComment : will return error if there is an unterminated multiline comment, found at EOF
Source

pub fn comments(&self) -> &[Comment]

Getter method for retrieving the Vec of Comment

Source

pub fn leading_comment(&self, line: u64) -> Option<&Comment>

Finds a single comment before a specific line or returns none

§Parameters
  • Comments object
  • An u64 value representing the desired line to check above.
Source

pub fn leading_comments( &self, line: u64, capture: LeadingCommentCapture, ) -> Self

Finds leading comments before specific line based on LeadingCommentCapture preference

§Parameters
Source

pub fn collapse_comments(self, flatten: MultiFlatten<'_>) -> Option<Comment>

Collapse this collection of comments and separate each comment with \n as a single Comment.

Trait Implementations§

Source§

impl Debug for Comments

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Comments

Source§

fn eq(&self, other: &Comments) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Comments

Source§

impl StructuralPartialEq for Comments

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.