Skip to content

Commit 33eb49d

Browse files
authored
Merge pull request #3218 from 1c-syntax/feature/mdclasses_0.12.rc.6
Обновление версии mdclasses и восстановление работы диагностики
2 parents 0c544f4 + 1092d74 commit 33eb49d

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ dependencies {
8383
exclude("org.glassfish", "javax.json")
8484
}
8585
api("com.github.1c-syntax", "utils", "0.5.1")
86-
api("io.github.1c-syntax", "mdclasses", "0.12.0-rc.5")
86+
api("io.github.1c-syntax", "mdclasses", "0.12.0")
8787
api("io.github.1c-syntax", "bsl-common-library", "0.5.0")
8888
api("io.github.1c-syntax", "supportconf", "0.12.1")
8989

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import com.github._1c_syntax.bsl.languageserver.utils.Ranges;
3030
import com.github._1c_syntax.bsl.mdo.Form;
3131
import com.github._1c_syntax.bsl.mdo.MD;
32+
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
3233
import com.github._1c_syntax.bsl.mdo.support.ScriptVariant;
3334
import com.github._1c_syntax.bsl.types.ModuleType;
34-
import com.github._1c_syntax.mdclasses.mdo.children.form.FormItem;
3535
import org.eclipse.lsp4j.Range;
3636

3737
import java.util.function.Predicate;
@@ -57,16 +57,15 @@ public class WrongDataPathForFormElementsDiagnostic extends AbstractDiagnostic {
5757

5858
@Override
5959
protected void check() {
60-
6160
var range = documentContext.getSymbolTree().getModule().getSelectionRange();
6261
if (!Ranges.isEmpty(range)) {
6362
checkCurrentModule(range);
6463
}
6564
}
6665

67-
// private static boolean wrongDataPath(FormItem formItem) {
68-
// return formItem.getDataPath().getSegment().startsWith("~");
69-
// }
66+
private static boolean wrongDataPath(FormItem formItem) {
67+
return formItem.getDataPath().getSegments().startsWith("~");
68+
}
7069

7170
private static boolean haveFormModules(Form form) {
7271
return !form.getModules().isEmpty();
@@ -84,13 +83,11 @@ private void checkCurrentModule(Range range) {
8483
}
8584

8685
private void checkAllFormsWithoutModules() {
87-
// todo формы не доделаны
88-
// checkMdoObjectStream(form -> !haveFormModules(form),
89-
// documentContext.getServerContext().getConfiguration().getChildrenByMdoRef().values().stream());
86+
checkMdoObjectStream(form -> !haveFormModules(form),
87+
documentContext.getServerContext().getConfiguration().getPlainChildren().stream());
9088
}
9189

9290
private void checkMdoObjectStream(Predicate<Form> formFilter, Stream<MD> stream) {
93-
9491
stream
9592
.filter(Form.class::isInstance)
9693
.map(Form.class::cast)
@@ -99,17 +96,15 @@ private void checkMdoObjectStream(Predicate<Form> formFilter, Stream<MD> stream)
9996
}
10097

10198
private void checkForm(Form form) {
102-
10399
var formData = form.getData();
104100
if (formData.isEmpty()) {
105101
return;
106102
}
107-
// todo формы не доделаны
108-
// formData.getPlainChildren()
109-
// .stream()
110-
// .filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath)
111-
// .forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange,
112-
// info.getMessage(formItem.getName(), getMdoRef(form))));
103+
formData.getPlainItems()
104+
.stream()
105+
.filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath)
106+
.forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange,
107+
info.getMessage(formItem.getName(), getMdoRef(form))));
113108
}
114109

115110
private String getMdoRef(Form form) {

src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323

2424
import com.github._1c_syntax.bsl.languageserver.util.TestUtils;
2525
import com.github._1c_syntax.bsl.mdclasses.CF;
26+
import com.github._1c_syntax.bsl.mdo.Form;
2627
import com.github._1c_syntax.utils.Absolute;
2728
import org.eclipse.lsp4j.Diagnostic;
2829
import org.junit.jupiter.api.BeforeEach;
29-
import org.junit.jupiter.api.Disabled;
3030
import org.junit.jupiter.api.Test;
3131
import org.springframework.test.annotation.DirtiesContext;
3232

3333
import java.nio.file.Paths;
34+
import java.util.Collections;
3435
import java.util.List;
3536

3637
import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat;
@@ -55,16 +56,14 @@ void setUp() {
5556
}
5657

5758
@Test
58-
@Disabled
5959
void testNoFormModule() {
6060

6161
final var pathToManagedApplicationModuleFile = "/Ext/ManagedApplicationModule.bsl";
6262

6363
context = spy(context);
6464
final var configuration = spy(context.getConfiguration());
65-
when(context.getConfiguration()).thenReturn(configuration);
66-
6765
fillConfigChildrenByFormsWithoutModule(configuration);
66+
when(context.getConfiguration()).thenReturn(configuration);
6867

6968
List<Diagnostic> diagnostics = getDiagnosticListForMockedFile(pathToManagedApplicationModuleFile);
7069

@@ -76,7 +75,6 @@ void testNoFormModule() {
7675
}
7776

7877
@Test
79-
@Disabled
8078
void testFormModule() {
8179

8280
List<Diagnostic> diagnostics = getDiagnosticListForMockedFile(PATH_TO_ELEMENT_MODULE_FILE);
@@ -88,7 +86,6 @@ void testFormModule() {
8886
}
8987

9088
@Test
91-
@Disabled
9289
void testDynamicListFormModule() {
9390

9491
final var pathToDynamicListModuleFile = "/Catalogs/Справочник1/Forms/ФормаВыбора/Ext/Form/Module.bsl";
@@ -101,20 +98,23 @@ void testDynamicListFormModule() {
10198
}
10299

103100
private void fillConfigChildrenByFormsWithoutModule(CF configuration) {
104-
// final var childrenByMdoRefFromConfig = configuration.getChildrenByMdoRef();
105-
// var childrenByMdoRef = childrenByMdoRefFromConfig.entrySet().stream()
106-
// .filter(entry -> entry.getValue() instanceof Form)
107-
// .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
108-
// ((Form) entry.getValue()).setModules(Collections.emptyList());
109-
// return entry.getValue();
110-
// }));
111-
// when(configuration.getChildrenByMdoRef()).thenReturn(childrenByMdoRef);
101+
var plainChildren = configuration.getPlainChildren().stream()
102+
.filter(md -> md instanceof Form)
103+
.map(md -> {
104+
var mockMD = spy(md);
105+
when(((Form) mockMD).getModules()).thenReturn(Collections.emptyList());
106+
return mockMD;
107+
})
108+
.toList();
109+
110+
when(configuration.getPlainChildren()).thenReturn(plainChildren);
112111
}
113112

114113
private List<Diagnostic> getDiagnosticListForMockedFile(String pathToDynamicListModuleFile) {
115114
var testFile = Paths.get(PATH_TO_METADATA + pathToDynamicListModuleFile).toAbsolutePath();
116115

117-
var documentContext = TestUtils.getDocumentContext(testFile.toUri(), getText());
116+
var documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), getText()));
117+
when(documentContext.getServerContext()).thenReturn(context);
118118

119119
return getDiagnostics(documentContext);
120120
}

0 commit comments

Comments
 (0)