@@ -67,6 +67,7 @@ const ClientCapabilities = packed struct {
67
67
label_details_support : bool = false ,
68
68
supports_configuration : bool = false ,
69
69
supports_workspace_did_change_configuration_dynamic_registration : bool = false ,
70
+ supports_textDocument_definition_linkSupport : bool = false ,
70
71
};
71
72
72
73
pub const Error = error {
@@ -414,6 +415,9 @@ fn initializeHandler(server: *Server, _: std.mem.Allocator, request: types.Initi
414
415
}
415
416
}
416
417
}
418
+ if (textDocument .definition ) | definition | {
419
+ server .client_capabilities .supports_textDocument_definition_linkSupport = definition .linkSupport orelse false ;
420
+ }
417
421
}
418
422
419
423
if (request .capabilities .workspace ) | workspace | {
@@ -900,8 +904,20 @@ fn gotoHandler(
900
904
var analyser = Analyser .init (server .allocator , & server .document_store , & server .ip );
901
905
defer analyser .deinit ();
902
906
907
+ const response = try goto .goto (& analyser , & server .document_store , arena , handle , source_index , kind , server .offset_encoding ) orelse return null ;
908
+ if (server .client_capabilities .supports_textDocument_definition_linkSupport ) {
909
+ return .{
910
+ .array_of_DefinitionLink = response ,
911
+ };
912
+ }
913
+
914
+ var aol = try arena .alloc (types .Location , response .len );
915
+ for (0.. response .len ) | index | {
916
+ aol [index ].uri = response [index ].targetUri ;
917
+ aol [index ].range = response [index ].targetSelectionRange ;
918
+ }
903
919
return .{
904
- .array_of_DefinitionLink = try goto . goto ( & analyser , & server . document_store , arena , handle , source_index , kind , server . offset_encoding ) orelse return null ,
920
+ .Definition = .{ . array_of_Location = aol } ,
905
921
};
906
922
}
907
923
@@ -912,7 +928,10 @@ fn gotoTypeDefinitionHandler(server: *Server, arena: std.mem.Allocator, request:
912
928
.workDoneToken = request .workDoneToken ,
913
929
.partialResultToken = request .partialResultToken ,
914
930
})) orelse return null ;
915
- return .{ .array_of_DefinitionLink = response .array_of_DefinitionLink };
931
+ return switch (response ) {
932
+ .array_of_DefinitionLink = > | adl | .{ .array_of_DefinitionLink = adl },
933
+ .Definition = > | def | .{ .Definition = def },
934
+ };
916
935
}
917
936
918
937
fn gotoImplementationHandler (server : * Server , arena : std.mem.Allocator , request : types.ImplementationParams ) Error ! ResultType ("textDocument/implementation" ) {
@@ -922,7 +941,10 @@ fn gotoImplementationHandler(server: *Server, arena: std.mem.Allocator, request:
922
941
.workDoneToken = request .workDoneToken ,
923
942
.partialResultToken = request .partialResultToken ,
924
943
})) orelse return null ;
925
- return .{ .array_of_DefinitionLink = response .array_of_DefinitionLink };
944
+ return switch (response ) {
945
+ .array_of_DefinitionLink = > | adl | .{ .array_of_DefinitionLink = adl },
946
+ .Definition = > | def | .{ .Definition = def },
947
+ };
926
948
}
927
949
928
950
fn gotoDeclarationHandler (server : * Server , arena : std.mem.Allocator , request : types.DeclarationParams ) Error ! ResultType ("textDocument/declaration" ) {
@@ -932,7 +954,10 @@ fn gotoDeclarationHandler(server: *Server, arena: std.mem.Allocator, request: ty
932
954
.workDoneToken = request .workDoneToken ,
933
955
.partialResultToken = request .partialResultToken ,
934
956
})) orelse return null ;
935
- return .{ .array_of_DeclarationLink = response .array_of_DefinitionLink };
957
+ return switch (response ) {
958
+ .array_of_DefinitionLink = > | adl | .{ .array_of_DeclarationLink = adl },
959
+ .Definition = > | def | .{ .Declaration = .{ .array_of_Location = def .array_of_Location } },
960
+ };
936
961
}
937
962
938
963
pub fn hoverHandler (server : * Server , arena : std.mem.Allocator , request : types.HoverParams ) Error ! ? types.Hover {
0 commit comments