22
22
package com .github ._1c_syntax .bsl .languageserver .utils ;
23
23
24
24
import com .github ._1c_syntax .bsl .languageserver .context .DocumentContext ;
25
+ import com .github ._1c_syntax .bsl .mdo .MD ;
26
+ import com .github ._1c_syntax .bsl .mdo .support .ScriptVariant ;
25
27
import com .github ._1c_syntax .bsl .parser .BSLParser ;
26
28
import com .github ._1c_syntax .bsl .types .MDOType ;
27
29
import com .github ._1c_syntax .bsl .types .MdoReference ;
@@ -68,7 +70,7 @@ public String getMdoRef(DocumentContext documentContext, BSLParser.ComplexIdenti
68
70
public String getMdoRef (
69
71
DocumentContext documentContext ,
70
72
@ Nullable
71
- TerminalNode identifier ,
73
+ TerminalNode identifier ,
72
74
List <? extends BSLParser .ModifierContext > modifiers
73
75
) {
74
76
@@ -91,6 +93,39 @@ public String getMdoRef(
91
93
return stringInterner .intern (mdoRef .get ());
92
94
}
93
95
96
+ /**
97
+ * Получить mdoRef в языке конфигурации
98
+ *
99
+ * @param documentContext the document context
100
+ * @param mdo the mdo
101
+ * @return the locale mdoRef
102
+ */
103
+ public String getLocaleMdoRef (DocumentContext documentContext , MD mdo ) {
104
+ final var mdoReference = mdo .getMdoReference ();
105
+ final String result ;
106
+ if (documentContext .getServerContext ().getConfiguration ().getScriptVariant () == ScriptVariant .ENGLISH ) {
107
+ result = mdoReference .getMdoRef ();
108
+ } else {
109
+ result = mdoReference .getMdoRefRu ();
110
+ }
111
+ return stringInterner .intern (result );
112
+ }
113
+
114
+ /**
115
+ * Получить имя родителя метаданного в языке конфигурации.
116
+ *
117
+ * @param documentContext the document context
118
+ * @param mdo the mdo
119
+ * @return the locale owner mdo name
120
+ */
121
+ public String getLocaleOwnerMdoName (DocumentContext documentContext , MD mdo ) {
122
+ final var names = getLocaleMdoRef (documentContext , mdo ).split ("\\ ." );
123
+ if (names .length <= 1 ) {
124
+ return "" ;
125
+ }
126
+ return stringInterner .intern (names [0 ].concat ("." ).concat (names [1 ]));
127
+ }
128
+
94
129
private Optional <String > getCommonModuleMdoRef (DocumentContext documentContext , String commonModuleName ) {
95
130
return documentContext .getServerContext ()
96
131
.getConfiguration ()
0 commit comments