From 9d595ebb058823e783c71a9bb69b1383f325958e Mon Sep 17 00:00:00 2001 From: salexdv Date: Wed, 2 Feb 2022 07:31:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=B0=20=D0=9E?= =?UTF-8?q?=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=9C=D0=B5=D1=82=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bsl_helper.js | 35 +++++++++++++++++++++++++++++++---- src/parsers.js | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/bsl_helper.js b/src/bsl_helper.js index 6041a99..7fa0b90 100644 --- a/src/bsl_helper.js +++ b/src/bsl_helper.js @@ -561,14 +561,14 @@ class bslHelper { } /** - * Get array of metadata object names by snippet action + * Get array of metadata object by metadata name * - * @param {string} action type of action from snippet + * @param {string} metadataName name of metadata object * @param {completionItem} completionItem current item of suggestion list * * @returns {array} array of metadata object names */ - getSnippetMetadataItemsByAction(action, completionItem) { + getSnippetMetadataItemsByName(metadataName, completionItem) { let items = []; @@ -607,7 +607,7 @@ class bslHelper { relations['ВыберитеКонстанту'] = 'constants'; relations['РегистрРасчета'] = 'calcRegs'; - let relation = relations[action]; + let relation = relations[metadataName]; if (relation) items = this.getSnippetMetadataItems(relation, completionItem); @@ -616,6 +616,33 @@ class bslHelper { } + /** + * Get array of metadata object names by snippet action + * + * @param {string} action type of action from snippet + * @param {completionItem} completionItem current item of suggestion list + * + * @returns {array} array of metadata object names + */ + getSnippetMetadataItemsByAction(action, completionItem) { + + let items = []; + + if (0 <= action.indexOf('ОбъектМетаданных:')) { + action = action.replace('ОбъектМетаданных:', ''); + let metadata_array = action.split(','); + metadata_array.forEach((name) => { + let metadata_items = this.getSnippetMetadataItemsByName(name, completionItem); + items = items.concat(metadata_items); + }); + } + else + items = this.getSnippetMetadataItemsByName(action, completionItem); + + return items; + + } + /** * Replace standart choice elements with metadata objects * or other additional transformations diff --git a/src/parsers.js b/src/parsers.js index 93b5cad..c39340e 100644 --- a/src/parsers.js +++ b/src/parsers.js @@ -65,6 +65,7 @@ class SnippetsParser { if (1 < template_arr.length) { let action = template_arr[1].trim(); + if (action == 'ВыборВарианта') { template_arr = template_arr.slice(2); @@ -88,6 +89,26 @@ class SnippetsParser { placeholder = '${CURRENT_DATE}.${CURRENT_MONTH}.${CURRENT_YEAR} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}'; fix_placeholder = true; } + else if (action == 'ОбъектМетаданных') { + + template_arr = template_arr.slice(2); + let options = []; + + template_arr.forEach((value) => { + let option = value.replace(/"/g, '').trim(); + if (option.indexOf('.') == -1 && options.indexOf(option) == -1) + options.push(option); + }); + + if (options.length) + if (options.length == 1) + placeholder = options[0]; + else + placeholder = 'ОбъектМетаданных:' + options.join(); + else + placeholder = action; + + } else { placeholder = action; }