Debian Codegraph @

LspCpp/include/LibLsp/lsp/symbol.h

raw
1 #pragma once
2 #include "LibLsp/lsp/location_type.h"
3
4 enum class lsSymbolKind : uint8_t
5 {
6 Unknown = 0,
7
8 File = 1,
9 Module = 2,
10 Namespace = 3,
11 Package = 4,
12 Class = 5,
13 Method = 6,
14 Property = 7,
15 Field = 8,
16 Constructor = 9,
17 Enum = 10,
18 Interface = 11,
19 Function = 12,
20 Variable = 13,
21 Constant = 14,
22 String = 15,
23 Number = 16,
24 Boolean = 17,
25 Array = 18,
26 Object = 19,
27 Key = 20,
28 Null = 21,
29 EnumMember = 22,
30 Struct = 23,
31 Event = 24,
32 Operator = 25,
33
34 // For C++, this is interpreted as "template parameter" (including
35 // non-type template parameters).
36 TypeParameter = 26,
37
38 // cquery extensions
39 // See also https://github.com/Microsoft/language-server-protocol/issues/344
40 // for new SymbolKind clang/Index/IndexSymbol.h clang::index::SymbolKind
41 TypeAlias = 252,
42 Parameter = 253,
43 StaticMethod = 254,
44 Macro = 255,
45 };
46 MAKE_REFLECT_TYPE_PROXY(lsSymbolKind);
47
48 typedef lsSymbolKind SymbolKind;
49
50 // A document highlight kind.
51 enum class lsDocumentHighlightKind
52 {
53 // A textual occurrence.
54 Text = 1,
55 // Read-access of a symbol, like reading a variable.
56 Read = 2,
57 // Write-access of a symbol, like writing to a variable.
58 Write = 3
59 };
60 MAKE_REFLECT_TYPE_PROXY(lsDocumentHighlightKind);
61
62 // A document highlight is a range inside a text document which deserves
63 // special attention. Usually a document highlight is visualized by changing
64 // the background color of its range.
65 struct lsDocumentHighlight
66 {
67 // The range this highlight applies to.
68 lsRange range;
69
70 // The highlight kind, default is DocumentHighlightKind.Text.
71 optional<lsDocumentHighlightKind> kind;
72
73 MAKE_SWAP_METHOD(lsDocumentHighlight, range, kind)
74 };
75 MAKE_REFLECT_STRUCT(lsDocumentHighlight, range, kind);
76
77 struct lsSymbolInformation
78 {
79
80 /**
81 * The name of this symbol.
82 */
83 std::string name;
84 /**
85 * The kind of this symbol.
86 */
87 lsSymbolKind kind;
88 /**
89 * Indicates if this symbol is deprecated.
90 */
91 optional<bool> deprecated;
92 /**
93 * The location of this symbol. The location's range is used by a tool
94 * to reveal the location in the editor. If the symbol is selected in the
95 * tool the range's start information is used to position the cursor. So
96 * the range usually spans more then the actual symbol's name and does
97 * normally include things like visibility modifiers.
98 *
99 * The range doesn't have to denote a node range in the sense of a abstract
100 * syntax tree. It can therefore not be used to re-construct a hierarchy of
101 * the symbols.
102 */
103 lsLocation location;
104 /**
105 * The name of the symbol containing this symbol. This information is for
106 * user interface purposes (e.g. to render a qualifier in the user interface
107 * if necessary). It can't be used to re-infer a hierarchy for the document
108 * symbols.
109 */
110 optional<std::string> containerName;
111
112 MAKE_SWAP_METHOD(lsSymbolInformation, name, kind, deprecated, location, containerName);
113 };
114 MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, deprecated, location, containerName);
115
116 struct lsDocumentSymbol
117 {
118 /**
119 * The name of this symbol.
120 */
121
122 std::string name;
123
124 /**
125 * The kind of this symbol.
126 */
127
128 lsSymbolKind kind = lsSymbolKind::Unknown;
129
130 /**
131 * The range enclosing this symbol not including leading/trailing whitespace but everything else
132 * like comments. This information is typically used to determine if the clients cursor is
133 * inside the symbol to reveal in the symbol in the UI.
134 */
135
136 lsRange range;
137
138 /**
139 * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
140 * Must be contained by the `range`.
141 */
142
143 lsRange selectionRange;
144
145 /**
146 * More detail for this symbol, e.g the signature of a function. If not provided the
147 * name is used.
148 */
149 optional<std::string> detail;
150
151 /**
152 * Indicates if this symbol is deprecated.
153 */
154 optional<bool> deprecated;
155
156 /**
157 * Children of this symbol, e.g. properties of a class.
158 */
159 optional<std::vector<lsDocumentSymbol>> children;
160
161 //internal use
162 int flags = 0;
163
164 MAKE_SWAP_METHOD(lsDocumentSymbol, name, kind, range, selectionRange, detail, deprecated, children, flags);
165 };
166 MAKE_REFLECT_STRUCT(lsDocumentSymbol, name, kind, range, selectionRange, detail, deprecated, children, flags);