mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-02-13 13:48:24 +02:00
Реализация подсказки для параметров запроса
This commit is contained in:
parent
ea3c626768
commit
040022bd6a
@ -1225,6 +1225,38 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills array of completition for params of query
|
||||
*
|
||||
* @param {array} suggestions array of suggestions for provideCompletionItems
|
||||
* @param {CompletionItemKind} kind - monaco.languages.CompletionItemKind (class, function, constructor etc.)
|
||||
*/
|
||||
getQueryParamsCompletition(suggestions, kind) {
|
||||
|
||||
if (this.lastRawExpression.startsWith('&')) {
|
||||
|
||||
const matches = this.model.findMatches('&(.*?)[\\b\\s\\n,]', true, true, false, null, true)
|
||||
|
||||
for (let idx = 0; idx < matches.length; idx++) {
|
||||
|
||||
let match = matches[idx];
|
||||
let paramName = match.matches[match.matches.length - 1];
|
||||
|
||||
if (paramName && !suggestions.some(suggest => suggest.insertText === paramName)) {
|
||||
suggestions.push({
|
||||
label: '&' + paramName,
|
||||
kind: kind,
|
||||
insertText: paramName,
|
||||
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Completition provider for query language
|
||||
*
|
||||
@ -1240,6 +1272,7 @@ class bslHelper {
|
||||
this.getCommonCompletition(suggestions, bslQuery.functions, monaco.languages.CompletionItemKind.Function, true);
|
||||
|
||||
this.getQueryCommonCompletition(suggestions, langDef, monaco.languages.CompletionItemKind.Module);
|
||||
this.getQueryParamsCompletition(suggestions, monaco.languages.CompletionItemKind.Enum);
|
||||
|
||||
if (suggestions.length)
|
||||
return { suggestions: suggestions }
|
||||
|
@ -151,7 +151,7 @@ define([], function () {
|
||||
'РАЗНОСТЬДАТ', 'DATEDIFF', 'СЕКУНДА', 'SECOND', 'СПЕЦСИМВОЛ',
|
||||
'ESCAPE', 'СРЕДНЕЕ', 'AVG', 'ССЫЛКА', 'REFS', 'СТРОКА', 'STRING',
|
||||
'СУММА', 'SUM', 'ТОГДА', 'THEN', 'УБЫВ', 'DESC', 'ЧАС', 'HOUR',
|
||||
'ЧИСЛО', 'NUMBER', 'NULL'
|
||||
'ЧИСЛО', 'NUMBER', 'NULL', 'КОГДА', 'WHEN'
|
||||
],
|
||||
queryOperators: /[=><+\-*\/%;,]+/,
|
||||
// The main tokenizer for our languages
|
||||
@ -357,7 +357,7 @@ define([], function () {
|
||||
query: {
|
||||
languageDef: query_language,
|
||||
completionProvider: {
|
||||
triggerCharacters: ['.', '"'],
|
||||
triggerCharacters: ['.', '"', '&'],
|
||||
provideCompletionItems: function (model, position) {
|
||||
let bsl = new bslHelper(model, position);
|
||||
return bsl.getQueryCompletition(query_language);
|
||||
|
Loading…
x
Reference in New Issue
Block a user