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

Method add_error

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

Source from the content-addressed store, hash-verified

632 }
633
634 fn add_error<T>(&mut self, error: ParseErrorType, ranged: T)
635 where
636 T: Ranged,
637 {
638 fn inner(errors: &mut Vec<ParseError>, error: ParseErrorType, range: TextRange) {
639 // Avoid flagging multiple errors at the same location
640 let is_same_location = errors
641 .last()
642 .is_some_and(|last| last.location.start() == range.start());
643
644 if !is_same_location {
645 errors.push(ParseError {
646 error,
647 location: range,
648 });
649 }
650 }
651
652 inner(&mut self.errors, error, ranged.range());
653 }
654
655 /// Add an [`UnsupportedSyntaxError`] with the given [`UnsupportedSyntaxErrorKind`] and
656 /// [`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