MCPcopy Create free account
hub / github.com/hashintel/hash / trailing_commas

Function trailing_commas

libs/@local/hashql/syntax-jexpr/src/parser/array/error.rs:147–162  ·  view source on GitHub ↗
(spans: &[SpanId])

Source from the content-addressed store, hash-verified

145 `[item1, item2]` instead of `[item1, item2,]`";
146
147pub(crate) fn trailing_commas(spans: &[SpanId]) -> ArrayDiagnostic {
148 let (&first, rest) = spans.split_first().expect("spans must be non-empty");
149
150 let mut diagnostic = Diagnostic::new(ArrayDiagnosticCategory::TrailingComma, Critical::ERROR)
151 .primary(Label::new(first, "Remove this trailing comma"));
152
153 for &span in rest {
154 diagnostic
155 .labels
156 .push(Label::new(span, "... and this trailing comma"));
157 }
158
159 diagnostic.add_message(Message::help(TRAILING_COMMA_HELP));
160
161 diagnostic
162}
163
164const LEADING_COMMA_HELP: &str =
165 "J-Expr does not support leading commas in arrays. Use `[item1, item2]` format.";

Callers 1

visit_arrayFunction · 0.70

Calls 4

primaryMethod · 0.80
add_messageMethod · 0.80
pushMethod · 0.65
expectMethod · 0.45

Tested by

no test coverage detected