Feat(lsp): Add rename functionality for CTEs in vscode#4718
Merged
Conversation
Contributor
^ Do the two As in |
72b5780 to
b2677d3
Compare
Collaborator
Author
thanks after #4763 now yes they do as they're picked up as references. added tests for it and end to end for rename functionality in general |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds rename support for Common Table Expressions (CTEs) in the SQLMesh LSP server and VSCode extension, including UI interactions, preview, and document highlights.
- Implements
prepare_rename,rename_symbol, andget_document_highlightsinsqlmesh/lsp/rename.pyand wires up LSP handlers insqlmesh/lsp/main.py. - Expands end-to-end Playwright tests in
vscode/extension/tests/rename_cte.spec.tsto cover rename, cancel, and preview flows. - Adds Python LSP unit tests (
tests/lsp/test_rename_cte.pyandtests/lsp/test_document_highlight.py) to verify rename and highlight behavior.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sqlmesh/lsp/rename.py | Implements core CTE rename and highlight logic |
| sqlmesh/lsp/main.py | Registers LSP handlers for prepareRename, rename, and highlight |
| vscode/extension/tests/rename_cte.spec.ts | Adds UI tests for rename, cancel, preview, and references |
| tests/lsp/test_rename_cte.py | Unit tests for prepareRename and renameSymbol flows |
| tests/lsp/test_document_highlight.py | Unit tests for document highlight on CTE symbols |
Comments suppressed due to low confidence (2)
sqlmesh/lsp/rename.py:49
- Hardcoding the placeholder to 'cte_name' may confuse users; consider using the actual CTE identifier (e.g., extract the text under the target_range) so the rename UI shows the current name.
return PrepareRenameResult_Type1(range=target_range, placeholder="cte_name")
vscode/extension/tests/rename_cte.spec.ts:61
- [nitpick] This test only verifies the definition rename; you may want to also assert that usage occurrences (e.g. in the FROM clause) were updated to 'new_marketing' for full coverage.
await expect(window.locator('text=WITH new_marketing AS')).toBeVisible()
benfdking
reviewed
Jun 23, 2025
b2677d3 to
813aa61
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This update adds CTE renaming (F2) to the SQLMesh LSP server, letting users rename CTEs and their references with proper scope handling. Still to do: