2021-10-30 04:25:12 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Position
|
|
|
|
{
|
|
|
|
unsigned int line, column;
|
|
|
|
|
2023-11-04 07:45:04 +08:00
|
|
|
Position(unsigned int line, unsigned int column)
|
|
|
|
: line(line)
|
|
|
|
, column(column)
|
|
|
|
{
|
|
|
|
}
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-12-10 03:57:01 +08:00
|
|
|
bool operator==(const Position& rhs) const;
|
|
|
|
bool operator!=(const Position& rhs) const;
|
|
|
|
bool operator<(const Position& rhs) const;
|
|
|
|
bool operator>(const Position& rhs) const;
|
|
|
|
bool operator<=(const Position& rhs) const;
|
|
|
|
bool operator>=(const Position& rhs) const;
|
2022-12-03 02:09:59 +08:00
|
|
|
|
2022-12-10 03:57:01 +08:00
|
|
|
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
|
2021-10-30 04:25:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Location
|
|
|
|
{
|
|
|
|
Position begin, end;
|
|
|
|
|
2023-11-04 07:45:04 +08:00
|
|
|
Location()
|
|
|
|
: begin(0, 0)
|
|
|
|
, end(0, 0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Location(const Position& begin, const Position& end)
|
|
|
|
: begin(begin)
|
|
|
|
, end(end)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Location(const Position& begin, unsigned int length)
|
|
|
|
: begin(begin)
|
|
|
|
, end(begin.line, begin.column + length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Location(const Location& begin, const Location& end)
|
|
|
|
: begin(begin.begin)
|
|
|
|
, end(end.end)
|
|
|
|
{
|
|
|
|
}
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-12-10 03:57:01 +08:00
|
|
|
bool operator==(const Location& rhs) const;
|
|
|
|
bool operator!=(const Location& rhs) const;
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-12-10 03:57:01 +08:00
|
|
|
bool encloses(const Location& l) const;
|
|
|
|
bool overlaps(const Location& l) const;
|
|
|
|
bool contains(const Position& p) const;
|
|
|
|
bool containsClosed(const Position& p) const;
|
|
|
|
void extend(const Location& other);
|
|
|
|
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
|
2021-10-30 04:25:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Luau
|