@@ -67,6 +67,7 @@ const ClientCapabilities = packed struct {
6767    label_details_support : bool  =  false ,
6868    supports_configuration : bool  =  false ,
6969    supports_workspace_did_change_configuration_dynamic_registration : bool  =  false ,
70+     supports_textDocument_definition_linkSupport : bool  =  false ,
7071};
7172
7273pub  const  Error  =  error {
@@ -414,6 +415,9 @@ fn initializeHandler(server: *Server, _: std.mem.Allocator, request: types.Initi
414415                }
415416            }
416417        }
418+         if  (textDocument .definition ) | definition |  {
419+             server .client_capabilities .supports_textDocument_definition_linkSupport  =  definition .linkSupport  orelse  false ;
420+         }
417421    }
418422
419423    if  (request .capabilities .workspace ) | workspace |  {
@@ -900,8 +904,20 @@ fn gotoHandler(
900904    var  analyser  =  Analyser .init (server .allocator , & server .document_store , & server .ip );
901905    defer  analyser .deinit ();
902906
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+     }
903919    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  } ,
905921    };
906922}
907923
@@ -912,7 +928,10 @@ fn gotoTypeDefinitionHandler(server: *Server, arena: std.mem.Allocator, request:
912928        .workDoneToken  =  request .workDoneToken ,
913929        .partialResultToken  =  request .partialResultToken ,
914930    })) 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+     };
916935}
917936
918937fn  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:
922941        .workDoneToken  =  request .workDoneToken ,
923942        .partialResultToken  =  request .partialResultToken ,
924943    })) 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+     };
926948}
927949
928950fn  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
932954        .workDoneToken  =  request .workDoneToken ,
933955        .partialResultToken  =  request .partialResultToken ,
934956    })) 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+     };
936961}
937962
938963pub  fn  hoverHandler (server : * Server , arena : std.mem.Allocator , request : types.HoverParams ) Error ! ? types.Hover  {
0 commit comments