Complete more precisely in the "value" position#1665
Open
rolandwalker wants to merge 1 commit intomainfrom
Open
Complete more precisely in the "value" position#1665rolandwalker wants to merge 1 commit intomainfrom
rolandwalker wants to merge 1 commit intomainfrom
Conversation
No security issues found in this PR. I could not execute tests in this environment because |
When in the "value" position, that is, where a value may be referred to
such as a literal, function name, or column name, don't offer all
keywords, but instead limit keywords to function names and function-
alikes.
Pygments has some errors in its designations of keywords vs functions,
such as classifying JSON_VALUE() as a keyword, and some missing
functions as well, so we amend the values imported from Pygments. At a
certain point the amendments would be large enough that we should
consider maintaining our own categorical lists. But the amendments are
so far not too extensive.
(We might also consider adding loadable function names.)
Since we have made the list of function names more accurate, we can then
remove '{"type": "keyword"}' from the completion candidates when we are
in the "value" position (keeping '{"type": "function"}' which is already
present.
Now, functions such as JSON_VALUE() complete in the "value" position,
_eg_, after a SELECT, but mere keywords such as SELECT do not. We no
longer suggest "SELECT SELECT"!
An exception was made here for completions within backticks, which are
still not great, and need future work, because the choices are too
many. Backtick completions are left in the current state.
As a comment notes, we should better also define "value position"
keywords such as CASE and make a separate completion set for them,
rather than lumping them into the list of functions as is done here.
There are other edge cases such as CURRENT_TIME, which can occur in the
value position but does not take parentheses, and weird ones such as
MEMBER OF(), a midfix function which also contains a space in the name.
ba8cf46 to
a341e6c
Compare
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.
Description
When in the "value" position, that is, where a value may be referred to such as a literal, function name, or column name, don't offer all keywords, but instead limit keywords to function names and function-alikes.
Pygments has some errors in its designations of keywords vs functions, such as classifying
JSON_VALUE()as a keyword, and some missing functions as well, so we amend the values imported from Pygments. At a certain point the amendments would be large enough that we should consider maintaining our own categorical lists. But the amendments are so far not too extensive.(We might also consider adding loadable function names.)
Since we have made the list of function names more accurate, we can then remove
{"type": "keyword"}from the completion candidates when we are in the "value" position (keeping{"type": "function"}which is already present.Now, functions such as
JSON_VALUE()complete in the "value" position, eg, after aSELECT, but mere keywords such asSELECTdo not. We no longer suggestSELECT SELECT!An exception was made here for completions within backticks, which are still not great, and need future work, because the choices are too many. Backtick completions are left in the current state.
As a comment notes, we should better also define "value position" keywords such as
CASEand make a separate completion set for them, rather than lumping them into the list of functions as is done here.There are other edge cases such as
CURRENT_TIME, which can occur in the value position but does not take parentheses, and weird ones such asMEMBER OF(), a midfix function which also contains a space in the name.Checklist
changelog.mdfile.AUTHORSfile (or it's already there).