Skip to content

Commit 2ece96f

Browse files
committed
Work on Comment parsing logic began + support for comment errors
1 parent c5ccbb9 commit 2ece96f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/comments.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ impl fmt::Display for CommentError {
151151

152152
impl std::error::Error for CommentError {}
153153

154+
/// Alias for comment results that may return a [`CommentError`]
155+
pub type CommentResult<T> = Result<T, CommentError>;
156+
154157
/// Structure that holds the comment along with its location in the file
155158
pub struct CommentWithSpan {
156159
comment: Comment,
@@ -211,12 +214,12 @@ impl Comments {
211214

212215
/// Build all leading comments from a parsed SQL file
213216
#[must_use]
214-
pub fn parse_all_comments_from_file(file: &ParsedSqlFile) -> Self {
217+
pub fn parse_all_comments_from_file(file: &ParsedSqlFile) -> CommentResult<Self> {
215218
let src = file.content();
216219
let mut comments = Vec::new();
217220
let mut current_location = Location::default();
218221

219-
Self { comments }
222+
Ok(Self { comments })
220223
}
221224

222225
/// Scans the raw file and collects all comments

0 commit comments

Comments
 (0)