From b71f12a8f3543ec471b8bb02ee974ea9b127b0fe Mon Sep 17 00:00:00 2001 From: salexdv Date: Wed, 6 Mar 2024 18:40:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D1=8D=D0=BB=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=20=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=B8=D0=BF=D0=B0=20#34?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bsl_helper.js | 25 ++++++++++++++----------- src/test.js | 8 ++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/bsl_helper.js b/src/bsl_helper.js index f548e2d..ba42144 100644 --- a/src/bsl_helper.js +++ b/src/bsl_helper.js @@ -2953,6 +2953,12 @@ class bslHelper { 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_arr = source_exp.split('('); let exp_arr = source_arr[0].split('.'); @@ -3307,9 +3313,9 @@ class bslHelper { * @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) { @@ -3321,7 +3327,7 @@ class bslHelper { if (bslMetadata.customObjects.items.hasOwnProperty(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 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 stack = this.getMetadataStackForVar(exp, this.position, false); - let itemExists = this.getMetadataStackCompletionFromFullDefinition(suggestions, stack); - - if (!itemExists) { - this.getStackCompletionFromRefs(suggestions, stack); - } - + this.getMetadataStackCompletionFromFullDefinition(suggestions, stack); + this.getStackCompletionFromRefs(suggestions, stack); + if (!stack.length) { - this.getStackCompletionForLoopsVar(suggestions, exp); + this.getStackCompletionForLoopsVar(suggestions, exp, this.position); } } diff --git a/src/test.js b/src/test.js index b9e46bc..543e291 100644 --- a/src/test.js +++ b/src/test.js @@ -1256,6 +1256,14 @@ describe("Проверка автокомлита и подсказок реда expect(suggestions).to.be.an('array').that.not.is.empty; 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); + }); }