From 4d1a5f144008a6b28fa5c4ed816d5751f4966882 Mon Sep 17 00:00:00 2001 From: theshadowco Date: Tue, 26 Dec 2023 09:33:11 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20mdc?= =?UTF-8?q?lasses=20=D0=B8=20=D0=B2=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D1=8B=20#3215?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 +- ...rongDataPathForFormElementsDiagnostic.java | 27 +++++++---------- ...DataPathForFormElementsDiagnosticTest.java | 30 +++++++++---------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c6dc7ec1c61..04a388fe91c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -83,7 +83,7 @@ dependencies { exclude("org.glassfish", "javax.json") } api("com.github.1c-syntax", "utils", "0.5.1") - api("io.github.1c-syntax", "mdclasses", "0.12.0-rc.5") + api("io.github.1c-syntax", "mdclasses", "0.12.0-rc.6") api("io.github.1c-syntax", "bsl-common-library", "0.5.0") api("io.github.1c-syntax", "supportconf", "0.12.1") diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java index 77528c81a4c..42c8d16d4d1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java @@ -29,9 +29,9 @@ import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.storage.form.FormItem; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.children.form.FormItem; import org.eclipse.lsp4j.Range; import java.util.function.Predicate; @@ -57,16 +57,15 @@ public class WrongDataPathForFormElementsDiagnostic extends AbstractDiagnostic { @Override protected void check() { - var range = documentContext.getSymbolTree().getModule().getSelectionRange(); if (!Ranges.isEmpty(range)) { checkCurrentModule(range); } } -// private static boolean wrongDataPath(FormItem formItem) { -// return formItem.getDataPath().getSegment().startsWith("~"); -// } + private static boolean wrongDataPath(FormItem formItem) { + return formItem.getDataPath().getSegments().startsWith("~"); + } private static boolean haveFormModules(Form form) { return !form.getModules().isEmpty(); @@ -84,13 +83,11 @@ private void checkCurrentModule(Range range) { } private void checkAllFormsWithoutModules() { - // todo формы не доделаны -// checkMdoObjectStream(form -> !haveFormModules(form), -// documentContext.getServerContext().getConfiguration().getChildrenByMdoRef().values().stream()); + checkMdoObjectStream(form -> !haveFormModules(form), + documentContext.getServerContext().getConfiguration().getPlainChildren().stream()); } private void checkMdoObjectStream(Predicate
formFilter, Stream stream) { - stream .filter(Form.class::isInstance) .map(Form.class::cast) @@ -99,17 +96,15 @@ private void checkMdoObjectStream(Predicate formFilter, Stream stream) } private void checkForm(Form form) { - var formData = form.getData(); if (formData.isEmpty()) { return; } -// todo формы не доделаны -// formData.getPlainChildren() -// .stream() -// .filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath) -// .forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange, -// info.getMessage(formItem.getName(), getMdoRef(form)))); + formData.getPlainItems() + .stream() + .filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath) + .forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange, + info.getMessage(formItem.getName(), getMdoRef(form)))); } private String getMdoRef(Form form) { diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java index 940cfb4b435..9857fedd350 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java @@ -23,14 +23,15 @@ import com.github._1c_syntax.bsl.languageserver.util.TestUtils; import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.test.annotation.DirtiesContext; import java.nio.file.Paths; +import java.util.Collections; import java.util.List; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; @@ -55,16 +56,14 @@ void setUp() { } @Test - @Disabled void testNoFormModule() { final var pathToManagedApplicationModuleFile = "/Ext/ManagedApplicationModule.bsl"; context = spy(context); final var configuration = spy(context.getConfiguration()); - when(context.getConfiguration()).thenReturn(configuration); - fillConfigChildrenByFormsWithoutModule(configuration); + when(context.getConfiguration()).thenReturn(configuration); List diagnostics = getDiagnosticListForMockedFile(pathToManagedApplicationModuleFile); @@ -76,7 +75,6 @@ void testNoFormModule() { } @Test - @Disabled void testFormModule() { List diagnostics = getDiagnosticListForMockedFile(PATH_TO_ELEMENT_MODULE_FILE); @@ -88,7 +86,6 @@ void testFormModule() { } @Test - @Disabled void testDynamicListFormModule() { final var pathToDynamicListModuleFile = "/Catalogs/Справочник1/Forms/ФормаВыбора/Ext/Form/Module.bsl"; @@ -101,20 +98,23 @@ void testDynamicListFormModule() { } private void fillConfigChildrenByFormsWithoutModule(CF configuration) { -// final var childrenByMdoRefFromConfig = configuration.getChildrenByMdoRef(); -// var childrenByMdoRef = childrenByMdoRefFromConfig.entrySet().stream() -// .filter(entry -> entry.getValue() instanceof Form) -// .collect(Collectors.toMap(Map.Entry::getKey, entry -> { -// ((Form) entry.getValue()).setModules(Collections.emptyList()); -// return entry.getValue(); -// })); -// when(configuration.getChildrenByMdoRef()).thenReturn(childrenByMdoRef); + var plainChildren = configuration.getPlainChildren().stream() + .filter(md -> md instanceof Form) + .map(md -> { + var mockMD = spy(md); + when(((Form) mockMD).getModules()).thenReturn(Collections.emptyList()); + return mockMD; + }) + .toList(); + + when(configuration.getPlainChildren()).thenReturn(plainChildren); } private List getDiagnosticListForMockedFile(String pathToDynamicListModuleFile) { var testFile = Paths.get(PATH_TO_METADATA + pathToDynamicListModuleFile).toAbsolutePath(); - var documentContext = TestUtils.getDocumentContext(testFile.toUri(), getText()); + var documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), getText())); + when(documentContext.getServerContext()).thenReturn(context); return getDiagnostics(documentContext); } From 1092d74e0e6be179b98e7a08781a967b6d70aebf Mon Sep 17 00:00:00 2001 From: theshadowco Date: Tue, 26 Dec 2023 12:45:04 +0300 Subject: [PATCH 2/2] stable mdclasses 0.12.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 04a388fe91c..563ae8b2b26 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -83,7 +83,7 @@ dependencies { exclude("org.glassfish", "javax.json") } api("com.github.1c-syntax", "utils", "0.5.1") - api("io.github.1c-syntax", "mdclasses", "0.12.0-rc.6") + api("io.github.1c-syntax", "mdclasses", "0.12.0") api("io.github.1c-syntax", "bsl-common-library", "0.5.0") api("io.github.1c-syntax", "supportconf", "0.12.1")