diff --git a/benchmark-compare.sh b/benchmark-compare.sh index 4625b77fc..67cfe9f14 100644 --- a/benchmark-compare.sh +++ b/benchmark-compare.sh @@ -19,6 +19,7 @@ BUILD_DIR="build/libs" echo "πŸ”¨ Начало сравнСния ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΠΈ MDClasses" echo "================================================" +rm -rf "$RESULTS_DIR" mkdir -p $RESULTS_DIR # Ѐункция для ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ являСтся Π»ΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ JAR Ρ„Π°ΠΉΠ» diff --git a/src/jmh/java/com/github/_1c_syntax/bsl/mdclasses/benchmark/MDClassesBenchmark.java b/src/jmh/java/com/github/_1c_syntax/bsl/mdclasses/benchmark/MDClassesBenchmark.java index a0609b410..f50d1d1cc 100644 --- a/src/jmh/java/com/github/_1c_syntax/bsl/mdclasses/benchmark/MDClassesBenchmark.java +++ b/src/jmh/java/com/github/_1c_syntax/bsl/mdclasses/benchmark/MDClassesBenchmark.java @@ -21,18 +21,17 @@ */ package com.github._1c_syntax.bsl.mdclasses.benchmark; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClasses; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; @@ -49,35 +48,42 @@ public class MDClassesBenchmark { private final Path configPathEDT = Path.of("src/test/resources/ext/edt/ssl_3_1/configuration"); private final Path configPathDesigner = Path.of("src/test/resources/ext/designer/ssl_3_1/src/cf"); + private static final MDCReadSettings SKIP_ALL = MDCReadSettings.builder() + .skipSupport(true) + .skipRoleData(true) + .skipFormElementItems(true) + .skipXdtoPackage(true) + .skipDataCompositionSchema(true) + .build(); @Setup public void setup() { // ΠŸΡ€Π΅Π΄Π²Π°Ρ€ΠΈΡ‚Π΅Π»ΡŒΠ½Π°Ρ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° для Ρ€Π°Π·ΠΎΠ³Ρ€Π΅Π²Π° - MDClasses.createConfiguration(configPathEDT, false); - MDClasses.createConfiguration(configPathDesigner, false); + MDClasses.createConfiguration(configPathEDT); + MDClasses.createConfiguration(configPathDesigner); } @Benchmark public void test_EDT_CreateConfiguration_SkipSupport_False(Blackhole blackhole) { - var model = MDClasses.createConfiguration(configPathEDT, false); + var model = MDClasses.createConfiguration(configPathEDT); blackhole.consume(model); } @Benchmark public void test_EDT_CreateConfiguration_SkipSupport_True(Blackhole blackhole) { - var model = MDClasses.createConfiguration(configPathEDT, true); + var model = MDClasses.createConfiguration(configPathEDT, SKIP_ALL); blackhole.consume(model); } @Benchmark public void test_Designer_CreateConfiguration_SkipSupport_False(Blackhole blackhole) { - var model = MDClasses.createConfiguration(configPathDesigner, false); + var model = MDClasses.createConfiguration(configPathDesigner); blackhole.consume(model); } @Benchmark public void test_Designer_CreateConfiguration_SkipSupport_True(Blackhole blackhole) { - var model = MDClasses.createConfiguration(configPathDesigner, true); + var model = MDClasses.createConfiguration(configPathDesigner, SKIP_ALL); blackhole.consume(model); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDCReadSettings.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDCReadSettings.java new file mode 100644 index 000000000..f8e82b685 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDCReadSettings.java @@ -0,0 +1,68 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2025 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdclasses; + +import lombok.Builder; +import lombok.Value; + +/** + * Настройки чтСния MDC + */ +@Value +@Builder +public class MDCReadSettings { + /** + * Настройки ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ + */ + public static final MDCReadSettings DEFAULT = MDCReadSettings.builder().build(); + + /** + * Π¨Π°Π±Π»ΠΎΠ½ с ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ΠΌ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ чтСния ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΈ + */ + public static final MDCReadSettings SKIP_SUPPORT = MDCReadSettings.builder().skipSupport(true).build(); + + /** + * ΠŸΡ€ΠΎΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ настроСк поставки ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ + */ + boolean skipSupport; + + /** + * ΠŸΡ€ΠΎΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ содСрТимого Ρ€ΠΎΠ»Π΅ΠΉ + */ + boolean skipRoleData; + + /** + * ΠŸΡ€ΠΎΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ содСрТимого xdto ΠΏΠ°ΠΊΠ΅Ρ‚ΠΎΠ² + */ + boolean skipXdtoPackage; + + /** + * ΠŸΡ€ΠΎΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ элСмСнтов Ρ„ΠΎΡ€ΠΌ + */ + boolean skipFormElementItems; + + /** + * ΠŸΡ€ΠΎΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ элСмСнтов ΠΌΠ°ΠΊΠ΅Ρ‚ΠΎΠ² систСмы ΠΊΠΎΠΌΠΏΠΎΠ½ΠΎΠ²ΠΊΠΈ + */ + boolean skipDataCompositionSchema; + +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java index 70ecdc3d9..09af8c274 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java @@ -72,18 +72,30 @@ public ExternalSource createExternalReport() { * @return ΠšΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ */ public MDClass createConfiguration(Path path) { - return createConfiguration(path, false); + return createConfiguration(path, MDCReadSettings.DEFAULT); } /** * Π‘ΠΎΠ·Π΄Π°Π΅Ρ‚ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡŽ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ ΠΏΠΎ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΌΡƒ ΠΏΡƒΡ‚ΠΈ * + * @param path ΠŸΡƒΡ‚ΡŒ ΠΊ ΠΊΠΎΡ€Π½ΡŽ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° + * @param readSettings Настройки чтСния + * @return ΠšΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ + */ + public MDClass createConfiguration(Path path, MDCReadSettings readSettings) { + return MDOReader.readConfiguration(path, readSettings); + } + + /** * @param path ΠŸΡƒΡ‚ΡŒ ΠΊ ΠΊΠΎΡ€Π½ΡŽ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° * @param skipSupport Π€Π»Π°Π³ управлСния Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ΠΌ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΎ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ΅ * @return ΠšΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ + * @deprecated Π‘Ρ‚ΠΎΠΈΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ с ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ MDCReadSettings. + * Π‘ΠΎΠ·Π΄Π°Π΅Ρ‚ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡŽ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ ΠΏΠΎ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΌΡƒ ΠΏΡƒΡ‚ΠΈ */ + @Deprecated(since = "0.16.0") public MDClass createConfiguration(Path path, boolean skipSupport) { - return MDOReader.readConfiguration(path, skipSupport); + return createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build()); } /** @@ -103,7 +115,7 @@ public MDClass createExternalSource(Path mdoPath) { * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΉ ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠΉ */ public List createConfigurations(Path sourcePath) { - return createConfigurations(sourcePath, false); + return createConfigurations(sourcePath, MDCReadSettings.DEFAULT); } /** @@ -112,10 +124,25 @@ public List createConfigurations(Path sourcePath) { * @param sourcePath ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² * @param skipSupport Π€Π»Π°Π³ управлСния Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ΠΌ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΎ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ΅ * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΉ ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠΉ + * @deprecated Π‘Ρ‚ΠΎΠΈΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ с ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ MDCReadSettings. */ + @Deprecated(since = "0.16.0") public List createConfigurations(Path sourcePath, boolean skipSupport) { return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream() - .map(path -> createConfiguration(path, skipSupport)) + .map(path -> createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build())) + .toList(); + } + + /** + * Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ список ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΉ\Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠΉ Π² ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π΅ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * + * @param sourcePath ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * @param readSettings Настройки чтСния + * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΉ ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠΉ + */ + public List createConfigurations(Path sourcePath, MDCReadSettings readSettings) { + return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream() + .map(path -> createConfiguration(path, readSettings)) .toList(); } @@ -126,8 +153,19 @@ public List createConfigurations(Path sourcePath, boolean skipSupport) * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² Π²Π½Π΅ΡˆΠ½ΠΈΡ… ΠΎΡ‚Ρ‡Π΅Ρ‚ΠΎΠ² ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΎΠΊ */ public List createExternalSources(Path sourcePath) { + return createExternalSources(sourcePath, MDCReadSettings.DEFAULT); + } + + /** + * Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ список Π²Π½Π΅ΡˆΠ½ΠΈΡ… ΠΎΡ‚Ρ‡Π΅Ρ‚ΠΎΠ² ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΎΠΊ Π² ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π΅ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * + * @param sourcePath ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * @param readSettings Настройки чтСния + * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² Π²Π½Π΅ΡˆΠ½ΠΈΡ… ΠΎΡ‚Ρ‡Π΅Ρ‚ΠΎΠ² ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΎΠΊ + */ + public List createExternalSources(Path sourcePath, MDCReadSettings readSettings) { return findFiles(sourcePath, SEARCH_EX_RES).parallelStream() - .map(MDOReader::readExternalSource) + .map(mdoPath -> MDOReader.readExternalSource(mdoPath, readSettings)) .toList(); } @@ -138,7 +176,7 @@ public List createExternalSources(Path sourcePath) { * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² */ public List create(Path sourcePath) { - return create(sourcePath, false); + return create(sourcePath, MDCReadSettings.DEFAULT); } /** @@ -147,10 +185,23 @@ public List create(Path sourcePath) { * @param sourcePath ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² * @param skipSupport Π€Π»Π°Π³ управлСния Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ΠΌ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΎ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ΅ * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² + * @deprecated Π‘Ρ‚ΠΎΠΈΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ с ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ MDCReadSettings. */ + @Deprecated(since = "0.16.0") public List create(Path sourcePath, boolean skipSupport) { - var result = new ArrayList<>(createConfigurations(sourcePath, skipSupport)); - result.addAll(createExternalSources(sourcePath)); + return create(sourcePath, MDCReadSettings.builder().skipSupport(skipSupport).build()); + } + + /** + * Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ список ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… Π² ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π΅ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * + * @param sourcePath ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ исходных Ρ„Π°ΠΉΠ»ΠΎΠ² + * @param readSettings Настройки чтСния + * @return Бписок ΠΏΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ² + */ + public List create(Path sourcePath, MDCReadSettings readSettings) { + var result = new ArrayList<>(createConfigurations(sourcePath, readSettings)); + result.addAll(createExternalSources(sourcePath, readSettings)); return result; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/storage/DataCompositionSchema.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/storage/DataCompositionSchema.java index 23ab5d9da..6ec96ef84 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/storage/DataCompositionSchema.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/storage/DataCompositionSchema.java @@ -1,27 +1,28 @@ -/* - * This file is a part of MDClasses. - * - * Copyright (c) 2019 - 2025 - * Tymko Oleg , Maximov Valery and contributors - * - * SPDX-License-Identifier: LGPL-3.0-or-later - * - * MDClasses is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * MDClasses is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with MDClasses. - */ -package com.github._1c_syntax.bsl.mdo.storage; +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2025 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdo.storage; import com.github._1c_syntax.bsl.mdo.support.DataSetType; +import com.github._1c_syntax.utils.Lazy; import lombok.Builder; import lombok.Builder.Default; import lombok.EqualsAndHashCode; @@ -49,7 +50,7 @@ public class DataCompositionSchema implements TemplateData { /** * Плоский список Π½Π°Π±ΠΎΡ€ΠΎΠ² Π΄Π°Π½Π½Ρ‹Ρ… */ - List plainDataSets; + Lazy> plainDataSets = new Lazy<>(this::computePlainDataSets); /** * ΠŸΡƒΡ‚ΡŒ ΠΊ Ρ„Π°ΠΉΠ»Ρƒ с Π΄Π°Π½Π½Ρ‹ΠΌΠΈ ΠΌΠ°ΠΊΠ΅Ρ‚Π° @@ -59,8 +60,6 @@ public class DataCompositionSchema implements TemplateData { public DataCompositionSchema(@NonNull List dataSetsTree, @NonNull Path path) { dataSets = dataSetsTree; - plainDataSets = new ArrayList<>(); - fillPlaintDataSetByList(dataSetsTree); dataPath = path; } @@ -69,10 +68,21 @@ public boolean isEmpty() { return false; } - private void fillPlaintDataSetByList(List items) { + public List getPlainDataSets() { + return plainDataSets.getOrCompute(); + } + + private List computePlainDataSets() { + List result = new ArrayList<>(); + fillPlainDataSetByList(result, dataSets); + + return result; + } + + private static void fillPlainDataSetByList(List result, List items) { items.forEach((DataSet dataSet) -> { - plainDataSets.add(dataSet); - fillPlaintDataSetByList(dataSet.getItems()); + result.add(dataSet); + fillPlainDataSetByList(result, dataSet.getItems()); }); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java index 346edb53e..04221ab56 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdclasses.ExternalReport; import com.github._1c_syntax.bsl.mdclasses.ExternalSource; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdo.MDObject; import com.github._1c_syntax.bsl.mdo.storage.EmptyFormData; @@ -69,6 +70,12 @@ public Path getRootPath() { return Path.of("fake-path"); } + @Override + @NonNull + public MDCReadSettings getReadSettings() { + return MDCReadSettings.DEFAULT; + } + @Override @Nullable public MDObject read(Path path) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/MDOReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/MDOReader.java index 4c2b479b5..90a64aaee 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/MDOReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/MDOReader.java @@ -21,6 +21,7 @@ */ package com.github._1c_syntax.bsl.reader; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.reader.designer.DesignerReader; import com.github._1c_syntax.bsl.reader.edt.EDTReader; @@ -49,7 +50,7 @@ public class MDOReader { * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (конфигурация) */ public MDClass readConfiguration(@NonNull Path rootPath) { - return readConfiguration(rootPath, false); + return readConfiguration(rootPath, MDCReadSettings.DEFAULT); } /** @@ -58,9 +59,22 @@ public MDClass readConfiguration(@NonNull Path rootPath) { * @param rootPath ΠšΠ°Ρ‚Π°Π»ΠΎΠ³ исходников * @param skipSupport Π€Π»Π°Π³ управлСния Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎΡΡ‚ΡŒΡŽ Ρ‡ΠΈΡ‚Π°Ρ‚ΡŒ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ΅ * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (конфигурация) + * @deprecated Π‘Ρ‚ΠΎΠΈΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ с ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ MDCReadSettings. */ + @Deprecated(since = "0.16.0") public MDClass readConfiguration(@NonNull Path rootPath, boolean skipSupport) { - return createReader(rootPath, skipSupport, MDOType.CONFIGURATION).readConfiguration(); + return readConfiguration(rootPath, MDCReadSettings.builder().skipSupport(skipSupport).build()); + } + + /** + * ΠŸΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Π° ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ) ΠΏΠΎ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Ρƒ исходников + * + * @param rootPath ΠšΠ°Ρ‚Π°Π»ΠΎΠ³ исходников + * @param readSettings Настройки чтСния + * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (конфигурация) + */ + public MDClass readConfiguration(@NonNull Path rootPath, @NonNull MDCReadSettings readSettings) { + return createReader(rootPath, readSettings, MDOType.CONFIGURATION).readConfiguration(); } /** @@ -70,7 +84,7 @@ public MDClass readConfiguration(@NonNull Path rootPath, boolean skipSupport) { * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… */ public Object read(@NonNull Path folder, @NonNull String fullName) { - return read(folder, fullName, false); + return read(folder, fullName, MDCReadSettings.DEFAULT); } /** @@ -79,9 +93,22 @@ public Object read(@NonNull Path folder, @NonNull String fullName) { * @param folder ΠšΠ°Ρ‚Π°Π»ΠΎΠ³ исходников * @param skipSupport Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ΠΌ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΈ * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… + * @deprecated Π‘Ρ‚ΠΎΠΈΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ с ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ MDCReadSettings. */ + @Deprecated(since = "0.16.0") public Object read(@NonNull Path folder, @NonNull String fullName, boolean skipSupport) { - var reader = createReader(folder, skipSupport, MDOType.UNKNOWN); + return read(folder, fullName, MDCReadSettings.builder().skipSupport(skipSupport).build()); + } + + /** + * ΠŸΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠ³ΠΎ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… ΠΈΠ»ΠΈ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Π° + * + * @param folder ΠšΠ°Ρ‚Π°Π»ΠΎΠ³ исходников + * @param readSettings Настройки чтСния + * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… + */ + public Object read(@NonNull Path folder, @NonNull String fullName, MDCReadSettings readSettings) { + var reader = createReader(folder, readSettings, MDOType.UNKNOWN); if (folder.toFile().isFile()) { return reader.read(fullName); } else { @@ -96,22 +123,33 @@ public Object read(@NonNull Path folder, @NonNull String fullName, boolean skipS * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (внСшний ΠΎΡ‚Ρ‡Π΅Ρ‚ ΠΈΠ»ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠ°) */ public MDClass readExternalSource(@NonNull Path mdoPath) { - return createReader(mdoPath, true, MDOType.EXTERNAL_REPORT).readExternalSource(); + return readExternalSource(mdoPath, MDCReadSettings.SKIP_SUPPORT); + } + + /** + * ΠŸΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ внСшнСго ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Π° ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (внСшнСй ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ ΠΈΠ»ΠΈ ΠΎΡ‚Ρ‡Π΅Ρ‚Π°) ΠΏΠΎ Ρ„Π°ΠΉΠ»Ρƒ описания + * + * @param mdoPath ΠŸΡƒΡ‚ΡŒ ΠΊ Ρ„Π°ΠΉΠ»Ρƒ описания + * @param readSettings Настройки чтСния + * @return ΠŸΡ€ΠΎΡ‡ΠΈΡ‚Π°Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ… (внСшний ΠΎΡ‚Ρ‡Π΅Ρ‚ ΠΈΠ»ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠ°) + */ + public MDClass readExternalSource(@NonNull Path mdoPath, MDCReadSettings readSettings) { + return createReader(mdoPath, readSettings, MDOType.EXTERNAL_REPORT).readExternalSource(); } - private MDReader createReader(Path rootPath, boolean skipSupport, MDOType mdoType) { + private MDReader createReader(Path rootPath, MDCReadSettings readSettings, MDOType mdoType) { if (mdoType == MDOType.CONFIGURATION || mdoType == MDOType.UNKNOWN) { - return createReader(rootPath, skipSupport, getConfigurationSourceByPath(rootPath)); + return createReader(rootPath, readSettings, getConfigurationSourceByPath(rootPath)); } else { - return createReader(rootPath, skipSupport, getConfigurationSourceByPathSimple(rootPath)); + return createReader(rootPath, readSettings, getConfigurationSourceByPathSimple(rootPath)); } } - private MDReader createReader(Path rootPath, boolean skipSupport, ConfigurationSource configurationSource) { + private MDReader createReader(Path rootPath, MDCReadSettings readSettings, ConfigurationSource configurationSource) { if (configurationSource == ConfigurationSource.DESIGNER) { - return new DesignerReader(rootPath, skipSupport); + return new DesignerReader(rootPath, readSettings); } else if (configurationSource == ConfigurationSource.EDT) { - return new EDTReader(rootPath, skipSupport); + return new EDTReader(rootPath, readSettings); } else { return new FakeReader(); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java index 49d98d77f..066d17736 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java @@ -22,6 +22,7 @@ package com.github._1c_syntax.bsl.reader; import com.github._1c_syntax.bsl.mdclasses.ExternalSource; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdo.storage.FormData; import com.github._1c_syntax.bsl.reader.common.context.AbstractReaderContext; @@ -57,6 +58,13 @@ public interface MDReader { @NonNull Path getRootPath(); + /** + * Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ установлСнныС настройки чтСния + * @return Настройки чтСния + */ + @NonNull + MDCReadSettings getReadSettings(); + /** * ВыполняСт Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ * diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDCReaderContext.java b/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDCReaderContext.java index 3d87d6053..274ea05b9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDCReaderContext.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDCReaderContext.java @@ -25,6 +25,7 @@ import com.github._1c_syntax.bsl.reader.common.TransformationUtils; import com.github._1c_syntax.bsl.supconf.ParseSupportData; import com.github._1c_syntax.bsl.support.CompatibilityMode; +import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.MdoReference; import com.thoughtworks.xstream.io.HierarchicalStreamReader; @@ -77,7 +78,11 @@ public MDCReaderContext(@NonNull Class clazz, @NonNull HierarchicalStreamRead builder = TransformationUtils.builder(realClass); var uuid = reader.getAttribute(UUID_FIELD_NAME); - supportVariant = ParseSupportData.get(uuid, currentPath); + if (uuid != null && !mdReader.getReadSettings().isSkipSupport()) { + supportVariant = ParseSupportData.get(uuid, currentPath); + } else { + supportVariant = SupportVariant.NONE; + } mdoType = MDOType.CONFIGURATION; super.setValue(UUID_FIELD_NAME, uuid); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDReaderContext.java b/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDReaderContext.java index 4672da530..1b009afc1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDReaderContext.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/common/context/MDReaderContext.java @@ -94,7 +94,7 @@ public MDReaderContext(@NonNull HierarchicalStreamReader reader) { builder = TransformationUtils.builder(realClass); var uuid = reader.getAttribute(UUID_FIELD_NAME); - if (uuid != null) { + if (uuid != null && !mdReader.getReadSettings().isSkipSupport()) { supportVariant = ParseSupportData.get(uuid, currentPath); } else { supportVariant = SupportVariant.NONE; diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/DataCompositionSchemaConverter.java b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/DataCompositionSchemaConverter.java index 6e43031b6..82c22083c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/DataCompositionSchemaConverter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/DataCompositionSchemaConverter.java @@ -22,6 +22,7 @@ package com.github._1c_syntax.bsl.reader.common.converter; import com.github._1c_syntax.bsl.mdo.storage.DataCompositionSchema; +import com.github._1c_syntax.bsl.mdo.storage.EmptyTemplateData; import com.github._1c_syntax.bsl.reader.common.xstream.ExtendReaderWrapper; import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream; import com.github._1c_syntax.bsl.reader.common.xstream.ReadConverter; @@ -45,6 +46,10 @@ public class DataCompositionSchemaConverter implements ReadConverter { @SneakyThrows @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + if (ExtendXStream.getCurrentMDReader(reader).getReadSettings().isSkipDataCompositionSchema()) { + return EmptyTemplateData.getEmpty(); + } + List dataSets = new ArrayList<>(); // Π»ΠΈΠ½Π΅ΠΉΠ½ΠΎ Ρ‡ΠΈΡ‚Π°Π΅ΠΌ Ρ„Π°ΠΉΠ» diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/RoleDataConverter.java b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/RoleDataConverter.java index 71dd9251e..0fe820ed5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/RoleDataConverter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/RoleDataConverter.java @@ -1,25 +1,25 @@ -/* - * This file is a part of MDClasses. - * - * Copyright (c) 2019 - 2025 - * Tymko Oleg , Maximov Valery and contributors - * - * SPDX-License-Identifier: LGPL-3.0-or-later - * - * MDClasses is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * MDClasses is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with MDClasses. - */ -package com.github._1c_syntax.bsl.reader.common.converter; +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2025 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.reader.common.converter; import com.github._1c_syntax.bsl.mdo.storage.RoleData; import com.github._1c_syntax.bsl.reader.common.TransformationUtils; @@ -39,6 +39,9 @@ public class RoleDataConverter implements ReadConverter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + if (ExtendXStream.getCurrentMDReader(reader).getReadSettings().isSkipRoleData()) { + return RoleData.EMPTY; + } var builder = RoleData.builder(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/XdtoPackageDataConverter.java b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/XdtoPackageDataConverter.java index 75bfa2153..fbbe205d3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/XdtoPackageDataConverter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/XdtoPackageDataConverter.java @@ -1,27 +1,28 @@ -/* - * This file is a part of MDClasses. - * - * Copyright (c) 2019 - 2025 - * Tymko Oleg , Maximov Valery and contributors - * - * SPDX-License-Identifier: LGPL-3.0-or-later - * - * MDClasses is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * MDClasses is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with MDClasses. - */ -package com.github._1c_syntax.bsl.reader.common.converter; +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2025 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.reader.common.converter; import com.github._1c_syntax.bsl.mdo.storage.XdtoPackageData; +import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream; import com.github._1c_syntax.bsl.reader.common.xstream.ReadConverter; import com.github._1c_syntax.utils.StringInterner; import com.thoughtworks.xstream.converters.UnmarshallingContext; @@ -57,6 +58,10 @@ public class XdtoPackageDataConverter implements ReadConverter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + if (ExtendXStream.getCurrentMDReader(reader).getReadSettings().isSkipXdtoPackage()) { + return XdtoPackageData.EMPTY; + } + var builder = XdtoPackageData.builder(); builder.targetNamespace(reader.getAttribute(TARGET_NAMESPACE_ATTRIBUTE_NAME)); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java index 14cc63a10..bc70301b6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdclasses.ExternalReport; import com.github._1c_syntax.bsl.mdclasses.ExternalSource; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdo.ExchangePlan; import com.github._1c_syntax.bsl.mdo.children.AccountingFlag; @@ -95,8 +96,11 @@ public class DesignerReader implements MDReader { @Getter private final Path rootPath; - public DesignerReader(Path path, boolean skipSupport) { - xstream = createXMLMapper(); + @Getter + private final MDCReadSettings readSettings; + + public DesignerReader(Path path, MDCReadSettings readSettings) { + this.xstream = createXMLMapper(); var normalizedPath = path.toAbsolutePath(); var file = normalizedPath.toFile(); if (file.isFile() && CONFIGURATION_MDO_FILE_NAME.equals(file.getName())) { // ΠΏΠ΅Ρ€Π΅Π΄Π°Π»ΠΈ сам Ρ„Π°ΠΉΠ», Π° Π½Π΅ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ @@ -105,11 +109,13 @@ public DesignerReader(Path path, boolean skipSupport) { throw new IllegalArgumentException( "НС ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ для Ρ„Π°ΠΉΠ»Π° " + normalizedPath); } - rootPath = parent; + this.rootPath = parent; } else { - rootPath = path; + this.rootPath = path; } - if (!skipSupport) { + this.readSettings = readSettings; + + if (!readSettings.isSkipSupport()) { var pcbin = parentConfigurationsPath(); if (pcbin.toFile().exists()) { ParseSupportData.read(pcbin); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/FormElementConverter.java b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/FormElementConverter.java index 67be7c5a1..edad762dc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/FormElementConverter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/FormElementConverter.java @@ -38,6 +38,10 @@ public class FormElementConverter implements ReadConverter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + if (ExtendXStream.getCurrentMDReader(reader).getReadSettings().isSkipFormElementItems()) { + return null; + } + var readerContext = new FormElementReaderContext(reader.getNodeName(), reader); try { readerContext.setValue("id", Integer.parseInt(reader.getAttribute("id"))); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java index f65aae1f0..a84fb76ad 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdclasses.ExternalReport; import com.github._1c_syntax.bsl.mdclasses.ExternalSource; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdo.Language; import com.github._1c_syntax.bsl.mdo.children.AccountingFlag; @@ -93,8 +94,11 @@ public class EDTReader implements MDReader { @Getter private final Path rootPath; - public EDTReader(Path path, boolean skipSupport) { - xstream = createXMLMapper(); + @Getter + private final MDCReadSettings readSettings; + + public EDTReader(Path path, MDCReadSettings readSettings) { + this.xstream = createXMLMapper(); var normalizedPath = path.toAbsolutePath(); var file = normalizedPath.toFile(); if (file.isFile() && CONFIGURATION_MDO_FILE_NAME.equals(file.getName())) { // ΠΏΠ΅Ρ€Π΅Π΄Π°Π»ΠΈ сам Ρ„Π°ΠΉΠ», Π° Π½Π΅ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ @@ -109,11 +113,13 @@ public EDTReader(Path path, boolean skipSupport) { throw new IllegalArgumentException( "НС ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ ΠΊΠΎΡ€Π΅Π½ΡŒ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° EDT для Ρ„Π°ΠΉΠ»Π° " + normalizedPath); } - rootPath = projectRoot; + this.rootPath = projectRoot; } else { - rootPath = path; + this.rootPath = path; } - if (!skipSupport) { + this.readSettings = readSettings; + + if (!readSettings.isSkipSupport()) { var pcbin = parentConfigurationsPath(); if (pcbin.toFile().exists()) { ParseSupportData.read(pcbin); diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/FormItemConverter.java b/src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/FormItemConverter.java index 591b2e389..7313a584b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/FormItemConverter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/FormItemConverter.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdo.storage.form.FormElementType; import com.github._1c_syntax.bsl.mdo.storage.form.FormItem; import com.github._1c_syntax.bsl.reader.common.context.FormElementReaderContext; +import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream; import com.github._1c_syntax.bsl.reader.common.xstream.ReadConverter; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; @@ -36,6 +37,9 @@ public class FormItemConverter implements ReadConverter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + if (ExtendXStream.getCurrentMDReader(reader).getReadSettings().isSkipFormElementItems()) { + return null; + } var readerContext = new FormElementReaderContext(reader.getNodeName(), reader); var attributeType = reader.getAttribute("type"); Unmarshaller.unmarshal(reader, context, readerContext); diff --git a/src/test/java/com/github/_1c_syntax/bsl/examples/ValueTypeTest.java b/src/test/java/com/github/_1c_syntax/bsl/examples/ValueTypeTest.java index d1dfb2154..23bcc9229 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/examples/ValueTypeTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/examples/ValueTypeTest.java @@ -22,6 +22,7 @@ package com.github._1c_syntax.bsl.examples; import com.github._1c_syntax.bsl.mdclasses.Configuration; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdclasses.MDClasses; import com.github._1c_syntax.bsl.mdo.Catalog; @@ -123,7 +124,7 @@ private static Configuration readConfiguration(ArgumentsAccessor argumentsAccess configurationPath = Path.of(EXAMPLES_PATH, DESIGNER_PATH, examplePackName, DESIGNER_CF_PATH); } - var mdc = MDClasses.createConfiguration(configurationPath, true); + var mdc = MDClasses.createConfiguration(configurationPath, MDCReadSettings.SKIP_SUPPORT); assertThat(mdc).isNotNull(); assertThat(mdc).isInstanceOf(MDClass.class); assertThat(mdc).isInstanceOf(Configuration.class); diff --git a/src/test/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationTest.java b/src/test/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationTest.java index 7c2a8ae18..5f13327f8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationTest.java @@ -23,8 +23,12 @@ import com.github._1c_syntax.bsl.mdo.BusinessProcess; import com.github._1c_syntax.bsl.mdo.Form; +import com.github._1c_syntax.bsl.mdo.FormOwner; import com.github._1c_syntax.bsl.mdo.Module; +import com.github._1c_syntax.bsl.mdo.TemplateOwner; import com.github._1c_syntax.bsl.mdo.children.ObjectForm; +import com.github._1c_syntax.bsl.mdo.storage.RoleData; +import com.github._1c_syntax.bsl.mdo.storage.XdtoPackageData; import com.github._1c_syntax.bsl.mdo.support.DataLockControlMode; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.support.SupportVariant; @@ -39,6 +43,7 @@ import org.junit.jupiter.params.provider.CsvSource; import java.nio.file.Path; +import java.util.Collection; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -216,7 +221,7 @@ void testFullMdclasses(ArgumentsAccessor argumentsAccessor) { @Test void testFullExt() { var configurationPath = Path.of("src/test/resources/ext/designer/mdclasses_ext/src/cf/Configuration.xml"); - var mdc = MDClasses.createConfiguration(configurationPath, true); + var mdc = MDClasses.createConfiguration(configurationPath, MDCReadSettings.SKIP_SUPPORT); assertThat(mdc).isNotNull() .isInstanceOf(MDClass.class) .isInstanceOf(ConfigurationExtension.class); @@ -249,11 +254,76 @@ void testFullExt() { .isEmpty(); } + @ParameterizedTest + @CsvSource( + { + "true, ssl_3_1, _edt", + "false, ssl_3_1" + } + ) + void testFullSSLSkipAll(ArgumentsAccessor argumentsAccessor) { + var settings = MDCReadSettings.builder() + .skipSupport(true) + .skipRoleData(true) + .skipFormElementItems(true) + .skipXdtoPackage(true) + .skipDataCompositionSchema(true) + .build(); + + var mdc = MDTestUtils.readConfiguration(argumentsAccessor, settings); + assertThat(mdc).isInstanceOf(Configuration.class); + var cf = (Configuration) mdc; + assertThat(cf.getSupportVariant()).isEqualTo(SupportVariant.NONE); + assertThat(cf.getModules()) + .hasSize(4) + .allMatch(module -> module.getSupportVariant().equals(SupportVariant.NONE)); + + assertThat(cf.getAllModules()) + .hasSize(1320 + cf.getCommonModules().size()) + .allMatch(module -> module.getSupportVariant().equals(SupportVariant.NONE)); + + assertThat(cf.getPlainChildren()) + .hasSize(8038) + .allMatch(md -> md.getSupportVariant().equals(SupportVariant.NONE)); + + assertThat(cf.getRoles()) + .hasSize(86) + .allMatch(role -> role.getData() == RoleData.EMPTY) + ; + + assertThat(cf.getXDTOPackages()) + .hasSize(38) + .allMatch(xdtoPackage -> xdtoPackage.getData() == XdtoPackageData.EMPTY) + ; + + var forms = cf.getPlainChildren().stream() + .filter(FormOwner.class::isInstance) + .map(FormOwner.class::cast) + .map(FormOwner::getForms) + .flatMap(Collection::stream) + .toList(); + + assertThat(forms) + .hasSize(632) + .allMatch(form -> form.getData().getPlainItems().isEmpty()); + + var templates = cf.getPlainChildren().stream() + .filter(TemplateOwner.class::isInstance) + .map(TemplateOwner.class::cast) + .map(TemplateOwner::getTemplates) + .flatMap(Collection::stream) + .toList(); + + assertThat(templates) + .hasSize(89) + .allMatch(template -> template.getData().isEmpty()); + } + @Test void testFullExtEdt() { var configurationPath = Path.of( "src/test/resources/ext/edt/mdclasses_ext/configuration/src/Configuration/Configuration.mdo"); - var mdc = MDClasses.createConfiguration(configurationPath, true); + var mdc = MDClasses.createConfiguration(configurationPath, MDCReadSettings.SKIP_SUPPORT); assertThat(mdc).isNotNull() .isInstanceOf(MDClass.class) .isInstanceOf(ConfigurationExtension.class); diff --git a/src/test/java/com/github/_1c_syntax/bsl/test_utils/MDTestUtils.java b/src/test/java/com/github/_1c_syntax/bsl/test_utils/MDTestUtils.java index ed8d26ced..bd4df6cd7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/test_utils/MDTestUtils.java +++ b/src/test/java/com/github/_1c_syntax/bsl/test_utils/MDTestUtils.java @@ -23,6 +23,7 @@ import com.github._1c_syntax.bsl.mdclasses.CF; import com.github._1c_syntax.bsl.mdclasses.ExternalSource; +import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings; import com.github._1c_syntax.bsl.mdclasses.MDClass; import com.github._1c_syntax.bsl.mdclasses.MDClasses; import com.github._1c_syntax.bsl.mdo.CommonModule; @@ -111,6 +112,7 @@ public String createJson(Object obj) { xstream.omitField(clazz, "commonModulesByName"); xstream.omitField(clazz, "childrenByMdoRef"); xstream.omitField(clazz, "mdoRef"); + xstream.omitField(clazz, "plainDataSets"); } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -136,7 +138,7 @@ public MD getMDWithSimpleTest(ArgumentsAccessor argumentsAccessor) { configurationPath = Path.of(EXAMPLES_PATH, DESIGNER_PATH, examplePackName, DESIGNER_CF_PATH); } - var mdo = MDOReader.read(configurationPath, mdoRef); + var mdo = MDOReader.read(configurationPath, mdoRef, MDCReadSettings.DEFAULT); assertThat(mdo).isInstanceOf(MD.class); Path fixturePath; @@ -165,7 +167,8 @@ public MDClass getMDCWithSimpleTest(ArgumentsAccessor argumentsAccessor, boolean configurationPath = Path.of(EXAMPLES_PATH, DESIGNER_PATH, examplePackName, DESIGNER_CF_PATH); } - var mdc = MDClasses.createConfiguration(configurationPath, skipSupport); + var mdc = MDClasses.createConfiguration(configurationPath, + MDCReadSettings.builder().skipSupport(skipSupport).build()); assertThat(mdc).isNotNull(); assertThat(mdc).isInstanceOf(MDClass.class); @@ -182,6 +185,10 @@ public MDClass getMDCWithSimpleTest(ArgumentsAccessor argumentsAccessor, boolean } public CF readConfiguration(ArgumentsAccessor argumentsAccessor, boolean skipSupport) { + return readConfiguration(argumentsAccessor, MDCReadSettings.builder().skipSupport(skipSupport).build()); + } + + public CF readConfiguration(ArgumentsAccessor argumentsAccessor, MDCReadSettings readSettings) { var isEDT = argumentsAccessor.getBoolean(0); var examplePackName = argumentsAccessor.getString(1); @@ -192,7 +199,7 @@ public CF readConfiguration(ArgumentsAccessor argumentsAccessor, boolean skipSup configurationPath = Path.of(EXAMPLES_PATH, DESIGNER_PATH, examplePackName, DESIGNER_CF_PATH); } - var mdc = MDClasses.createConfiguration(configurationPath, skipSupport); + var mdc = MDClasses.createConfiguration(configurationPath, readSettings); assertThat(mdc).isNotNull(); assertThat(mdc).isInstanceOf(MDClass.class); assertThat(mdc).isInstanceOf(CF.class);