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

Возврат имен переменных из итераций циклов

This commit is contained in:
salexdv 2022-08-23 08:49:10 +03:00
parent eca9eb8edd
commit c0647e2a46

View File

@ -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 * Fills and returns array of variables names
* *
@ -3353,6 +3378,9 @@ class bslHelper {
names = names.concat(this.getFunctionsVarsNames(currentLine, funcLine)); names = names.concat(this.getFunctionsVarsNames(currentLine, funcLine));
names = names.concat(this.getDefaultVarsNames(currentLine, funcLine)); names = names.concat(this.getDefaultVarsNames(currentLine, funcLine));
if (currentLine == 0)
names = names.concat(this.getLoopsVarNames());
return names; return names;
} }