luau-src-rs/luau/Ast/include/Luau/Location.h

44 lines
1.3 KiB
C
Raw Normal View History

2022-02-23 07:12:51 -05: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-01-10 05:31:19 -05:00
Position(unsigned int line, unsigned int column);
2022-02-23 07:12:51 -05:00
2023-01-10 05:31:19 -05: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;
2023-01-10 05:31:19 -05:00
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
2022-02-23 07:12:51 -05:00
};
struct Location
{
Position begin, end;
2023-01-10 05:31:19 -05:00
Location();
Location(const Position& begin, const Position& end);
Location(const Position& begin, unsigned int length);
Location(const Location& begin, const Location& end);
2022-02-23 07:12:51 -05:00
2023-01-10 05:31:19 -05:00
bool operator==(const Location& rhs) const;
bool operator!=(const Location& rhs) const;
2022-02-23 07:12:51 -05:00
2023-01-10 05:31:19 -05: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);
2022-02-23 07:12:51 -05:00
};
} // namespace Luau