Debian Codegraph @

LspCpp/include/LibLsp/lsp/lsPosition.h

raw
1 #pragma once
2
3 #include "LibLsp/JsonRpc/serializer.h"
4
5 #include <string>
6 #include <vector>
7
8 //Position in a text document expressed as zero - based line and zero - based character offset.
9 //A position is between two characters like an insert cursor in a editor.Special values like
10 //for example - 1 to denote the end of a line are not supported.
11 struct lsPosition
12 {
13 lsPosition();
14 lsPosition(int line, int character);
15
16 bool operator==(lsPosition const& other) const;
17 bool operator<(lsPosition const& other) const;
18
19 std::string ToString() const;
20
21 /**
22 * Line position in a document (zero-based).
23 */
24 // Note: these are 0-based.
25 unsigned line = 0;
26 /**
27 * Character offset on a line in a document (zero-based). Assuming that
28 * the line is represented as a string, the `character` value represents
29 * the gap between the `character` and `character + 1`.
30 *
31 * If the character value is greater than the line length it defaults back
32 * to the line length.
33 */
34 unsigned character = 0;
35 static lsPosition const kZeroPosition;
36
37 MAKE_SWAP_METHOD(lsPosition, line, character)
38 };
39 MAKE_REFLECT_STRUCT(lsPosition, line, character);