}
return false;
}
+ void ExtendToCover(const Interval &that) {
+ if (size_ == 0) {
+ *this = that;
+ } else if (that.size_ != 0) {
+ const auto end{std::max(NextAfter(), that.NextAfter())};
+ start_ = std::min(start_, that.start_);
+ size_ = end - start_;
+ }
+ }
std::size_t MemberOffset(const A &x) const {
CHECK(Contains(x));
return interval_.Contains(that.interval_);
}
+ void ExtendToCover(const CharBlock &that) {
+ interval_.ExtendToCover(that.interval_);
+ }
+
bool IsBlank() const {
for (char ch : *this) {
if (ch != ' ' && ch != '\t') {
}
void Scope::AddSourceRange(const parser::CharBlock &source) {
- if (sourceRange_.empty()) {
- sourceRange_ = source;
- } else if (!source.empty()) {
- sourceRange_ =
- parser::CharBlock(std::min(sourceRange_.begin(), source.begin()),
- std::max(sourceRange_.end(), source.end()));
- }
+ sourceRange_.ExtendToCover(source);
}
std::ostream &operator<<(std::ostream &os, const Scope &scope) {