Skip to content

Commit ce57395

Browse files
committed
sq fix
1 parent 3ee222b commit ce57395

File tree

4 files changed

+60
-35
lines changed

4 files changed

+60
-35
lines changed

src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDCReaderContext.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import com.github._1c_syntax.bsl.mdo.MD;
2525
import com.github._1c_syntax.bsl.mdo.Module;
26-
import com.github._1c_syntax.bsl.mdo.ModuleOwner;
2726
import com.github._1c_syntax.bsl.mdo.children.ObjectModule;
2827
import com.github._1c_syntax.bsl.reader.MDOReader;
2928
import com.github._1c_syntax.bsl.reader.common.TransformationUtils;
@@ -55,8 +54,12 @@
5554
public class MDCReaderContext implements ReaderContext {
5655

5756
private static final String UUID_FIELD_NAME = "uuid";
57+
private static final String MDO_REFERENCE_FIELD_NAME = "mdoReference";
5858
private static final String SUPPORT_VALIANT_FIELD_NAME = "SupportVariant";
5959
private static final String CHILD_FILED_NAME = "child";
60+
private static final String COMPATIBILITY_MODE_FILED_NAME = "compatibilityMode";
61+
private static final String CONFIGURATION_SOURCE_MODE_FILED_NAME = "configurationSource";
62+
private static final String MODULES_FIELD_NAME = "modules";
6063

6164
/**
6265
* Класс будущего объекта
@@ -131,22 +134,19 @@ public MDCReaderContext(@NonNull Class<?> clazz, @NonNull HierarchicalStreamRead
131134
@Override
132135
public Object build() {
133136
var mdoReference = MdoReference.create(mdoType, name);
134-
setValue("mdoReference", mdoReference);
137+
setValue(MDO_REFERENCE_FIELD_NAME, mdoReference);
135138

136139
if (compatibilityMode == null) {
137-
setValue("compatibilityMode", configurationExtensionCompatibilityMode);
140+
setValue(COMPATIBILITY_MODE_FILED_NAME, configurationExtensionCompatibilityMode);
138141
}
139142

140143
if (isDesignerFormat) {
141-
setValue("configurationSource", ConfigurationSource.DESIGNER);
144+
setValue(CONFIGURATION_SOURCE_MODE_FILED_NAME, ConfigurationSource.DESIGNER);
142145
} else {
143-
setValue("configurationSource", ConfigurationSource.EDT);
144-
}
145-
146-
if (ModuleOwner.class.isAssignableFrom(realClass)) {
147-
setValueModules(mdoReference);
146+
setValue(CONFIGURATION_SOURCE_MODE_FILED_NAME, ConfigurationSource.EDT);
148147
}
149148

149+
setValueModules(mdoReference);
150150
setValueChildren();
151151

152152
return TransformationUtils.build(builder);
@@ -175,36 +175,19 @@ private void setValueChildren() {
175175
}
176176

177177
private void setValueModules(MdoReference mdoReference) {
178-
var moduleTypes = ModuleType.byMDOType(mdoType);
179-
if (moduleTypes.isEmpty()) {
178+
var folder = getModuleFolder();
179+
if (!folder.toFile().exists()) {
180180
return;
181181
}
182182

183-
// todo переделать
184-
Path folder;
185-
if (isDesignerFormat) {
186-
folder = DesignerPaths.moduleFolder(currentPath, mdoType);
187-
} else {
188-
folder = EDTPaths.moduleFolder(currentPath, mdoType);
189-
}
190-
191-
if (!folder.toFile().exists()) {
183+
var moduleTypes = ModuleType.byMDOType(mdoType);
184+
if (moduleTypes.isEmpty()) {
192185
return;
193186
}
194187

195188
List<Module> modules = new ArrayList<>();
196189
moduleTypes.forEach((ModuleType moduleType) -> {
197-
Path modulePath;
198-
// todo переделать
199-
if (isDesignerFormat) {
200-
modulePath = DesignerPaths.modulePath(folder, name, moduleType);
201-
} else if (mdoType == MDOType.CONFIGURATION) {
202-
modulePath = EDTPaths.modulePath(folder, MDOType.CONFIGURATION.getName(), moduleType);
203-
} else {
204-
modulePath = EDTPaths.modulePath(folder, name, moduleType);
205-
}
206-
207-
var protectedModuleInfo = new ProtectedModuleInfo(modulePath);
190+
var protectedModuleInfo = getModuleInfo(folder, moduleType);
208191
if (protectedModuleInfo.getModulePath().toFile().exists()) {
209192
modules.add(ObjectModule.builder()
210193
.moduleType(moduleType)
@@ -216,7 +199,24 @@ private void setValueModules(MdoReference mdoReference) {
216199
}
217200
}
218201
);
219-
setValue("modules", modules);
202+
setValue(MODULES_FIELD_NAME, modules);
220203
}
221204

205+
private Path getModuleFolder() {
206+
if (isDesignerFormat) {
207+
return DesignerPaths.moduleFolder(currentPath, mdoType);
208+
} else {
209+
return EDTPaths.moduleFolder(currentPath, mdoType);
210+
}
211+
}
212+
213+
private ProtectedModuleInfo getModuleInfo(Path folder, ModuleType moduleType) {
214+
Path modulePath;
215+
if (isDesignerFormat) {
216+
modulePath = DesignerPaths.modulePath(folder, name, moduleType);
217+
} else {
218+
modulePath = EDTPaths.modulePath(folder, MDOType.CONFIGURATION.getName(), moduleType);
219+
}
220+
return new ProtectedModuleInfo(modulePath);
221+
}
222222
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2023
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
/**
23+
* Контексты, используемые при чтении файлов
24+
*/
25+
package com.github._1c_syntax.bsl.reader.common.context;

src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/Unmarshaller.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ private void readNode(String name, UnmarshallingContext context, ReaderContext r
114114
private Object transformMultiLanguageString(ReaderContext readerContext, String name, Object value) {
115115
var newVal = value;
116116
if (readerContext.getLastName().equals(name)
117-
&& readerContext.getLastValue() instanceof MultiLanguageString && value instanceof MultiLanguageString) {
118-
newVal = new MultiLanguageString((MultiLanguageString) readerContext.getLastValue(), (MultiLanguageString) value);
117+
&& readerContext.getLastValue() instanceof MultiLanguageString lastValue
118+
&& value instanceof MultiLanguageString newValue) {
119+
newVal = new MultiLanguageString(lastValue, newValue);
119120
}
120121
readerContext.setLastName(name);
121122
readerContext.setLastValue(newVal);

src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/XDTOPackageConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import com.github._1c_syntax.bsl.mdo.XDTOPackage;
2525
import com.github._1c_syntax.bsl.mdo.storage.XdtoPackageData;
26-
import com.github._1c_syntax.bsl.reader.common.TransformationUtils;
2726
import com.github._1c_syntax.bsl.reader.common.converter.AbstractReadConverter;
2827
import com.github._1c_syntax.bsl.reader.edt.EDTPaths;
2928
import com.thoughtworks.xstream.converters.UnmarshallingContext;

0 commit comments

Comments
 (0)