From 16ce9737a7b0eb216d7d5e43e4a450440cd6737d Mon Sep 17 00:00:00 2001 From: salexdv Date: Thu, 27 Aug 2020 21:02:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D0=BC,=20=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=8B=D0=B5=20=D1=8F=D0=B2=D0=BB=D1=8F=D1=8E=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= =?UTF-8?q?=D1=8B/=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20closes=20#1?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bsl_helper.js | 24 ++++++++++++++++++++++++ src/test.js | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/src/bsl_helper.js b/src/bsl_helper.js index dec7207..d5485eb 100644 --- a/src/bsl_helper.js +++ b/src/bsl_helper.js @@ -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 + }); + } + + }); + + } + } /** diff --git a/src/test.js b/src/test.js index 647cf01..6e08a7e 100644 --- a/src/test.js +++ b/src/test.js @@ -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();