diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java index 3c65954060d..3cb4320e566 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java @@ -21,6 +21,7 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.context.symbol.annotations.CompilerDirectiveKind; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticCompatibilityMode; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; @@ -29,6 +30,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.mdclasses.Configuration; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; @@ -134,9 +136,30 @@ public ParseTree visitFile(BSLParser.FileContext ctx) { return ctx; } + if (isServerModule(documentContext)) { + return ctx; + } + return super.visitFile(ctx); } + private static boolean isServerModule(DocumentContext documentContext) { + return switch (documentContext.getModuleType()) { + case ApplicationModule, CommandModule, FormModule, ManagedApplicationModule -> false; + case CommonModule -> isServerCommonModule(documentContext); + default -> true; // Все прочие модули это строго серверные и в них синхронные вызовы разрешены + }; + } + + private static boolean isServerCommonModule(DocumentContext documentContext) { + var mdObject = documentContext.getMdObject(); + + return mdObject.map(CommonModule.class::cast) + .filter(commonModule -> !(commonModule.isClientManagedApplication() || + commonModule.isClientOrdinaryApplication())) + .isPresent(); + } + @Override public ParseTree visitSub(BSLParser.SubContext ctx) { var methodSymbol = documentContext.getSymbolTree().getMethodSymbol(ctx); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java index 6afaa9194aa..7281cc1c758 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java @@ -29,6 +29,8 @@ import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.test.annotation.DirtiesContext; import java.nio.file.Paths; @@ -45,7 +47,10 @@ class UsingSynchronousCallsDiagnosticTest extends AbstractDiagnosticTest diagnostics = getDiagnostics(context); + assertThat(diagnostics).isEmpty(); + } + private DocumentContext getDocumentContextWithUseFlag(UseMode useMode) { + return getDocumentContextWithUseFlag(useMode, PATH_TO_CLIENT_MODULE_FILE); + } + + private DocumentContext getDocumentContextWithUseFlag(UseMode useMode, String moduleFile) { var path = Absolute.path(PATH_TO_METADATA); - var testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); + var testFile = Paths.get(moduleFile).toAbsolutePath(); initServerContext(path); var serverContext = spy(context); diff --git "a/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274.xml" "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274.xml" new file mode 100644 index 00000000000..d0a7c1002cf --- /dev/null +++ "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274.xml" @@ -0,0 +1,126 @@ + + + + + + cd5d9910-c790-46e8-8c99-a0f38f3f9e39 + b69e7b91-a362-429c-b5b4-39e1fd765840 + + + c3d8d716-ce70-459f-9a75-2b8c77a0194b + e4215019-0558-438e-b225-b0f926f42b8a + + + 604fe1d0-b22f-48a6-8335-c86562ba654c + fa9ac073-8e89-47de-8aab-9a3badb9a894 + + + e2756a94-423f-4fff-ab71-622cd2d99f62 + 23864a50-78d1-48ab-88a6-e3f4d212b34f + + + 227a9ad8-b4aa-4d7d-8cc0-bed15e263277 + d2fae109-dc57-483e-a56a-f2baf0515b86 + + + + СправочникСМенеджером + + + false + HierarchyFoldersAndItems + false + 2 + true + true + + ToItems + 9 + 25 + String + Variable + WholeCatalog + true + true + AsDescription + + Auto + InDialog + false + BothWays + + Catalog.СправочникСМенеджером.StandardAttribute.Description + Catalog.СправочникСМенеджером.StandardAttribute.Code + + Begin + DontUse + Directly + + + + + + + + + + + false + + + Managed + Use + + + + + + Use + Auto + DontUse + false + false + + + + + Реквизит1 + + + + xs:string + + 10 + Variable + + + false + + + + false + + false + false + + + false + + DontCheck + Items + + + Auto + Auto + + + Auto + ForItem + DontIndex + Use + Use + + + + + \ No newline at end of file diff --git "a/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ManagerModule.bsl" "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ManagerModule.bsl" new file mode 100644 index 00000000000..5f282702bb0 --- /dev/null +++ "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ManagerModule.bsl" @@ -0,0 +1 @@ + \ No newline at end of file diff --git "a/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ObjectModule.bsl" "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ObjectModule.bsl" new file mode 100644 index 00000000000..5f282702bb0 --- /dev/null +++ "b/src/test/resources/metadata/designer/Catalogs/\320\241\320\277\321\200\320\260\320\262\320\276\321\207\320\275\320\270\320\272\320\241\320\234\320\265\320\275\320\265\320\264\320\266\320\265\321\200\320\276\320\274/Ext/ObjectModule.bsl" @@ -0,0 +1 @@ + \ No newline at end of file