mirror of
https://github.com/salexdv/bsl_console.git
synced 2024-11-28 08:48:48 +02:00
Подсказка переменных объявленных в итерациях
This commit is contained in:
parent
f406d1fe40
commit
b7031cc182
@ -3355,14 +3355,55 @@ class bslHelper {
|
||||
|
||||
/**
|
||||
* Looks for variables into iterations of loops
|
||||
* in current position
|
||||
*
|
||||
* @param {string} pattern to look for variables
|
||||
*
|
||||
* @returns {array} array with variables names
|
||||
*/
|
||||
getLoopsVarNames() {
|
||||
getLoopsVarNamesForCurrentPosition(pattern) {
|
||||
|
||||
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)'));
|
||||
|
||||
let loop_start = Finder.findPreviousMatch(this.model, pattern, this.position, false);
|
||||
|
||||
if (loop_start) {
|
||||
|
||||
let start_pos = new monaco.Position(loop_start.range.startLineNumber, loop_start.range.startColumn);
|
||||
let loop_end = Finder.findNextMatch(this.model, '(?:конеццикла|enddo)', start_pos, false);
|
||||
|
||||
if (loop_end) {
|
||||
|
||||
let end_pos = new monaco.Position(loop_end.range.startLineNumber, loop_end.range.startColumn);
|
||||
|
||||
if (start_pos.isBefore(this.position) && this.position.isBefore(end_pos)) {
|
||||
names.push(loop_start.matches[loop_start.matches.length - 1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for variables into iterations of loops
|
||||
*
|
||||
* @param {int} currentLine the current line
|
||||
*
|
||||
* @returns {array} array with variables names
|
||||
*/
|
||||
getLoopsVarNames(currentLine) {
|
||||
|
||||
let names = [];
|
||||
let each_pattern = '(?:для каждого|for each)\\s+([a-zA-Z0-9\u0410-\u044F_,\\s=]+)\\s+(?:из|in)';
|
||||
let for_pattern = '(?:для|for)\\s+([a-zA-Z0-9\u0410-\u044F_,\\s=]+)\\s+=.*(?:по|to)';
|
||||
|
||||
if (currentLine == 0) {
|
||||
|
||||
let matches = Finder.findMatches(this.model, each_pattern);
|
||||
matches = matches.concat(Finder.findMatches(this.model, for_pattern));
|
||||
|
||||
for (let idx = 0; idx < matches.length; idx++) {
|
||||
|
||||
@ -3374,6 +3415,14 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
names = this.getLoopsVarNamesForCurrentPosition(each_pattern);
|
||||
names = names.concat(this.getLoopsVarNamesForCurrentPosition(for_pattern));
|
||||
|
||||
}
|
||||
|
||||
return names;
|
||||
|
||||
}
|
||||
@ -3392,9 +3441,7 @@ class bslHelper {
|
||||
let funcLine = 0;
|
||||
names = names.concat(this.getFunctionsVarsNames(currentLine, funcLine));
|
||||
names = names.concat(this.getDefaultVarsNames(currentLine, funcLine));
|
||||
|
||||
if (currentLine == 0)
|
||||
names = names.concat(this.getLoopsVarNames());
|
||||
names = names.concat(this.getLoopsVarNames(currentLine));
|
||||
|
||||
return names;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user