@@ -211,6 +211,61 @@ SymbolKind adjustKindToCapability(SymbolKind Kind,
211
211
}
212
212
}
213
213
214
+ SymbolKind indexSymbolKindToSymbolKind (index::SymbolKind Kind) {
215
+ switch (Kind) {
216
+ case index ::SymbolKind::Unknown:
217
+ return SymbolKind::Variable;
218
+ case index ::SymbolKind::Module:
219
+ return SymbolKind::Module;
220
+ case index ::SymbolKind::Namespace:
221
+ return SymbolKind::Namespace;
222
+ case index ::SymbolKind::NamespaceAlias:
223
+ return SymbolKind::Namespace;
224
+ case index ::SymbolKind::Macro:
225
+ return SymbolKind::String;
226
+ case index ::SymbolKind::Enum:
227
+ return SymbolKind::Enum;
228
+ case index ::SymbolKind::Struct:
229
+ return SymbolKind::Struct;
230
+ case index ::SymbolKind::Class:
231
+ return SymbolKind::Class;
232
+ case index ::SymbolKind::Protocol:
233
+ return SymbolKind::Interface;
234
+ case index ::SymbolKind::Extension:
235
+ return SymbolKind::Interface;
236
+ case index ::SymbolKind::Union:
237
+ return SymbolKind::Class;
238
+ case index ::SymbolKind::TypeAlias:
239
+ return SymbolKind::Class;
240
+ case index ::SymbolKind::Function:
241
+ return SymbolKind::Function;
242
+ case index ::SymbolKind::Variable:
243
+ return SymbolKind::Variable;
244
+ case index ::SymbolKind::Field:
245
+ return SymbolKind::Field;
246
+ case index ::SymbolKind::EnumConstant:
247
+ return SymbolKind::EnumMember;
248
+ case index ::SymbolKind::InstanceMethod:
249
+ case index ::SymbolKind::ClassMethod:
250
+ case index ::SymbolKind::StaticMethod:
251
+ return SymbolKind::Method;
252
+ case index ::SymbolKind::InstanceProperty:
253
+ case index ::SymbolKind::ClassProperty:
254
+ case index ::SymbolKind::StaticProperty:
255
+ return SymbolKind::Property;
256
+ case index ::SymbolKind::Constructor:
257
+ case index ::SymbolKind::Destructor:
258
+ return SymbolKind::Method;
259
+ case index ::SymbolKind::ConversionFunction:
260
+ return SymbolKind::Function;
261
+ case index ::SymbolKind::Parameter:
262
+ return SymbolKind::Variable;
263
+ case index ::SymbolKind::Using:
264
+ return SymbolKind::Namespace;
265
+ }
266
+ llvm_unreachable (" invalid symbol kind" );
267
+ }
268
+
214
269
bool fromJSON (const llvm::json::Value &Params, ClientCapabilities &R) {
215
270
const llvm::json::Object *O = Params.getAsObject ();
216
271
if (!O)
@@ -812,6 +867,66 @@ bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts) {
812
867
return true ;
813
868
}
814
869
870
+ bool fromJSON (const llvm::json::Value &E, TypeHierarchyDirection &Out) {
871
+ auto T = E.getAsInteger ();
872
+ if (!T)
873
+ return false ;
874
+ if (*T < static_cast <int >(TypeHierarchyDirection::Children) ||
875
+ *T > static_cast <int >(TypeHierarchyDirection::Both))
876
+ return false ;
877
+ Out = static_cast <TypeHierarchyDirection>(*T);
878
+ return true ;
879
+ }
880
+
881
+ bool fromJSON (const llvm::json::Value &Params, TypeHierarchyParams &R) {
882
+ llvm::json::ObjectMapper O (Params);
883
+ return O && O.map (" textDocument" , R.textDocument ) &&
884
+ O.map (" position" , R.position ) && O.map (" resolve" , R.resolve ) &&
885
+ O.map (" direction" , R.direction );
886
+ }
887
+
888
+ llvm::raw_ostream &operator <<(llvm::raw_ostream &O,
889
+ const TypeHierarchyItem &I) {
890
+ return O << I.name << " - " << toJSON (I);
891
+ }
892
+
893
+ llvm::json::Value toJSON (const TypeHierarchyItem &I) {
894
+ llvm::json::Object Result{{" name" , I.name },
895
+ {" kind" , static_cast <int >(I.kind )},
896
+ {" range" , I.range },
897
+ {" selectionRange" , I.selectionRange },
898
+ {" uri" , I.uri }};
899
+
900
+ if (I.detail )
901
+ Result[" detail" ] = I.detail ;
902
+ if (I.deprecated )
903
+ Result[" deprecated" ] = I.deprecated ;
904
+ if (I.parents )
905
+ Result[" parents" ] = I.parents ;
906
+ if (I.children )
907
+ Result[" children" ] = I.children ;
908
+ return std::move (Result);
909
+ }
910
+
911
+ bool fromJSON (const llvm::json::Value &Params, TypeHierarchyItem &I) {
912
+ llvm::json::ObjectMapper O (Params);
913
+
914
+ // Required fields.
915
+ if (!(O && O.map (" name" , I.name ) && O.map (" kind" , I.kind ) &&
916
+ O.map (" uri" , I.uri ) && O.map (" range" , I.range ) &&
917
+ O.map (" selectionRange" , I.selectionRange ))) {
918
+ return false ;
919
+ }
920
+
921
+ // Optional fields.
922
+ O.map (" detail" , I.detail );
923
+ O.map (" deprecated" , I.deprecated );
924
+ O.map (" parents" , I.parents );
925
+ O.map (" children" , I.children );
926
+
927
+ return true ;
928
+ }
929
+
815
930
bool fromJSON (const llvm::json::Value &Params, ReferenceParams &R) {
816
931
TextDocumentPositionParams &Base = R;
817
932
return fromJSON (Params, Base);
0 commit comments