Skip to content

Commit 6f78f00

Browse files
authored
Merge pull request #456 from 1c-syntax/feature/optimize
Оптимизация многопоточной работы
2 parents 3b7b1b6 + 79a3606 commit 6f78f00

File tree

213 files changed

+1847
-9203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+1847
-9203
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ build/
1313

1414
/.idea/misc.xml
1515
Gradle_*.xml
16+
/.idea/material_theme_project_new.xml
17+
*.hprof
18+
*.hprof.idom

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ dependencies {
5151
implementation("com.thoughtworks.xstream", "xstream", "1.4.20")
5252

5353
// логирование
54-
implementation("org.slf4j", "slf4j-api", "1.7.30")
54+
implementation("org.slf4j", "slf4j-api", "2.1.0-alpha1")
5555

5656
// прочее
5757
implementation("commons-io", "commons-io", "2.8.0")
58-
implementation("io.github.1c-syntax", "utils", "0.6.0")
59-
implementation("io.github.1c-syntax", "bsl-common-library", "0.5.1")
58+
implementation("io.github.1c-syntax", "utils", "0.6.1")
59+
implementation("io.github.1c-syntax", "bsl-common-library", "0.6.0")
6060
implementation("io.github.1c-syntax", "supportconf", "0.14.0") {
6161
exclude("io.github.1c-syntax", "bsl-common-library")
6262
}
@@ -75,7 +75,7 @@ dependencies {
7575

7676
// логирование
7777
// https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12
78-
testImplementation("org.slf4j", "slf4j-log4j12", "1.7.30")
78+
testImplementation("org.slf4j", "slf4j-log4j12", "2.1.0-alpha1")
7979
}
8080

8181
java {

src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public MDClass createConfiguration() {
6161
*
6262
* @return Пустой внешний отчет
6363
*/
64-
public MDClass createExternalReport() {
64+
public ExternalSource createExternalReport() {
6565
return ExternalReport.EMPTY;
6666
}
6767

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/RoleData.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@
2222
package com.github._1c_syntax.bsl.mdo.storage;
2323

2424
import com.github._1c_syntax.bsl.mdo.support.RoleRight;
25-
import com.github._1c_syntax.bsl.reader.MDOReader;
2625
import com.github._1c_syntax.utils.GenericInterner;
2726
import lombok.Builder;
2827
import lombok.Builder.Default;
2928
import lombok.EqualsAndHashCode;
30-
import lombok.NonNull;
3129
import lombok.Singular;
3230
import lombok.ToString;
3331
import lombok.Value;
3432
import lombok.extern.slf4j.Slf4j;
3533

36-
import java.nio.file.Path;
3734
import java.util.List;
3835

3936
/**
@@ -67,19 +64,6 @@ public class RoleData {
6764
@Singular
6865
List<ObjectRight> objectRights;
6966

70-
// todo переделать на конвертер
71-
public static RoleData create(@NonNull Path path) {
72-
var data = MDOReader.read(path);
73-
if (data instanceof RoleData roleData) {
74-
return roleData;
75-
} else if (data == null) {
76-
LOGGER.warn("Missing file " + path);
77-
return null;
78-
} else {
79-
throw new IllegalArgumentException("Wrong Role data file " + path);
80-
}
81-
}
82-
8367
@Value
8468
@ToString(of = {"name"})
8569
@EqualsAndHashCode(of = {"name"})

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/XdtoPackageData.java

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
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-
package com.github._1c_syntax.bsl.mdo.storage;
23-
24-
import com.github._1c_syntax.bsl.reader.MDOReader;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
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+
package com.github._1c_syntax.bsl.mdo.storage;
23+
2524
import lombok.Builder;
2625
import lombok.Builder.Default;
2726
import lombok.EqualsAndHashCode;
28-
import lombok.NonNull;
2927
import lombok.Singular;
3028
import lombok.ToString;
3129
import lombok.Value;
3230
import lombok.extern.slf4j.Slf4j;
3331

34-
import java.nio.file.Path;
3532
import java.util.List;
3633

3734
/**
@@ -76,19 +73,6 @@ public class XdtoPackageData {
7673
@Singular
7774
List<Property> properties;
7875

79-
// todo переделать на конвертер
80-
public static XdtoPackageData create(@NonNull Path path) {
81-
var data = MDOReader.read(path);
82-
if (data instanceof XdtoPackageData xdtoPackageData) {
83-
return xdtoPackageData;
84-
} else if (data == null) {
85-
LOGGER.warn("Missing file " + path);
86-
return null;
87-
} else {
88-
throw new IllegalArgumentException("Wrong XDTO package data file " + path);
89-
}
90-
}
91-
9276
@Value
9377
@ToString(of = {"name"})
9478
@EqualsAndHashCode(of = {"name"})

src/main/java/com/github/_1c_syntax/bsl/mdo/support/MultiLanguageString.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.List;
3535
import java.util.Map;
3636
import java.util.Set;
37+
import java.util.stream.Collectors;
3738

3839
/**
3940
* Используется для хранения текстовой строки на разных языках
@@ -176,6 +177,16 @@ public int compareTo(@Nullable MultiLanguageString multiLanguageString) {
176177
}
177178
}
178179

180+
public String toString() {
181+
if (isEmpty()) {
182+
return "empty";
183+
} else {
184+
return content.stream()
185+
.map(entry -> entry.langKey + ": " + entry.value)
186+
.collect(Collectors.joining(", "));
187+
}
188+
}
189+
179190
private MultiLanguageString intern() {
180191
return interner.intern(this);
181192
}

src/main/java/com/github/_1c_syntax/bsl/mdo/support/ScriptVariant.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
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-
package com.github._1c_syntax.bsl.mdo.support;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
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+
package com.github._1c_syntax.bsl.mdo.support;
2323

2424
import lombok.AllArgsConstructor;
2525
import lombok.Getter;
2626
import lombok.experimental.Accessors;
27-
import org.apache.commons.collections4.map.CaseInsensitiveMap;
2827

2928
import java.util.Map;
29+
import java.util.concurrent.ConcurrentSkipListMap;
3030

3131
/**
3232
* Возможные варианты языков, на которых разрабатывается код
@@ -68,7 +68,7 @@ public static ScriptVariant valueByString(String string) {
6868
}
6969

7070
private static Map<String, ScriptVariant> computeKeys() {
71-
Map<String, ScriptVariant> keysMap = new CaseInsensitiveMap<>();
71+
Map<String, ScriptVariant> keysMap = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
7272
for (var element : values()) {
7373
keysMap.put(element.value(), element);
7474
keysMap.put(element.valueRu(), element);

src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,23 @@
2121
*/
2222
package com.github._1c_syntax.bsl.reader;
2323

24+
import com.github._1c_syntax.bsl.mdclasses.Configuration;
25+
import com.github._1c_syntax.bsl.mdclasses.ExternalReport;
26+
import com.github._1c_syntax.bsl.mdclasses.ExternalSource;
2427
import com.github._1c_syntax.bsl.mdclasses.MDClass;
25-
import com.github._1c_syntax.bsl.mdclasses.MDClasses;
2628
import com.github._1c_syntax.bsl.mdo.MDObject;
29+
import com.github._1c_syntax.bsl.mdo.storage.EmptyFormData;
30+
import com.github._1c_syntax.bsl.mdo.storage.FormData;
31+
import com.github._1c_syntax.bsl.reader.common.context.AbstractReaderContext;
2732
import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream;
2833
import com.github._1c_syntax.bsl.types.ConfigurationSource;
29-
import com.thoughtworks.xstream.converters.Converter;
34+
import com.github._1c_syntax.bsl.types.MDOType;
35+
import com.github._1c_syntax.bsl.types.ModuleType;
36+
import com.thoughtworks.xstream.converters.UnmarshallingContext;
37+
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
38+
import lombok.NonNull;
3039

3140
import javax.annotation.Nullable;
32-
import java.io.File;
3341
import java.nio.file.Path;
3442

3543
/**
@@ -38,53 +46,87 @@
3846
public class FakeReader implements MDReader {
3947

4048
@Override
49+
@NonNull
4150
public ConfigurationSource getConfigurationSource() {
4251
return ConfigurationSource.EMPTY;
4352
}
4453

45-
@Nullable
4654
@Override
47-
public MDObject read(String fullName) {
48-
return null;
55+
@NonNull
56+
public MDClass readConfiguration() {
57+
return Configuration.EMPTY;
58+
}
59+
60+
@Override
61+
@NonNull
62+
public ExternalSource readExternalSource() {
63+
return ExternalReport.EMPTY;
4964
}
5065

66+
@Override
67+
@NonNull
68+
public Path getRootPath() {
69+
return Path.of("fake-path");
70+
}
71+
72+
@Override
5173
@Nullable
74+
public MDObject read(Path path) {
75+
return null;
76+
}
77+
5278
@Override
79+
@Nullable
5380
public MDObject read(Path folder, String fullName) {
5481
return null;
5582
}
5683

57-
@Nullable
5884
@Override
59-
public MDObject read(Path fullMdoName) {
85+
@Nullable
86+
public ExtendXStream getXstream() {
6087
return null;
6188
}
6289

63-
@Nullable
6490
@Override
65-
public Object fromXml(File file) {
66-
return null;
91+
@NonNull
92+
public FormData readFormData(Path currentPath, String name, MDOType mdoType) {
93+
return EmptyFormData.getEmpty();
6794
}
6895

69-
@Nullable
7096
@Override
71-
public Converter getReflectionConverter() {
72-
return null;
97+
@NonNull
98+
public Path moduleFolder(Path mdoPath, MDOType mdoType) {
99+
return getRootPath();
73100
}
74101

75-
@Nullable
76102
@Override
77-
public ExtendXStream getEXStream() {
78-
return null;
103+
@NonNull
104+
public Path modulePath(Path folder, String name, ModuleType moduleType) {
105+
return getRootPath();
79106
}
80107

81108
@Override
82-
public MDClass readConfiguration() {
83-
return MDClasses.createConfiguration();
109+
@NonNull
110+
public Path mdoTypeFolderPath(Path mdoPath) {
111+
return getRootPath();
84112
}
85113

86114
@Override
87-
public MDClass readExternalSource() {
88-
return null;
115+
@NonNull
116+
public String subsystemsNodeName() {
117+
return "";
118+
}
119+
120+
@Override
121+
@NonNull
122+
public String configurationExtensionFilter() {
123+
return "";
124+
}
125+
126+
@Override
127+
public void unmarshal(HierarchicalStreamReader reader,
128+
UnmarshallingContext context,
129+
AbstractReaderContext readerContext) {
130+
// no-op
89131
}
90132
}

0 commit comments

Comments
 (0)