mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-02-01 13:08:06 +02:00
Режим запроса: подсказки полей таблицы, когда объявление таблицы многострочное
This commit is contained in:
parent
97517640c9
commit
f526ed4c7c
@ -350,8 +350,8 @@ class bslHelper {
|
||||
*/
|
||||
requireQueryRef() {
|
||||
|
||||
let word = this.getLastSeparatedWord().toLowerCase();
|
||||
return (word == 'ссылка' || word == 'refs') && (this.lastOperator == '');
|
||||
let match = editor.getModel().findPreviousMatch('\\s+(ссылка|refs)\\s+' , editor.getPosition(), true);
|
||||
return (match && match.range.startLineNumber == this.lineNumber);
|
||||
|
||||
}
|
||||
|
||||
@ -1763,6 +1763,8 @@ class bslHelper {
|
||||
*/
|
||||
getQueryFieldsCompletitionForTempTable(suggestions, sourceDefinition, startPosition) {
|
||||
|
||||
let tableExists = false;
|
||||
|
||||
// Let's find definition for temporary table
|
||||
let intoMatch = this.model.findPreviousMatch('(?:поместить|into)\\s+' + sourceDefinition, startPosition, true);
|
||||
|
||||
@ -1795,6 +1797,8 @@ class bslHelper {
|
||||
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
|
||||
});
|
||||
|
||||
tableExists = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1804,6 +1808,8 @@ class bslHelper {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return tableExists;
|
||||
|
||||
}
|
||||
|
||||
@ -1817,24 +1823,65 @@ class bslHelper {
|
||||
if (this.getLastCharacter() == '.') {
|
||||
|
||||
// Let's find start of current query
|
||||
let match = this.model.findPreviousMatch('(?:выбрать|select)', this.position, true);
|
||||
let startMatch = this.model.findPreviousMatch('(?:выбрать|select)', this.position, true);
|
||||
|
||||
if (match) {
|
||||
|
||||
if (startMatch) {
|
||||
|
||||
// Now we need to find lastExpression definition
|
||||
let position = new monaco.Position(match.range.startLineNumber, match.range.startColumn);
|
||||
match = this.model.findNextMatch('(.*)\\s+(?:как|as)\\s+' + this.lastRawExpression, position, true, false, null, true);
|
||||
let position = new monaco.Position(startMatch.range.startLineNumber, startMatch.range.startColumn);
|
||||
let match = this.model.findNextMatch('(.*)\\s+(?:как|as)\\s+' + this.lastRawExpression, position, true, false, null, true);
|
||||
|
||||
if (match) {
|
||||
if (match) {
|
||||
let sourceDefinition = match.matches[1];
|
||||
sourceDefinition = sourceDefinition.replace(/(из|левое|правое|внутреннее|внешнее|полное|from|left|right|inner|outer|full)?\s?(соединение|join)?/gi, '').trim();
|
||||
|
||||
if (!this.getQueryFieldsCompletitionForMetadata(suggestions, sourceDefinition)) {
|
||||
this.getQueryFieldsCompletitionForTempTable(suggestions, sourceDefinition, position);
|
||||
|
||||
if (!this.getQueryFieldsCompletitionForTempTable(suggestions, sourceDefinition, position)) {
|
||||
|
||||
position = new monaco.Position(startMatch.range.startLineNumber, startMatch.range.startColumn);
|
||||
let endMatch = this.model.findNextMatch('(?:из|from)[\\s\\S\\n]*?(?:как|as)\\s+' + this.lastRawExpression , position, true);
|
||||
|
||||
if (endMatch) {
|
||||
|
||||
// Searching the source
|
||||
position = new monaco.Position(endMatch.range.endLineNumber, endMatch.range.endColumn);
|
||||
let match = this.model.findPreviousMatch('[a-zA-Z0-9\u0410-\u044F]+\\.[a-zA-Z0-9\u0410-\u044F_]+(?:\\.[a-zA-Z0-9\u0410-\u044F]+)?', position, true, false, null, true);
|
||||
|
||||
if (match) {
|
||||
sourceDefinition = match.matches[0];
|
||||
this.getQueryFieldsCompletitionForMetadata(suggestions, sourceDefinition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
let position = new monaco.Position(startMatch.range.startLineNumber, startMatch.range.startColumn);
|
||||
let endMatch = this.model.findNextMatch('(?:из|from)[\\s\\S\\n]*?(?:как|as)\\s+' + this.lastRawExpression , position, true);
|
||||
|
||||
if (endMatch) {
|
||||
|
||||
// Searching the source
|
||||
position = new monaco.Position(endMatch.range.endLineNumber, endMatch.range.endColumn);
|
||||
let match = this.model.findPreviousMatch('[a-zA-Z0-9\u0410-\u044F]+\\.[a-zA-Z0-9\u0410-\u044F_]+(?:\\.[a-zA-Z0-9\u0410-\u044F]+)?', position, true, false, null, true);
|
||||
|
||||
if (match) {
|
||||
|
||||
let sourceDefinition = match.matches[0];
|
||||
if (!this.getQueryFieldsCompletitionForMetadata(suggestions, sourceDefinition)) {
|
||||
this.getQueryFieldsCompletitionForTempTable(suggestions, sourceDefinition, position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1110,11 +1110,14 @@
|
||||
'////////////////////////////////////////////////////////////////////////////////',
|
||||
'ВЫБРАТЬ',
|
||||
' Товары.Ссылка КАК Ссылка,',
|
||||
' Цены.Реквизит2 КАК Цена',
|
||||
' Цены.Цена КАК Цена',
|
||||
'ИЗ',
|
||||
' Справочник.Товары КАК Товары',
|
||||
' ЛЕВОЕ СОЕДИНЕНИЕ РегистрСведений.ЦеныНоменклатуры КАК Цены',
|
||||
' ПО Товары.Ссылка = Цены.Реквизит1',
|
||||
' ЛЕВОЕ СОЕДИНЕНИЕ РегистрСведений.ЦеныНоменклатуры.СрезПоследних(',
|
||||
' &Период,',
|
||||
' Номенклатура В (&СписокНоменклатуры),',
|
||||
' ) КАК Цены',
|
||||
' ПО Товары.Ссылка = Цены.Номенклатура',
|
||||
'ГДЕ',
|
||||
' Товары.Ссылка <> &Товар'
|
||||
].join('\n');
|
||||
|
@ -210,6 +210,14 @@ describe("Проверка автокомлита и подсказок реда
|
||||
|
||||
});
|
||||
|
||||
it("проверка подсказки полей таблицы запроса, когда объявление таблицы многострочное", function () {
|
||||
bsl = helper(getCode(), 1094, 7);
|
||||
let suggestions = [];
|
||||
bsl.getQueryFieldsCompletition(suggestions);
|
||||
expect(suggestions).to.be.an('array').that.not.is.empty;
|
||||
assert.equal(suggestions.some(suggest => suggest.label === "ВидЦены"), true);
|
||||
});
|
||||
|
||||
switchQueryMode();
|
||||
|
||||
mocha.run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user