Debian Codegraph @

LspCpp/include/LibLsp/lsp/textDocument/typeHierarchy.h

raw
1 #pragma once
2
3 #include "LibLsp/JsonRpc/RequestInMessage.h"
4 #include "LibLsp/JsonRpc/lsResponseMessage.h"
5 #include "LibLsp/lsp/lsTextDocumentPositionParams.h"
6 #include "LibLsp/lsp/symbol.h"
7 #include "LibLsp/lsp/lsAny.h"
8 /**
9 * The {@code textDocument/typeHierarchy} request is sent from the client to the
10 * server to retrieve a {@link TypeHierarchyItem type hierarchy item} based on
11 * the {@link TypeHierarchyParams cursor position in the text document}. This
12 * request would also allow to specify if the item should be resolved and
13 * whether sub- or supertypes are to be resolved. If no type hierarchy item can
14 * be found under the given text document position, resolves to {@code null}.
15 *
16 * <p>
17 * <b>Note:</b> the <a href=
18 * "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
19 * language feature</a> is not yet part of the official LSP specification.
20 */
21 enum class TypeHierarchyDirection : uint32_t
22 {
23
24 /**
25 * Flag for retrieving/resolving the subtypes. Value: {@code 0}.
26 */
27 Children = 0,
28
29 /**
30 * Flag to use when retrieving/resolving the supertypes. Value: {@code 1}.
31 */
32 Parents = 1,
33
34 /**
35 * Flag for resolving both the super- and subtypes. Value: {@code 2}.
36 */
37 Both = 2
38 };
39 void Reflect(Reader& reader, TypeHierarchyDirection& value);
40
41 void Reflect(Writer& writer, TypeHierarchyDirection& value);
42
43 struct TypeHierarchyParams : public lsTextDocumentPositionParams
44 {
45 optional<int> resolve;
46 optional<TypeHierarchyDirection> direction;
47
48 MAKE_SWAP_METHOD(TypeHierarchyParams, textDocument, position, resolve, direction)
49 };
50 MAKE_REFLECT_STRUCT(TypeHierarchyParams, textDocument, position, resolve, direction);
51
52 /**
53 * Representation of an item that carries type information (such as class, interface, enumeration, etc) with additional parentage details.
54 */
55
56 struct TypeHierarchyItem
57 {
58 /**
59 * The human readable name of the hierarchy item.
60 */
61
62 std::string name;
63
64 /**
65 * Optional detail for the hierarchy item. It can be, for instance, the signature of a function or method.
66 */
67 optional<std::string> detail;
68
69 /**
70 * The kind of the hierarchy item. For instance, class or interface.
71 */
72
73 SymbolKind kind;
74
75 /**
76 * {@code true} if the hierarchy item is deprecated. Otherwise, {@code false}. It is {@code false} by default.
77 */
78
79 optional<bool> deprecated;
80
81 /**
82 * The URI of the text document where this type hierarchy item belongs to.
83 */
84
85 lsDocumentUri uri;
86
87 /**
88 * The range enclosing this type hierarchy item not including leading/trailing whitespace but everything else
89 * like comments. This information is typically used to determine if the clients cursor is inside the type
90 * hierarchy item to reveal in the symbol in the UI.
91 *
92 * @see TypeHierarchyItem#selectionRange
93 */
94
95 lsRange range;
96
97 /**
98 * The range that should be selected and revealed when this type hierarchy item is being picked, e.g the name of a function.
99 * Must be contained by the the {@link TypeHierarchyItem#getRange range}.
100 *
101 * @see TypeHierarchyItem#range
102 */
103
104 lsRange selectionRange;
105
106 /**
107 * If this type hierarchy item is resolved, it contains the direct parents. Could be empty if the item does not have any
108 * direct parents. If not defined, the parents have not been resolved yet.
109 */
110 optional<std::vector<TypeHierarchyItem>> parents;
111
112 /**
113 * If this type hierarchy item is resolved, it contains the direct children of the current item.
114 * Could be empty if the item does not have any descendants. If not defined, the children have not been resolved.
115 */
116 optional<std::vector<TypeHierarchyItem>> children;
117
118 /**
119 * An optional data field can be used to identify a type hierarchy item in a resolve request.
120 */
121 optional<lsp::Any> data;
122
123 MAKE_SWAP_METHOD(
124 TypeHierarchyItem, name, detail, kind, deprecated, uri, range, selectionRange, parents, children, data
125 )
126 };
127 MAKE_REFLECT_STRUCT(
128 TypeHierarchyItem, name, detail, kind, deprecated, uri, range, selectionRange, parents, children, data
129 );
130
131 DEFINE_REQUEST_RESPONSE_TYPE(td_typeHierarchy, TypeHierarchyParams, TypeHierarchyItem, "textDocument/typeHierarchy");