1212
1313from sqlmesh .lsp .uri import URI
1414from sqlmesh .utils .lineage import (
15- LSPMacroReference ,
16- LSPCteReference ,
15+ MacroReference ,
16+ CTEReference ,
1717 Reference ,
18- LSPModelReference ,
18+ ModelReference ,
1919 extract_references_from_query ,
2020)
2121import ast
@@ -268,7 +268,7 @@ def get_macro_reference(
268268
269269 # Create a reference to the macro definition
270270
271- return LSPMacroReference (
271+ return MacroReference (
272272 path = path ,
273273 range = macro_range ,
274274 target_range = Range (
@@ -301,7 +301,7 @@ def get_built_in_macro_reference(macro_name: str, macro_range: Range) -> t.Optio
301301 # Calculate the end line number by counting the number of source lines
302302 end_line_number = line_number + len (source_lines ) - 1
303303
304- return LSPMacroReference (
304+ return MacroReference (
305305 path = Path (filename ),
306306 range = macro_range ,
307307 target_range = Range (
@@ -314,7 +314,7 @@ def get_built_in_macro_reference(macro_name: str, macro_range: Range) -> t.Optio
314314
315315def get_model_find_all_references (
316316 lint_context : LSPContext , document_uri : URI , position : Position
317- ) -> t .List [LSPModelReference ]:
317+ ) -> t .List [ModelReference ]:
318318 """
319319 Get all references to a model across the entire project.
320320
@@ -332,7 +332,7 @@ def get_model_find_all_references(
332332 # Find the model reference at the cursor position
333333 model_at_position = next (
334334 filter (
335- lambda ref : isinstance (ref , LSPModelReference )
335+ lambda ref : isinstance (ref , ModelReference )
336336 and _position_within_range (position , ref .range ),
337337 get_model_definitions_for_a_path (lint_context , document_uri ),
338338 ),
@@ -342,13 +342,13 @@ def get_model_find_all_references(
342342 if not model_at_position :
343343 return []
344344
345- assert isinstance (model_at_position , LSPModelReference ) # for mypy
345+ assert isinstance (model_at_position , ModelReference ) # for mypy
346346
347347 target_model_path = model_at_position .path
348348
349349 # Start with the model definition
350- all_references : t .List [LSPModelReference ] = [
351- LSPModelReference (
350+ all_references : t .List [ModelReference ] = [
351+ ModelReference (
352352 path = model_at_position .path ,
353353 range = Range (
354354 start = Position (line = 0 , character = 0 ),
@@ -360,15 +360,15 @@ def get_model_find_all_references(
360360
361361 # Then add references from the current file
362362 current_file_refs = filter (
363- lambda ref : isinstance (ref , LSPModelReference ) and ref .path == target_model_path ,
363+ lambda ref : isinstance (ref , ModelReference ) and ref .path == target_model_path ,
364364 get_model_definitions_for_a_path (lint_context , document_uri ),
365365 )
366366
367367 for ref in current_file_refs :
368- assert isinstance (ref , LSPModelReference ) # for mypy
368+ assert isinstance (ref , ModelReference ) # for mypy
369369
370370 all_references .append (
371- LSPModelReference (
371+ ModelReference (
372372 path = document_uri .to_path (),
373373 range = ref .range ,
374374 markdown_description = ref .markdown_description ,
@@ -385,15 +385,15 @@ def get_model_find_all_references(
385385
386386 # Get model references that point to the target model
387387 matching_refs = filter (
388- lambda ref : isinstance (ref , LSPModelReference ) and ref .path == target_model_path ,
388+ lambda ref : isinstance (ref , ModelReference ) and ref .path == target_model_path ,
389389 get_model_definitions_for_a_path (lint_context , file_uri ),
390390 )
391391
392392 for ref in matching_refs :
393- assert isinstance (ref , LSPModelReference ) # for mypy
393+ assert isinstance (ref , ModelReference ) # for mypy
394394
395395 all_references .append (
396- LSPModelReference (
396+ ModelReference (
397397 path = path ,
398398 range = ref .range ,
399399 markdown_description = ref .markdown_description ,
@@ -405,7 +405,7 @@ def get_model_find_all_references(
405405
406406def get_cte_references (
407407 lint_context : LSPContext , document_uri : URI , position : Position
408- ) -> t .List [LSPCteReference ]:
408+ ) -> t .List [CTEReference ]:
409409 """
410410 Get all references to a CTE at a specific position in a document.
411411
@@ -421,10 +421,10 @@ def get_cte_references(
421421 """
422422
423423 # Filter to get the CTE references
424- cte_references : t .List [LSPCteReference ] = [
424+ cte_references : t .List [CTEReference ] = [
425425 ref
426426 for ref in get_model_definitions_for_a_path (lint_context , document_uri )
427- if isinstance (ref , LSPCteReference )
427+ if isinstance (ref , CTEReference )
428428 ]
429429
430430 if not cte_references :
@@ -446,7 +446,7 @@ def get_cte_references(
446446
447447 # Add the CTE definition
448448 matching_references = [
449- LSPCteReference (
449+ CTEReference (
450450 path = document_uri .to_path (),
451451 range = target_cte_definition_range ,
452452 target_range = target_cte_definition_range ,
@@ -457,7 +457,7 @@ def get_cte_references(
457457 for ref in cte_references :
458458 if ref .target_range == target_cte_definition_range :
459459 matching_references .append (
460- LSPCteReference (
460+ CTEReference (
461461 path = document_uri .to_path (),
462462 range = ref .range ,
463463 target_range = ref .target_range ,
@@ -469,7 +469,7 @@ def get_cte_references(
469469
470470def get_macro_find_all_references (
471471 lsp_context : LSPContext , document_uri : URI , position : Position
472- ) -> t .List [LSPMacroReference ]:
472+ ) -> t .List [MacroReference ]:
473473 """
474474 Get all references to a macro at a specific position in a document.
475475
@@ -486,7 +486,7 @@ def get_macro_find_all_references(
486486 # Find the macro reference at the cursor position
487487 macro_at_position = next (
488488 filter (
489- lambda ref : isinstance (ref , LSPMacroReference )
489+ lambda ref : isinstance (ref , MacroReference )
490490 and _position_within_range (position , ref .range ),
491491 get_macro_definitions_for_a_path (lsp_context , document_uri ),
492492 ),
@@ -496,14 +496,14 @@ def get_macro_find_all_references(
496496 if not macro_at_position :
497497 return []
498498
499- assert isinstance (macro_at_position , LSPMacroReference ) # for mypy
499+ assert isinstance (macro_at_position , MacroReference ) # for mypy
500500
501501 target_macro_path = macro_at_position .path
502502 target_macro_target_range = macro_at_position .target_range
503503
504504 # Start with the macro definition
505- all_references : t .List [LSPMacroReference ] = [
506- LSPMacroReference (
505+ all_references : t .List [MacroReference ] = [
506+ MacroReference (
507507 path = target_macro_path ,
508508 range = target_macro_target_range ,
509509 target_range = target_macro_target_range ,
@@ -517,16 +517,16 @@ def get_macro_find_all_references(
517517
518518 # Get macro references that point to the same macro definition
519519 matching_refs = filter (
520- lambda ref : isinstance (ref , LSPMacroReference )
520+ lambda ref : isinstance (ref , MacroReference )
521521 and ref .path == target_macro_path
522522 and ref .target_range == target_macro_target_range ,
523523 get_macro_definitions_for_a_path (lsp_context , file_uri ),
524524 )
525525
526526 for ref in matching_refs :
527- assert isinstance (ref , LSPMacroReference ) # for mypy
527+ assert isinstance (ref , MacroReference ) # for mypy
528528 all_references .append (
529- LSPMacroReference (
529+ MacroReference (
530530 path = path ,
531531 range = ref .range ,
532532 target_range = ref .target_range ,
0 commit comments