feat(lsp): add keywords in query to autocompete#4638
Conversation
There was a problem hiding this comment.
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. |
| # Extract identifiers (variables, table names, column names, etc.) | ||
| if token.token_type == TokenType.VAR and token.text: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I made it more generic, I think we just want to check waht's not matching if both upper.
| # Skip if it's a SQL keyword | ||
| if token.text.upper() not in tokenizer_class.KEYWORDS: | ||
| keywords.add(token.text) |
There was a problem hiding this comment.
Because I don't want to add in the keywords twice.
62d35ee to
6b9cbf3
Compare
6b9cbf3 to
e92ff42
Compare
No description provided.