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

Function leading_commas

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

Source from the content-addressed store, hash-verified

165 "J-Expr does not support leading commas in arrays. Use `[item1, item2]` format.";
166
167pub(crate) fn leading_commas(spans: &[SpanId]) -> ArrayDiagnostic {
168 let (&first, rest) = spans.split_first().expect("spans must be non-empty");
169
170 let mut diagnostic = Diagnostic::new(ArrayDiagnosticCategory::LeadingComma, Critical::ERROR)
171 .primary(Label::new(first, "Remove this leading comma"));
172
173 for &span in rest {
174 diagnostic
175 .labels
176 .push(Label::new(span, "... and this leading comma"));
177 }
178
179 diagnostic.add_message(Message::help(LEADING_COMMA_HELP));
180
181 diagnostic
182}
183
184const CONSECUTIVE_COMMA_HELP: &str =
185 "J-Expr requires exactly one comma between array elements. Use `[item1, item2, item3]` 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