Skip to content

feat: external model takes you to the model not just file#4711

Merged
benfdking merged 1 commit intomainfrom
external_model_take_to_location
Jun 11, 2025
Merged

feat: external model takes you to the model not just file#4711
benfdking merged 1 commit intomainfrom
external_model_take_to_location

Conversation

@benfdking
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for navigating to external model definitions in YAML files by introducing a new reference type and extracting the exact block range.

  • Introduce LSPExternalModelReference and extend the reference schema and union
  • Implement _get_yaml_model_range to locate model blocks within external YAML files
  • Update goto_definition to handle external model target_range and add a new test

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/lsp/test_reference_external_model.py Adds a test for external model reference navigation
sqlmesh/lsp/reference.py Defines LSPExternalModelReference, extends the reference union, and adds YAML range extraction logic
sqlmesh/lsp/main.py Updates goto_definition to correctly handle external model target_range
sqlmesh/lsp/helpers.py Adds to_sqlmesh_range helper for converting LSP ranges to SQLMesh ranges
Comments suppressed due to low confidence (3)

sqlmesh/lsp/reference.py:743

  • The docstring refers to yaml_path but the function parameter is named path. Update the doc to match the parameter name for consistency.
yaml_path: Path to the YAML file

tests/lsp/test_reference_external_model.py:33

  • This test only covers the successful path where target_range is present. Add tests for the fallback path when target_range is None and for invalid YAML structures to ensure robust coverage.
if reference.target_range is None:

sqlmesh/lsp/helpers.py:9

  • There are no unit tests for to_sqlmesh_range. Add tests to verify correct conversion between LSP Range and SQLMeshRange.
def to_sqlmesh_range(

Comment thread sqlmesh/lsp/main.py
Comment thread sqlmesh/lsp/reference.py
Comment thread sqlmesh/lsp/helpers.py Outdated
@benfdking benfdking force-pushed the external_model_take_to_location branch from 6dbc589 to 1b5a003 Compare June 11, 2025 09:19
@benfdking benfdking enabled auto-merge (squash) June 11, 2025 09:22
@benfdking benfdking merged commit 8ff6aa2 into main Jun 11, 2025
25 checks passed
@benfdking benfdking deleted the external_model_take_to_location branch June 11, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants