MCPcopy Create free account
hub / github.com/astral-sh/ruff / add_error

Method add_error

crates/ruff_python_parser/src/parser/mod.rs:668–687  ·  view source on GitHub ↗
(&mut self, error: ParseErrorType, ranged: T)

Source from the content-addressed store, hash-verified

666 }
667
668 fn add_error<T>(&mut self, error: ParseErrorType, ranged: T)
669 where
670 T: Ranged,
671 {
672 fn inner(errors: &mut Vec<ParseError>, error: ParseErrorType, range: TextRange) {
673 // Avoid flagging multiple errors at the same location
674 let is_same_location = errors
675 .last()
676 .is_some_and(|last| last.location.start() == range.start());
677
678 if !is_same_location {
679 errors.push(ParseError {
680 error,
681 location: range,
682 });
683 }
684 }
685
686 inner(&mut self.errors, error, ranged.range());
687 }
688
689 /// Add an [`UnsupportedSyntaxError`] with the given [`UnsupportedSyntaxErrorKind`] and
690 /// [`TextRange`] if its minimum version is less than [`Parser::target_version`].

Calls 2

innerFunction · 0.50
rangeMethod · 0.45

Tested by

no test coverage detected