mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-25 16:01:30 +02:00
implement check for missing filters in pipeline
This commit is contained in:
parent
344afa22b5
commit
1b6d2a9b62
3 changed files with 53 additions and 2 deletions
|
@ -14,6 +14,12 @@ pub fn check(
|
|||
errs.push(SyntaxError::MissingStreamer(vec![(file_id, e_span)]));
|
||||
}
|
||||
|
||||
if let Err(mut err_locs) = check_missing_filters(&syntax) {
|
||||
errs.push(SyntaxError::MissingFilter(
|
||||
err_locs.into_iter().map(|loc| (file_id, loc)).collect(),
|
||||
))
|
||||
}
|
||||
|
||||
if errs.is_empty() {
|
||||
Ok(syntax)
|
||||
} else {
|
||||
|
@ -32,3 +38,29 @@ fn check_missing_streamer(syntax: &Vec<PipelineElement>) -> Result<(), logos::Sp
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn check_missing_filters(syntax: &Vec<PipelineElement>) -> Result<(), Vec<logos::Span>> {
|
||||
let mut missing_filter_locs = Vec::new();
|
||||
|
||||
for i in 0..syntax.len() {
|
||||
if let (
|
||||
Some(PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
ref span,
|
||||
}),
|
||||
Some(PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
span: ref span1,
|
||||
}),
|
||||
) = (syntax.get(i), syntax.get(i + 1))
|
||||
{
|
||||
missing_filter_locs.push(span.start..span1.end)
|
||||
}
|
||||
}
|
||||
|
||||
if missing_filter_locs.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(missing_filter_locs)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue