1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2025-02-07 13:31:37 +02:00

Работа над подсказками для полей таблиц в запросе (подсказка для временных таблиц в конструкции ГДЕ или СОЕДИНЕНИЕ)

This commit is contained in:
salexdv 2020-12-18 21:37:55 +03:00
parent f786558744
commit 374fee4b30
2 changed files with 51 additions and 3 deletions

View File

@ -1836,6 +1836,51 @@ class bslHelper {
}
/**
* Fills array of completition for temporary tables in source
*
* @param {array} suggestions array of suggestions for provideCompletionItems
*/
getQuerySourceTempraryTablesCompletition(suggestions) {
let sourceExist = false;
let startMatch = this.model.findPreviousMatch('(?:выбрать|select)', this.position, true);
if (startMatch) {
let matches = editor.getModel().findMatches('(?:поместить|into)\\s+([a-zA-Z0-9\u0410-\u044F_]+)', null, true, false, null, true);
if (matches) {
for (let idx = 0; idx < matches.length; idx++) {
let match = matches[idx];
if (match.range.startLineNumber < startMatch.range.startLineNumber) {
let tableName = match.matches[match.matches.length - 1];
suggestions.push({
label: tableName,
kind: monaco.languages.CompletionItemKind.Unit,
insertText: tableName,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
});
sourceExist = true;
}
}
}
}
return sourceExist;
}
/**
* Fills array of completition for source of table
*
@ -1883,10 +1928,13 @@ class bslHelper {
}
}
// suggestion for temporary tables
sourceExist = Math.max(sourceExist, this.getQuerySourceTempraryTablesCompletition(suggestions));
}
}
}
}

View File

@ -127,7 +127,7 @@ describe("Проверка автокомлита и подсказок реда
});
it("проверка подсказки для временных таблиц в конструкции ИЗ ИЛИ СОЕДИНЕНИЕ ", function () {
bsl = helper(getCode(), 70, 4);
bsl = helper(getCode(), 72, 20);
let suggestions = [];
bsl.getQuerySourceCompletition(suggestions, null);
expect(suggestions).to.be.an('array').that.not.is.empty;