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:
parent
981811567f
commit
16ce9737a7
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user