New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Server typos and keyword completion modifier #2460
Conversation
allows a highlight rule modify keyword completions
I like the result of using |
Good point. I think it would be valuable to have a standardized way to have create more intelligent keyword completions for each mode, but I don't have the time to figure out the best implementation. I removed all changes that are not for SQL Server mode and added an override for UPDATE |
was using wrong escape char for string, sqlserver uses double single quote to escape a single quote
Are you sure about caching? autocompleter doesn't modify array of matches it receives from getCompletions https://github.com/ajaxorg/ace/blob/master/lib/ace/autocomplete.js#L237. |
var keywords = this.$keywordList || this.$createKeywordList(); | ||
var types = session.$mode.$highlightRules.keywordTypes; | ||
|
||
return keywords.map(function(word) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we just use types skipping keywordList entirely?
keywordList removes some information that highlighter doesn't need and here we are restoring that using slow indexOf in a large array
Good point about skipping the keyword list, the custom completions is now simpler and its only compiled once. |
@@ -164,14 +154,11 @@ var SqlServerHighlightRules = function() { | |||
start: "/\\*", | |||
end: "\\*/" | |||
}, { | |||
token: "string", // ' string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was the unnecessary rule you were referring to, correct? I think I copied that rule from somewhere else
SQL Server typos and keyword completion modifier
Merged. |
This contains a few different things:
getCompletions
for SQL Server mode to ensure proper case of completions and use intelligentmeta
instead ofkeyword
for all completions.3. AddedcompletionModifier
to text_highlight_rules, which is an optional function that can be specified by a mode's highlight rules that inherit from text_highlight_rules.4. Modified
getCompletions
in text mode to call thecompletionModifier
if it exists.The completion modifier allows modifying keyword completions, which is useful for a few things:- Remove keywords that are obsolete from the completor, but they still need to have syntax highlighting- Modify themeta
display in the completer to provide more information thankeyword
for some things- Modify the case of completions, use case: SQL Server mode has completions that should be all caps, and others that should not (even though all keywords are case-insensitive for highlighting, its simply recommended by Microsoft to use all caps for most keywords).I modified SQL Server mode to use the completion modifier, and I went ahead and modified Javascript mode as well.If you don't like the completion modifier and the javascript modifications, I can remove them and simply do a one off for SQL Server mode completions by overridinggetCompletions
for SQL Server mode. I decided to make the completion modifier standard because I think it could benefit almost all modes.Javascript mode completion popup with modifiedmeta
for keywords: