File indexing completed on 2024-05-12 04:38:05

0001 /*
0002     SPDX-FileCopyrightText: 2010 David Nolden <david.nolden.kdevelop@art-master.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef KDEVPLATFORM_DOCUMENTCURSOR_H
0008 #define KDEVPLATFORM_DOCUMENTCURSOR_H
0009 
0010 #include <language/languageexport.h>
0011 #include <serialization/indexedstring.h>
0012 
0013 #include <KTextEditor/Cursor>
0014 
0015 namespace KDevelop {
0016 /**
0017  * Lightweight object that extends a cursor with information about the document URL to which the range
0018  * refers.
0019  */
0020 class DocumentCursor
0021     : public KTextEditor::Cursor
0022 {
0023 public:
0024     DocumentCursor()
0025     {
0026     }
0027 
0028     DocumentCursor(const IndexedString& document, const KTextEditor::Cursor& cursor) : KTextEditor::Cursor(cursor)
0029         , document(document)
0030     {
0031     }
0032 
0033     static DocumentCursor invalid()
0034     {
0035         return DocumentCursor({}, KTextEditor::Cursor::invalid());
0036     }
0037 
0038     inline bool operator==(const DocumentCursor& rhs) const
0039     {
0040         return document == rhs.document && *static_cast<const KTextEditor::Cursor*>(this) == rhs;
0041     }
0042 
0043     IndexedString document;
0044 };
0045 }
0046 #endif // KDEVPLATFORM_DOCUMENTCURSOR_H