Add Location (#88)

This commit is contained in:
ykiko
2025-02-21 12:51:05 +08:00
committed by GitHub
parent bcb4c3895a
commit 828d20b8c2
2 changed files with 27 additions and 1 deletions

View File

@@ -22,6 +22,24 @@ struct LocalSourceRange {
constexpr bool intersects(const LocalSourceRange& other) const {
return begin <= other.end && end >= other.begin;
}
constexpr bool valid() const {
return begin != -1 && end != -1;
}
};
struct Location {
/// The file path.
std::string file;
/// The range in the file.
LocalSourceRange range;
constexpr bool operator== (const Location& other) const = default;
constexpr bool valid() const {
return !file.empty() && range.valid();
}
};
/// Get the content of the file with the given file ID.