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

Подсказка по переменным, которые являются параметрами процедуры/функции closes #16

This commit is contained in:
salexdv 2020-08-27 21:02:48 +03:00
parent 981811567f
commit 16ce9737a7
2 changed files with 32 additions and 0 deletions

View File

@ -1066,6 +1066,30 @@ class bslHelper {
}
const funcDef = editor.getModel().findPreviousMatch('(?:процедура|функция)\\s+[a-zA-Z0-9\u0410-\u044F_]+\\(([a-zA-Z0-9\u0410-\u044F_,\\s=]+)\\)', true, true, false, null, true);
if (funcDef && 1 < funcDef.matches.length) {
const params = funcDef.matches[1].split(',');
let word = this.word;
params.forEach(function(param){
let paramName = param.split('=')[0].trim();
if (paramName.toLowerCase().startsWith(word)) {
suggestions.push({
label: paramName,
kind: monaco.languages.CompletionItemKind.Variable,
insertText: paramName,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
});
}
});
}
}
/**

View File

@ -472,6 +472,14 @@ describe("Проверка автокомлита и подсказок реда
contextData = new Map();
});
it("проверка подсказки переменных из параметров функции", function () {
bsl = helper('Функция МояФункция(Парам1, Парам2, Парам3)\nПар');
let suggestions = [];
bsl.getVariablesCompetition(suggestions);
expect(suggestions).to.be.an('array').that.not.is.empty;
assert.equal(suggestions.some(suggest => suggest.label === "Парам1"), true);
});
}
mocha.run();