@@ -130,6 +130,43 @@ def formatting(
130130 ls .show_message (f"Error formatting SQL: { e } " , types .MessageType .Error )
131131 return []
132132
133+ @self .server .feature (types .TEXT_DOCUMENT_DEFINITION )
134+ def goto_definition (
135+ ls : LanguageServer , params : types .DefinitionParams
136+ ) -> t .List [types .LocationLink ]:
137+ """Jump to an object's definition."""
138+ try :
139+ self ._ensure_context_for_document (params .text_document .uri )
140+ document = ls .workspace .get_document (params .text_document .uri )
141+ if self .lsp_context is None :
142+ raise RuntimeError (f"No context found for document: { document .path } " )
143+
144+ references = get_model_definitions_for_a_path (
145+ self .lsp_context , params .text_document .uri
146+ )
147+ if len (references ) == 0 :
148+ return []
149+
150+ return [
151+ types .LocationLink (
152+ target_uri = reference .uri ,
153+ target_selection_range = types .Range (
154+ start = types .Position (line = 0 , character = 0 ),
155+ end = types .Position (line = 0 , character = 0 ),
156+ ),
157+ target_range = types .Range (
158+ start = types .Position (line = 0 , character = 0 ),
159+ end = types .Position (line = 0 , character = 0 ),
160+ ),
161+ origin_selection_range = reference .range ,
162+ )
163+ for reference in references
164+ ]
165+
166+ except Exception as e :
167+ ls .show_message (f"Error formatting SQL: { e } " , types .MessageType .Error )
168+ return []
169+
133170 @self .server .feature (types .TEXT_DOCUMENT_DEFINITION )
134171 def goto_definition (
135172 ls : LanguageServer , params : types .DefinitionParams
0 commit comments