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; }