Skip to content

Commit 3fcf764

Browse files
committed
partial merge of work
1 parent 28840b4 commit 3fcf764

File tree

21 files changed

+861
-575
lines changed

21 files changed

+861
-575
lines changed

crates/qmd-syntax-helper/src/conversions/div_whitespace.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ impl DivWhitespaceConverter {
4444
false, // not loose mode
4545
&filename,
4646
&mut sink,
47-
Some(
48-
quarto_markdown_pandoc::readers::qmd_error_messages::produce_json_error_messages
49-
as fn(
50-
&[u8],
51-
&quarto_markdown_pandoc::utils::tree_sitter_log_observer::TreeSitterLogObserver,
52-
&str,
53-
) -> Vec<String>,
54-
),
5547
);
5648

5749
match result {

crates/qmd-syntax-helper/src/diagnostics/parse_check.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ impl ParseChecker {
2424
false,
2525
&filename,
2626
&mut sink,
27-
Some(
28-
quarto_markdown_pandoc::readers::qmd_error_messages::produce_json_error_messages
29-
as fn(
30-
&[u8],
31-
&quarto_markdown_pandoc::utils::tree_sitter_log_observer::TreeSitterLogObserver,
32-
&str,
33-
) -> Vec<String>,
34-
),
3527
);
3628

3729
Ok(result.is_ok())

crates/quarto-error-reporting/src/builder.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,35 @@ impl DiagnosticMessageBuilder {
256256
self.details.push(DetailItem {
257257
kind: DetailKind::Error,
258258
content: detail.into(),
259+
location: None,
260+
});
261+
self
262+
}
263+
264+
/// Add an error detail with a source location.
265+
///
266+
/// This allows adding contextual information that points to specific locations
267+
/// in the source code, creating rich multi-location error messages.
268+
///
269+
/// # Example
270+
///
271+
/// ```ignore
272+
/// use quarto_error_reporting::DiagnosticMessageBuilder;
273+
///
274+
/// let error = DiagnosticMessageBuilder::error("Mismatched brackets")
275+
/// .add_detail_at("Opening bracket here", opening_location)
276+
/// .add_detail_at("But no closing bracket found", end_location)
277+
/// .build();
278+
/// ```
279+
pub fn add_detail_at(
280+
mut self,
281+
detail: impl Into<MessageContent>,
282+
location: quarto_source_map::SourceInfo,
283+
) -> Self {
284+
self.details.push(DetailItem {
285+
kind: DetailKind::Error,
286+
content: detail.into(),
287+
location: Some(location),
259288
});
260289
self
261290
}
@@ -278,6 +307,21 @@ impl DiagnosticMessageBuilder {
278307
self.details.push(DetailItem {
279308
kind: DetailKind::Info,
280309
content: info.into(),
310+
location: None,
311+
});
312+
self
313+
}
314+
315+
/// Add an info detail with a source location.
316+
pub fn add_info_at(
317+
mut self,
318+
info: impl Into<MessageContent>,
319+
location: quarto_source_map::SourceInfo,
320+
) -> Self {
321+
self.details.push(DetailItem {
322+
kind: DetailKind::Info,
323+
content: info.into(),
324+
location: Some(location),
281325
});
282326
self
283327
}
@@ -297,6 +341,21 @@ impl DiagnosticMessageBuilder {
297341
self.details.push(DetailItem {
298342
kind: DetailKind::Note,
299343
content: note.into(),
344+
location: None,
345+
});
346+
self
347+
}
348+
349+
/// Add a note detail with a source location.
350+
pub fn add_note_at(
351+
mut self,
352+
note: impl Into<MessageContent>,
353+
location: quarto_source_map::SourceInfo,
354+
) -> Self {
355+
self.details.push(DetailItem {
356+
kind: DetailKind::Note,
357+
content: note.into(),
358+
location: Some(location),
300359
});
301360
self
302361
}

0 commit comments

Comments
 (0)