Skip to content

feat(lsp): add keywords in query to autocompete#4638

Merged
benfdking merged 1 commit intomainfrom
adding_keywords_to_autocomplete
Jun 5, 2025
Merged

feat(lsp): add keywords in query to autocompete#4638
benfdking merged 1 commit intomainfrom
adding_keywords_to_autocomplete

Conversation

@benfdking
Copy link
Copy Markdown
Contributor

No description provided.

@benfdking benfdking linked an issue Jun 3, 2025 that may be closed by this pull request
@benfdking benfdking requested a review from Copilot June 3, 2025 16:12
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 enhances the LSP autocomplete functionality by including additional keywords from the SQL content. Key changes include adding new tests for keyword extraction, updating the autocomplete API to accept file content, and refactoring keyword extraction in the completions module.

Reviewed Changes

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

File Description
tests/lsp/test_completions.py Added tests for new keyword extraction logic.
sqlmesh/lsp/main.py Updated autocomplete functions to utilize file content.
sqlmesh/lsp/context.py Adjusted get_autocomplete signature to pass file content.
sqlmesh/lsp/completions.py Refactored keyword extraction and added support for file-specific keywords.

Comment thread sqlmesh/lsp/main.py
Comment thread sqlmesh/lsp/main.py
Comment thread sqlmesh/lsp/completions.py Outdated
Comment thread sqlmesh/lsp/completions.py Outdated
Comment thread sqlmesh/lsp/completions.py Outdated
Comment thread sqlmesh/lsp/completions.py Outdated
Comment on lines +160 to +161
# Extract identifiers (variables, table names, column names, etc.)
if token.token_type == TokenType.VAR and token.text:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What about IDENTIFIER (e.g. "foo") and STRING (e.g. 'foo') tokens? Should we factor the set of interesting tokens out into a global variable and do a look up token.token_type in it instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made it more generic, I think we just want to check waht's not matching if both upper.

Comment thread sqlmesh/lsp/completions.py Outdated
Comment on lines +162 to +164
# Skip if it's a SQL keyword
if token.text.upper() not in tokenizer_class.KEYWORDS:
keywords.add(token.text)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Copy Markdown
Contributor Author

@benfdking benfdking Jun 4, 2025

Choose a reason for hiding this comment

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

Because I don't want to add in the keywords twice.

@benfdking benfdking force-pushed the adding_keywords_to_autocomplete branch 3 times, most recently from 62d35ee to 6b9cbf3 Compare June 5, 2025 08:52
@benfdking benfdking force-pushed the adding_keywords_to_autocomplete branch from 6b9cbf3 to e92ff42 Compare June 5, 2025 11:39
@benfdking benfdking merged commit 40bd72f into main Jun 5, 2025
23 checks passed
@benfdking benfdking deleted the adding_keywords_to_autocomplete branch June 5, 2025 11:54
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.

Visual Studio Code: Auto-complete to recognize CTEs

3 participants