From c0647e2a46c9558c5b31ef9563ff41c2ffa5329f Mon Sep 17 00:00:00 2001 From: salexdv Date: Tue, 23 Aug 2022 08:49:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=82=20?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=BD=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B8=D0=B7=20=D0=B8=D1=82=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B9=20=D1=86=D0=B8=D0=BA=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bsl_helper.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/bsl_helper.js b/src/bsl_helper.js index ca93d65..7146825 100644 --- a/src/bsl_helper.js +++ b/src/bsl_helper.js @@ -3338,6 +3338,31 @@ class bslHelper { } + /** + * Looks for variables into iterations of loops + * + * @returns {array} array with variables names + */ + getLoopsVarNames() { + + let names = []; + let matches = Finder.findMatches(this.model, '(?:для каждого|for each)\\s+([a-zA-Z0-9\u0410-\u044F_,\\s=]+)\\s+(?:из|in)'); + matches = matches.concat(Finder.findMatches(this.model, '(?:для|for)\\s+([a-zA-Z0-9\u0410-\u044F_,\\s=]+)\\s+=.*(?:по|to)')); + + for (let idx = 0; idx < matches.length; idx++) { + + let match = matches[idx]; + let varDef = match.matches[match.matches.length - 1]; + + if (!names.some(name => name === varDef)) + names.push(varDef); + + } + + return names; + + } + /** * Fills and returns array of variables names * @@ -3353,6 +3378,9 @@ class bslHelper { names = names.concat(this.getFunctionsVarsNames(currentLine, funcLine)); names = names.concat(this.getDefaultVarsNames(currentLine, funcLine)); + if (currentLine == 0) + names = names.concat(this.getLoopsVarNames()); + return names; }