Skip to content

Commit d6c7600

Browse files
committed
Небольшая оптимизация чтения для формата конфигуратора при определении защищенности файла
1 parent e69b628 commit d6c7600

File tree

5 files changed

+94
-94
lines changed

5 files changed

+94
-94
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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-
package com.github._1c_syntax.bsl.reader.common.context;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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+
package com.github._1c_syntax.bsl.reader.common.context;
2323

2424
import com.github._1c_syntax.bsl.mdo.MD;
2525
import com.github._1c_syntax.bsl.mdo.Module;
@@ -217,6 +217,6 @@ private ProtectedModuleInfo getModuleInfo(Path folder, ModuleType moduleType) {
217217
} else {
218218
modulePath = EDTPaths.modulePath(folder, MDOType.CONFIGURATION.getName(), moduleType);
219219
}
220-
return new ProtectedModuleInfo(modulePath);
220+
return new ProtectedModuleInfo(modulePath, isDesignerFormat);
221221
}
222222
}

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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-
package com.github._1c_syntax.bsl.reader.common.context;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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+
package com.github._1c_syntax.bsl.reader.common.context;
2323

2424
import com.github._1c_syntax.bsl.mdo.ChildrenOwner;
2525
import com.github._1c_syntax.bsl.mdo.Form;
@@ -278,6 +278,6 @@ private ProtectedModuleInfo getModuleInfo(Path folder, ModuleType moduleType) {
278278
} else {
279279
modulePath = EDTPaths.modulePath(folder, name, moduleType);
280280
}
281-
return new ProtectedModuleInfo(modulePath);
281+
return new ProtectedModuleInfo(modulePath, isDesignerFormat);
282282
}
283283
}

src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/CommonModuleConverter.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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-
package com.github._1c_syntax.bsl.reader.common.converter;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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+
package com.github._1c_syntax.bsl.reader.common.converter;
2323

2424
import com.github._1c_syntax.bsl.mdo.CommonModule;
2525
import com.github._1c_syntax.bsl.reader.designer.DesignerPaths;
@@ -54,7 +54,7 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
5454
ModuleType.CommonModule
5555
);
5656
}
57-
var protectedModuleInfo = new ProtectedModuleInfo(modulePath);
57+
var protectedModuleInfo = new ProtectedModuleInfo(modulePath, readerContext.isDesignerFormat());
5858
readerContext.setValue(URI_FIELD_NAME, protectedModuleInfo.getModulePath().toUri());
5959
readerContext.setValue(IS_PROTECTED_FIELD_NAME, protectedModuleInfo.isProtected());
6060
return readerContext.build();

src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/ProtectedModuleInfo.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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-
package com.github._1c_syntax.bsl.reader.common.converter;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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+
package com.github._1c_syntax.bsl.reader.common.converter;
2323

2424
import lombok.Getter;
2525
import org.apache.commons.io.FilenameUtils;
@@ -48,7 +48,7 @@ public class ProtectedModuleInfo {
4848
*/
4949
private Path modulePath;
5050

51-
public ProtectedModuleInfo(Path path) {
51+
public ProtectedModuleInfo(Path path, boolean onlyFindBin) {
5252
modulePath = path;
5353
isProtected = false;
5454

@@ -58,7 +58,7 @@ public ProtectedModuleInfo(Path path) {
5858
isProtected = true;
5959
modulePath = prtModulePath;
6060
}
61-
} else {
61+
} else if (!onlyFindBin) { // нет смысла читать файлы, если ищем только bin
6262
var bytes = new byte[PROTECTED_FILE_HEADER.length];
6363
try (var fis = new FileInputStream(modulePath.toFile())) {
6464
isProtected = (fis.read(bytes) == PROTECTED_FILE_HEADER.length

src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/FormElementConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
4343
try {
4444
readerContext.setValue("id", Integer.parseInt(reader.getAttribute("id")));
4545
} catch (NumberFormatException e) {
46-
LOGGER.error("Unknown type {} in file {}", reader.getNodeName(), ExtendXStream.getCurrentPath(reader).toString());
46+
LOGGER.warn("Unknown type {} in file {}", reader.getNodeName(), ExtendXStream.getCurrentPath(reader).toString());
4747
return null;
4848
}
4949
readerContext.setValue("type", reader.getNodeName());

0 commit comments

Comments
 (0)