Merged
Conversation
8269bb2 to
66d01ca
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the instantiation of the LSPContext by extracting repeated try/except logic into a single helper method _create_lsp_context, reducing duplication across initialization, save handling, and context discovery.
- Introduces
_create_lsp_contextto centralize context creation and error logging - Replaces inline
context_classcalls ininitialize,did_save,_ensure_context_in_folder, and_ensure_context_for_documentwith the new helper - Simplifies error handling by logging failures at trace level and returning
Noneon errors
Comments suppressed due to low confidence (1)
sqlmesh/lsp/main.py:88
- Add unit tests for
_create_lsp_contextto cover both successful instantiation and exception handling paths, ensuring that errors are logged andNoneis returned as expected.
def _create_lsp_context(self, paths: t.List[Path]) -> t.Optional[LSPContext]:
| try: | ||
| created_context = self.context_class(paths=[folder_uri]) | ||
| self.lsp_context = LSPContext(created_context) | ||
| lsp_context = self._create_lsp_context([folder_uri]) |
There was a problem hiding this comment.
User-facing error messages were removed when context creation fails in ensure_context_in_folder. Failures now only log at trace level, so users may not know why loading didn't occur. Consider restoring server.show_message calls or adding a warning to inform users of load failures.
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.
No description provided.