Skip to content

refactor(lsp): creation of context#4704

Merged
benfdking merged 1 commit intomainfrom
refactor_creation_of_context
Jun 10, 2025
Merged

refactor(lsp): creation of context#4704
benfdking merged 1 commit intomainfrom
refactor_creation_of_context

Conversation

@benfdking
Copy link
Copy Markdown
Contributor

No description provided.

@benfdking benfdking changed the title refactor(lsp): creation of lsp refactor(lsp): creation of context Jun 10, 2025
@benfdking benfdking force-pushed the refactor_creation_of_context branch from 8269bb2 to 66d01ca Compare June 10, 2025 11:20
@benfdking benfdking requested a review from Copilot June 10, 2025 11:32
@benfdking benfdking enabled auto-merge (squash) June 10, 2025 11:32
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

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_context to centralize context creation and error logging
  • Replaces inline context_class calls in initialize, did_save, _ensure_context_in_folder, and _ensure_context_for_document with the new helper
  • Simplifies error handling by logging failures at trace level and returning None on errors
Comments suppressed due to low confidence (1)

sqlmesh/lsp/main.py:88

  • Add unit tests for _create_lsp_context to cover both successful instantiation and exception handling paths, ensuring that errors are logged and None is returned as expected.
def _create_lsp_context(self, paths: t.List[Path]) -> t.Optional[LSPContext]:

Comment thread sqlmesh/lsp/main.py
try:
created_context = self.context_class(paths=[folder_uri])
self.lsp_context = LSPContext(created_context)
lsp_context = self._create_lsp_context([folder_uri])
Copy link

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@benfdking benfdking merged commit d655523 into main Jun 10, 2025
25 checks passed
@benfdking benfdking deleted the refactor_creation_of_context branch June 10, 2025 11: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.

2 participants