1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-11-28 08:48:48 +02:00

Доработка подсказок через точку для однострочных выражений.

Например, Запрос.Выполнить().Вырузить().ВыгрузитьКолонку()
This commit is contained in:
salexdv 2020-08-19 16:12:59 +03:00
parent c8da41ca6f
commit d091d5814c
3 changed files with 50 additions and 32 deletions

View File

@ -97,7 +97,7 @@ define(['vs/editor/editor.main'], function () {
contextData.set(position.lineNumber, new Map());
}
lineContextData = contextData.get(position.lineNumber);
lineContextData.set(obj.name, obj.data);
lineContextData.set(obj.name.toLowerCase(), obj.data);
}
return null;
}

View File

@ -465,8 +465,10 @@ class bslHelper {
if (lineContextData) {
let wordUntil = this.model.getWordUntilPosition(position);
this.getRefSuggestions(suggestions, lineContextData.get(wordUntil.word))
if (wordUntil.word)
this.getRefSuggestions(suggestions, lineContextData.get(wordUntil.word.toLowerCase()))
else if (this.lastOperator == ')')
this.getRefSuggestions(suggestions, lineContextData.get(this.lastRawExpression))
}
@ -499,7 +501,7 @@ class bslHelper {
lineContextData = contextData.get(match.range.startLineNumber);
if (lineContextData)
this.getRefSuggestions(suggestions, lineContextData.get(match.matches[match.matches.length - 1]));
this.getRefSuggestions(suggestions, lineContextData.get(match.matches[match.matches.length - 1].toLowerCase()));
}
@ -1079,38 +1081,41 @@ class bslHelper {
if (this.lastOperator != '"') {
if (!this.getClassCompletition(suggestions, bslGlobals.classes)) {
this.getRefCompletition(suggestions);
if (!this.getClassCompletition(suggestions, bslGlobals.systemEnum)) {
if (!suggestions.length) {
if (!this.getMetadataCompletition(suggestions, bslMetadata)) {
if (!this.getClassCompletition(suggestions, bslGlobals.classes)) {
this.getRefCompletition(suggestions);
if (!this.getClassCompletition(suggestions, bslGlobals.systemEnum)) {
if (!suggestions.length)
this.getVariablesCompetition(suggestions);
if (!this.getMetadataCompletition(suggestions, bslMetadata)) {
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword.ru, true);
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword.en, true);
if (!suggestions.length)
this.getVariablesCompetition(suggestions);
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword.ru, true);
this.getCommonCompletition(suggestions, bslGlobals.keywords, monaco.languages.CompletionItemKind.Keyword.en, true);
if (this.requireClass()) {
this.getCommonCompletition(suggestions, bslGlobals.classes, monaco.languages.CompletionItemKind.Constructor, false);
}
else {
this.getCommonCompletition(suggestions, bslGlobals.globalfunctions, monaco.languages.CompletionItemKind.Function, true);
this.getCommonCompletition(suggestions, bslGlobals.globalvariables, monaco.languages.CompletionItemKind.Class, false);
this.getCommonCompletition(suggestions, bslGlobals.systemEnum, monaco.languages.CompletionItemKind.Enum, false);
this.getCommonCompletition(suggestions, bslGlobals.customFunctions, monaco.languages.CompletionItemKind.Function, true);
this.getCommonCompletition(suggestions, bslMetadata.commonModules, monaco.languages.CompletionItemKind.Module, true);
this.getCustomObjectsCompletition(suggestions, bslMetadata.customObjects, monaco.languages.CompletionItemKind.Enum);
}
this.getSnippets(suggestions, snippets);
if (this.requireClass()) {
this.getCommonCompletition(suggestions, bslGlobals.classes, monaco.languages.CompletionItemKind.Constructor, false);
}
else {
this.getCommonCompletition(suggestions, bslGlobals.globalfunctions, monaco.languages.CompletionItemKind.Function, true);
this.getCommonCompletition(suggestions, bslGlobals.globalvariables, monaco.languages.CompletionItemKind.Class, false);
this.getCommonCompletition(suggestions, bslGlobals.systemEnum, monaco.languages.CompletionItemKind.Enum, false);
this.getCommonCompletition(suggestions, bslGlobals.customFunctions, monaco.languages.CompletionItemKind.Function, true);
this.getCommonCompletition(suggestions, bslMetadata.commonModules, monaco.languages.CompletionItemKind.Module, true);
this.getCustomObjectsCompletition(suggestions, bslMetadata.customObjects, monaco.languages.CompletionItemKind.Enum);
}
this.getSnippets(suggestions, snippets);
}
}
}
}
@ -1517,7 +1522,7 @@ class bslHelper {
if (lineContextData) {
let wordUntil = this.model.getWordUntilPosition(position);
wordContext = lineContextData.get(wordUntil.word);
wordContext = lineContextData.get(wordUntil.word.toLowerCase());
if (wordContext && wordContext.sig) {

View File

@ -402,7 +402,7 @@ describe("Проверка автокомлита и подсказок реда
bsl = helper('_ОстаткиТовара.Номенклатура.');
let suggestions = [];
contextData = new Map([
[1, new Map([["Номенклатура", { "ref": "catalogs.Товары", "sig": null }]])]
[1, new Map([["номенклатура", { "ref": "catalogs.Товары", "sig": null }]])]
]);
bsl.getRefCompletition(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
@ -418,8 +418,8 @@ describe("Проверка автокомлита и подсказок реда
bsl = helper('ОбъектЗапрос = Новый Запрос();\nРезультат = ОбъектЗапрос.Выполнить();\nТаблица = Результат.Выгрузить();\nТаблица.');
let suggestions = [];
contextData = new Map([
[2, new Map([["Выполнить", { "ref": "types.РезультатЗапроса", "sig": null }]])],
[3, new Map([["Выгрузить", { "ref": "classes.ТаблицаЗначений", "sig": null }]])]
[2, new Map([["выполнить", { "ref": "types.РезультатЗапроса", "sig": null }]])],
[3, new Map([["выгрузить", { "ref": "classes.ТаблицаЗначений", "sig": null }]])]
]);
bsl.getRefCompletition(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
@ -439,8 +439,8 @@ describe("Проверка автокомлита и подсказок реда
}
};
contextData = new Map([
[2, new Map([["Скопировать", { "ref": "classes.ТаблицаЗначений", "sig": null }]])],
[3, new Map([["ВыгрузитьКолонку", { "ref": "classes.Массив", "sig": signature }]])]
[2, new Map([["скопировать", { "ref": "classes.ТаблицаЗначений", "sig": null }]])],
[3, new Map([["выгрузитьколонку", { "ref": "classes.Массив", "sig": signature }]])]
]);
let help = bsl.getRefSigHelp();
expect(help).to.have.property('activeParameter');
@ -451,7 +451,7 @@ describe("Проверка автокомлита и подсказок реда
bsl = helper('Таблица = НайтиПоСсылкам();\nТаблица.');
let suggestions = [];
contextData = new Map([
[1, new Map([["НайтиПоСсылкам", { "ref": "classes.ТаблицаЗначений", "sig": null }]])]
[1, new Map([["найтипоссылкам", { "ref": "classes.ТаблицаЗначений", "sig": null }]])]
]);
bsl.getRefCompletition(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
@ -459,6 +459,19 @@ describe("Проверка автокомлита и подсказок реда
contextData = new Map();
});
it("проверка подсказки для таблицы, полученной из результата запроса в одну строку", function () {
bsl = helper('ОбъектЗапрос = Новый Запрос();\nТаблица = ОбъектЗапрос.Выполнить().Выгрузить().');
let suggestions = [];
contextData = new Map([
[2, new Map([["выполнить", { "ref": "types.РезультатЗапроса", "sig": null }]])],
[2, new Map([["выгрузить", { "ref": "classes.ТаблицаЗначений", "sig": null }]])]
]);
bsl.getRefCompletition(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
assert.equal(suggestions.some(suggest => suggest.label === "Скопировать"), true);
contextData = new Map();
});
}
mocha.run();