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; }