forked from qt-creator/qt-creator
LSP: add compare operator for Position
... and a contains function for Range Change-Id: Ieab05495deb0160fb651d6ae0642ffd625d7e115 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -88,6 +88,12 @@ public:
|
||||
int toPositionInDocument(QTextDocument *doc) const;
|
||||
};
|
||||
|
||||
static bool operator<=(const Position &first, const Position &second)
|
||||
{
|
||||
return first.line() < second.line()
|
||||
|| (first.line() == second.line() && first.character() <= second.character());
|
||||
}
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT Range : public JsonObject
|
||||
{
|
||||
public:
|
||||
@@ -103,6 +109,8 @@ public:
|
||||
Position end() const { return typedValue<Position>(endKey); }
|
||||
void setEnd(const Position &end) { insert(endKey, end); }
|
||||
|
||||
bool contains(const Position &pos) const { return start() <= pos && pos <= end(); }
|
||||
|
||||
bool isValid(QStringList *error) const override
|
||||
{ return check<Position>(error, startKey) && check<Position>(error, endKey); }
|
||||
};
|
||||
|
Reference in New Issue
Block a user