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

Подсказка для элементов массива определенного типа #341

This commit is contained in:
salexdv 2024-03-06 18:40:13 +03:00
parent 5c33a051f6
commit b71f12a8f3
2 changed files with 22 additions and 11 deletions

View File

@ -2953,6 +2953,12 @@ class bslHelper {
column: column column: column
}); });
let var_match = Finder.findPreviousMatch(this.model, '\\s+' + source_var + '\\s+(?:из|in)\\s+(.+?)\\s+(?:цикл|do)', position, false);
if (var_match) {
this.getStackCompletionForLoopsVar([], source_var, new monaco.Position(match.range.startLineNumber, match.range.startColumn));
}
let source_exp = match.matches[3]; let source_exp = match.matches[3];
let source_arr = source_exp.split('('); let source_arr = source_exp.split('(');
let exp_arr = source_arr[0].split('.'); let exp_arr = source_arr[0].split('.');
@ -3307,9 +3313,9 @@ class bslHelper {
* @param {array} stack call stack array * @param {array} stack call stack array
* *
*/ */
getStackCompletionForLoopsVar(suggestions, varName) { getStackCompletionForLoopsVar(suggestions, varName, position) {
let var_match = Finder.findPreviousMatch(this.model, '\\s+' + varName + '\\s+(?:из|in)\\s+(.+?)\\s+(?:цикл|do)', this.position, false); let var_match = Finder.findPreviousMatch(this.model, '\\s+' + varName + '\\s+(?:из|in)\\s+(.+?)\\s+(?:цикл|do)', position, false);
if (var_match) { if (var_match) {
@ -3321,7 +3327,7 @@ class bslHelper {
if (bslMetadata.customObjects.items.hasOwnProperty(source)) { if (bslMetadata.customObjects.items.hasOwnProperty(source)) {
let item = bslMetadata.customObjects.items[source] let item = bslMetadata.customObjects.items[source]
refExists = this.setContextForCustomItem(item, varName, this.lineNumber, true); refExists = this.setContextForCustomItem(item, varName, position.lineNumber, true);
} }
} }
@ -3329,7 +3335,7 @@ class bslHelper {
let paths = sources.join('.properties.').split('.'); let paths = sources.join('.properties.').split('.');
let item = bslHelper.getObjectByPath(bslMetadata.customObjects.items, paths); let item = bslHelper.getObjectByPath(bslMetadata.customObjects.items, paths);
refExists = this.setContextForCustomItem(item, varName, this.lineNumber, true); refExists = this.setContextForCustomItem(item, varName, position.lineNumber, true);
} }
@ -3351,14 +3357,11 @@ class bslHelper {
let exp = this.lastRawExpression; let exp = this.lastRawExpression;
let stack = this.getMetadataStackForVar(exp, this.position, false); let stack = this.getMetadataStackForVar(exp, this.position, false);
let itemExists = this.getMetadataStackCompletionFromFullDefinition(suggestions, stack); this.getMetadataStackCompletionFromFullDefinition(suggestions, stack);
this.getStackCompletionFromRefs(suggestions, stack);
if (!itemExists) {
this.getStackCompletionFromRefs(suggestions, stack);
}
if (!stack.length) { if (!stack.length) {
this.getStackCompletionForLoopsVar(suggestions, exp); this.getStackCompletionForLoopsVar(suggestions, exp, this.position);
} }
} }

View File

@ -1256,6 +1256,14 @@ describe("Проверка автокомлита и подсказок реда
expect(suggestions).to.be.an('array').that.not.is.empty; expect(suggestions).to.be.an('array').that.not.is.empty;
assert.equal(suggestions.some(suggest => suggest.label === "Наименование"), true); assert.equal(suggestions.some(suggest => suggest.label === "Наименование"), true);
bsl = helper(`Для Каждого Товар Из Параметры.Товары Цикл
ТоварОбъект = Товар.ПолучитьОбъект();
ТоварОбъект.`);
suggestions = [];
bsl.getStackCompletion(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
assert.equal(suggestions.some(suggest => suggest.label === "Записать"), true);
}); });
} }