mirror of
https://github.com/salexdv/bsl_console.git
synced 2024-11-28 08:48:48 +02:00
Подсказка имен реквизитов и табличных частей
This commit is contained in:
parent
eda95301fd
commit
87ea9141d6
@ -34745,6 +34745,7 @@ define([], function () {
|
||||
"ОбъединениеНедопустимыхПодстановкиXS": {},
|
||||
"ОбъектXDTO": {},
|
||||
"ОбъектАнализаДанных": {},
|
||||
"ОбъектМетаданных": {},
|
||||
"ОбъектМетаданныхКонфигурация": {},
|
||||
"ОбъектыСлояГеографическойСхемы": {},
|
||||
"ОбъявлениеАтрибутаXS": {},
|
||||
|
@ -863,7 +863,8 @@ define([], function () {
|
||||
"name":"Реквизиты",
|
||||
"name_en":"Attributes",
|
||||
"description":"Коллекция объектов метаданных, описывающих реквизиты данного объекта метаданных.",
|
||||
"ref":"types.КоллекцияОбъектовМетаданных"
|
||||
"ref":"types.КоллекцияОбъектовМетаданных",
|
||||
"list": "properties"
|
||||
},
|
||||
"СерииКодов":{
|
||||
"name":"СерииКодов",
|
||||
@ -899,7 +900,8 @@ define([], function () {
|
||||
"name":"ТабличныеЧасти",
|
||||
"name_en":"TabularSections",
|
||||
"description":"Коллекция объектов метаданных, описывающих табличные части данного объекта метаданных. Элементами коллекции являются объекты типа ОбъектМетаданных: ТабличнаяЧасть.",
|
||||
"ref":"types.КоллекцияОбъектовМетаданных"
|
||||
"ref":"types.КоллекцияОбъектовМетаданных",
|
||||
"list": "tabulars"
|
||||
},
|
||||
"ТипКода":{
|
||||
"name":"ТипКода",
|
||||
|
@ -1150,7 +1150,7 @@ class bslHelper {
|
||||
if (ref && ref.indexOf(':') != -1) {
|
||||
if (metadataKey && medatadaName) {
|
||||
if (ref.indexOf(':metadata') != -1)
|
||||
ref = metadataKey + '.metadata';
|
||||
ref = metadataKey + '.metadata.' + medatadaName;
|
||||
else if (ref.indexOf(':obj') != -1)
|
||||
ref = metadataKey + '.' + medatadaName + '.obj';
|
||||
else
|
||||
@ -1410,7 +1410,12 @@ class bslHelper {
|
||||
}
|
||||
}
|
||||
else if (subItemName == 'metadata' && this.objectHasProperties(bslMetadata, itemName, 'metadata')) {
|
||||
this.getClassSuggestions(suggestions, bslMetadata[itemName]['metadata']);
|
||||
if (refArray.length == 2)
|
||||
this.fillSuggestionsForMetadataItems(suggestions, bslMetadata[itemName], itemName, wordContext.ref);
|
||||
else if (refArray.length == 3) {
|
||||
let item = this.getMetadataItemByName(bslMetadata, itemName, refArray[2]);
|
||||
this.getItemMedatadaSuggestions(suggestions, item, bslMetadata[itemName]['metadata']);
|
||||
}
|
||||
}
|
||||
else if (itemName == 'universalObjects' && this.objectHasProperties(bslGlobals, itemName, subItemName)) {
|
||||
this.getUniversalObjectSuggestions(suggestions, bslGlobals[itemName][subItemName], parentRef);
|
||||
@ -1749,6 +1754,124 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the suggestions for objects from bslGlobals
|
||||
* like classes or types
|
||||
*
|
||||
* @param {array} suggestions the list of suggestions
|
||||
* @param {object} obj object from BSL-JSON dictionary
|
||||
*/
|
||||
getItemMedatadaSuggestions(suggestions, item, metadata) {
|
||||
|
||||
if (metadata.hasOwnProperty('methods')) {
|
||||
|
||||
for (const [mkey, mvalue] of Object.entries(metadata.methods)) {
|
||||
|
||||
let description = mvalue.hasOwnProperty('returns') ? mvalue.returns : '';
|
||||
let signatures = this.getMethodsSignature(mvalue);
|
||||
let command = null;
|
||||
let postfix = '';
|
||||
let post_action = null;
|
||||
|
||||
if (signatures.length) {
|
||||
postfix = '(';
|
||||
post_action = 'editor.action.triggerParameterHints';
|
||||
}
|
||||
|
||||
if (signatures.length == 0 || (signatures.length == 1 && signatures[0].parameters.length == 0))
|
||||
postfix = '()';
|
||||
|
||||
let ref = null;
|
||||
if (mvalue.hasOwnProperty('ref'))
|
||||
ref = mvalue.ref;
|
||||
|
||||
if (ref || signatures.length) {
|
||||
// If the attribute contains a ref, we need to run the command to save the position of ref
|
||||
command = {
|
||||
id: 'vs.editor.ICodeEditor:1:saveref',
|
||||
arguments: [
|
||||
{
|
||||
"name": mvalue[this.nameField],
|
||||
"data": {
|
||||
"ref": ref,
|
||||
"sig": signatures
|
||||
},
|
||||
"post_action": post_action
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
suggestions.push({
|
||||
label: mvalue[this.nameField],
|
||||
kind: monaco.languages.CompletionItemKind.Method,
|
||||
insertText: mvalue[this.nameField] + postfix,
|
||||
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
||||
detail: mvalue.description,
|
||||
documentation: description,
|
||||
command: command
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (metadata.hasOwnProperty('properties')) {
|
||||
|
||||
for (const [pkey, pvalue] of Object.entries(metadata.properties)) {
|
||||
|
||||
let command = null;
|
||||
let ref = null;
|
||||
let list = [];
|
||||
|
||||
if (pvalue.hasOwnProperty('ref'))
|
||||
ref = pvalue.ref;
|
||||
|
||||
if (pvalue.hasOwnProperty('list') && item) {
|
||||
let list_name = pvalue.list;
|
||||
if (item.child.hasOwnProperty(list_name)) {
|
||||
for (const [lkey, lvalue] of Object.entries(item.child[list_name])) {
|
||||
list.push({
|
||||
name: lkey,
|
||||
ref: '',
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (ref || list) {
|
||||
command = {
|
||||
id: 'vs.editor.ICodeEditor:1:saveref',
|
||||
arguments: [
|
||||
{
|
||||
"name": pvalue[this.nameField],
|
||||
"data": {
|
||||
"ref": ref,
|
||||
"sig": null,
|
||||
"list": list
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
suggestions.push({
|
||||
label: pvalue[this.nameField],
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
insertText: pvalue[this.nameField],
|
||||
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
||||
detail: pvalue.description,
|
||||
documentation: '',
|
||||
command: command
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the suggestions for objects from bslGlobals
|
||||
* like classes or types
|
||||
@ -2499,6 +2622,47 @@ class bslHelper {
|
||||
|
||||
}
|
||||
|
||||
fillSuggestionsForMetadataItems(suggestions, metadataObject, metadataName, ref) {
|
||||
|
||||
if (Object.keys(metadataObject.items).length) {
|
||||
|
||||
for (const [ikey, ivalue] of Object.entries(metadataObject.items)) {
|
||||
|
||||
let command = null;
|
||||
|
||||
if (ref) {
|
||||
command = {
|
||||
id: 'vs.editor.ICodeEditor:1:saveref',
|
||||
arguments: [
|
||||
{
|
||||
"name": ikey,
|
||||
"data": {
|
||||
"ref": ref + '.' + ikey,
|
||||
"sig": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
suggestions.push({
|
||||
label: ikey,
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
insertText: ikey,
|
||||
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
||||
detail: '',
|
||||
documentation: '',
|
||||
command: command
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
requestMetadata(metadataName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills array of completion for metadata item like Catalogs,
|
||||
* Documents, InformationRegisters, etc.
|
||||
@ -2593,25 +2757,8 @@ class bslHelper {
|
||||
|
||||
} else {
|
||||
|
||||
this.getMetadataMethods(suggestions, value, 'managerMethods', '', '');
|
||||
|
||||
if (Object.keys(value.items).length) {
|
||||
|
||||
for (const [ikey, ivalue] of Object.entries(value.items)) {
|
||||
values.push({
|
||||
name: ikey,
|
||||
detail: '',
|
||||
description: '',
|
||||
postfix: '',
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
command: null
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
requestMetadata(metadataName);
|
||||
}
|
||||
this.getMetadataMethods(suggestions, value, 'managerMethods', '', '');
|
||||
this.fillSuggestionsForMetadataItems(suggestions, value, metadataName);
|
||||
|
||||
}
|
||||
|
||||
@ -5228,12 +5375,15 @@ class bslHelper {
|
||||
|
||||
if (value.hasOwnProperty(this.nameField)) {
|
||||
|
||||
if (value[this.nameField].toLowerCase() == metadataName) {
|
||||
if (value.name.toLowerCase() == metadataName || value.name_en.toLowerCase() == metadataName) {
|
||||
|
||||
for (const [ikey, ivalue] of Object.entries(value.items)) {
|
||||
|
||||
if (ikey.toLowerCase() == metadataItem) {
|
||||
return value;
|
||||
if (ikey.toLowerCase() == metadataItem.toLowerCase()) {
|
||||
return {
|
||||
node: value,
|
||||
child: ivalue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -5290,9 +5440,9 @@ class bslHelper {
|
||||
|
||||
let item = this.getMetadataItemByName(data, metadataName, metadataItem);
|
||||
|
||||
if (item && item.hasOwnProperty('objMethods')) {
|
||||
if (item && item.node.hasOwnProperty('objMethods')) {
|
||||
|
||||
for (const [mkey, mvalue] of Object.entries(item.objMethods)) {
|
||||
for (const [mkey, mvalue] of Object.entries(item.node.objMethods)) {
|
||||
|
||||
if (mvalue[this.nameField].toLowerCase() == metadataFunc) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user