pub struct Comments { /* private fields */ }Expand description
Structure for holding all comments found in the document
Implementations§
Source§impl Comments
impl Comments
Sourcepub fn new(comments: Vec<Comment>) -> Self
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: mutableVec<Comment>that will be sorted by span start
Sourcepub fn parse_all_comments_from_file(file: &ParsedSqlFile) -> CommentResult<Self>
pub fn parse_all_comments_from_file(file: &ParsedSqlFile) -> CommentResult<Self>
Build all leading comments from a parsed SQL file
§Parameters
file: theParsedSqlFilethat needs to be parsed for comments
§Errors
- Will return
CommentError::UnmatchedMultilineCommentStartif a comment does not have an opening/* - Will return
CommentError::UnterminatedMultiLineCommentif a multiline comment doesn’t end beforeEOF
Sourcepub fn scan_comments(src: &str) -> CommentResult<Self>
pub fn scan_comments(src: &str) -> CommentResult<Self>
Scans the raw file and collects all comments
§Parameters
srcwhich is theSQLfile content as astr
§Errors
UnmatchedMultilineCommentStart: will return error if unable to find a starting/*for a multiline commentUnterminatedMultiLineComment: will return error if there is an unterminated multiline comment, found at EOF
Sourcepub fn leading_comment(&self, line: u64) -> Option<&Comment>
pub fn leading_comment(&self, line: u64) -> Option<&Comment>
Sourcepub fn leading_comments(
&self,
line: u64,
capture: LeadingCommentCapture,
) -> Self
pub fn leading_comments( &self, line: u64, capture: LeadingCommentCapture, ) -> Self
Finds leading comments before specific line based on LeadingCommentCapture preference
§Parameters
Commentsobject- An
u64value representing the desired line to check above. LeadingCommentCapturepreference
Sourcepub fn collapse_comments(self, flatten: MultiFlatten<'_>) -> Option<Comment>
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§
impl Eq for Comments
impl StructuralPartialEq for Comments
Auto Trait Implementations§
impl Freeze for Comments
impl RefUnwindSafe for Comments
impl Send for Comments
impl Sync for Comments
impl Unpin for Comments
impl UnwindSafe for Comments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more