Skip to content

Conversation

@juleswritescode
Copy link
Collaborator

@juleswritescode juleswritescode commented Dec 14, 2024

Autocompletions for functions! Some rules that are applied:

  • if we're in a select clause, we'll prefer function items over table items
  • if we're in an "invocation" (parentheses after the current token), we'll prefer functions
  • if we're in a from clause, we'll slightly prefer table items

I refactored the CompletionRelevance again; now we can update the score based on the completion item score.

I also added docs to the SchemaCache's Function and changed the query. Some properties were Options, even though they should always be present: id, schema etc. – please verify if I made any wrong assumptions 🙌

Some extra stuff:

  • added a few additional test helpers (only compiled when we're running tests)
  • changed the CompletionItem.preselected from Option<bool> to a simple bool
  • added a ClauseType enum

Note: I had to comment out an alphanumeric table test. The query generates a tree-sitter tree with an ERROR, and the current node has an end_byte() that is at position 17, while the query only has a length of 14... will check in a separate PR, not sure why it even worked before 🤷

@juleswritescode juleswritescode changed the title Feat/completions fn feat(completions): autocomplete for function types Dec 14, 2024
@juleswritescode juleswritescode marked this pull request as ready for review December 14, 2024 15:33
Copy link
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

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

lgtm! Two nits, but we can merge 🙏🏼

@psteinroe
Copy link
Collaborator

@juleswritescode, sorry, can you fix the conflict again? Should have merge the other pr after this one

@juleswritescode
Copy link
Collaborator Author

@juleswritescode, sorry, can you fix the conflict again? Should have merge the other pr after this one

Check!!

@psteinroe psteinroe merged commit dd70fa6 into supabase-community:main Dec 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants