MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / handle_comment

Method handle_comment

src/parse_to_ast.rs:211–225  ·  view source on GitHub ↗
(&mut self, comment: Comment<'a>)

Source from the content-addressed store, hash-verified

209 }
210
211 fn handle_comment(&mut self, comment: Comment<'a>) -> Result<(), ParseError> {
212 if !self.allow_comments {
213 return Err(self.create_error(ParseErrorKind::CommentsNotAllowed));
214 }
215
216 if self.comments.is_some() {
217 if let Some(comments) = self.current_comments.as_mut() {
218 comments.push(comment);
219 } else {
220 self.current_comments = Some(vec![comment]);
221 }
222 }
223
224 Ok(())
225 }
226}
227
228/// Parses a string containing JSONC to an AST with comments and tokens.

Callers 1

Calls 1

create_errorMethod · 0.80

Tested by

no test coverage detected