From 287dde0e0825edb55da67e8f85a6cadb871d8e84 Mon Sep 17 00:00:00 2001 From: Maxim Dzyuba Date: Fri, 28 Jun 2024 15:37:41 +0300 Subject: [PATCH] =?UTF-8?q?G5V8DT-25016=20=D0=92=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D1=85=20=D1=82=D0=B8=D0=BF=D0=B0=D1=85=20Edt?= =?UTF-8?q?=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BD=D0=B8=D0=BC=D0=B0=D0=B5?= =?UTF-8?q?=D1=82,=20=D1=87=D1=82=D0=BE=20=D0=A1=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=A1=D1=81=D1=8B=D0=BB=D0=BA?= =?UTF-8?q?=D0=B0.=D0=98=D0=BC=D1=8F=D0=A1=D0=BF=D1=80=D0=B0=D0=B2=D0=BE?= =?UTF-8?q?=D1=87=D0=BD=D0=B8=D0=BA=D0=B0=20=D0=B2=D1=85=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=20=D0=B2=20=D1=81=D0=BE=D1=81=D1=82=D0=B0=D0=B2=20=D1=82?= =?UTF-8?q?=D0=B8=D0=BF=D0=B0=20=D0=A1=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA=D0=A1=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20#1360?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/bsl/ui/views/BslDocCommentView.java | 9 ++------- .../check/FunctionCtorReturnSectionCheck.java | 15 +++++---------- .../constructor-function-return-section.bsl | 10 ++++++++++ .../check/itests/CommonModuleStrictTypesTest.java | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/internal/bsl/ui/views/BslDocCommentView.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/internal/bsl/ui/views/BslDocCommentView.java index d83e19cc..dbedc2ef 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/internal/bsl/ui/views/BslDocCommentView.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/internal/bsl/ui/views/BslDocCommentView.java @@ -14,8 +14,6 @@ package com.e1c.v8codestyle.internal.bsl.ui.views; import java.text.MessageFormat; -import com.google.inject.Inject; - import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; @@ -32,8 +30,8 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionBars; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.xtext.resource.EObjectAtOffsetHelper; @@ -68,9 +66,6 @@ public class BslDocCommentView */ public static final String ID = "com.e1c.v8codestyle.bsl.ui.views.BslDocCommentView"; //$NON-NLS-1$ - @Inject - private IWorkbench workbench; - private TreeViewer viewer; private ISelectionListener listener; @@ -254,7 +249,7 @@ public class BslDocCommentView { imageKey = ISharedImages.IMG_OBJ_FOLDER; } - return workbench.getSharedImages().getImage(imageKey); + return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); } } diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/FunctionCtorReturnSectionCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/FunctionCtorReturnSectionCheck.java index 7c64a0a9..1729dc6e 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/FunctionCtorReturnSectionCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/FunctionCtorReturnSectionCheck.java @@ -48,6 +48,7 @@ import com._1c.g5.v8.dt.bsl.model.Function; import com._1c.g5.v8.dt.bsl.model.ReturnStatement; import com._1c.g5.v8.dt.bsl.resource.DynamicFeatureAccessComputer; import com._1c.g5.v8.dt.bsl.resource.TypesComputer; +import com._1c.g5.v8.dt.bsl.util.BslUtil; import com._1c.g5.v8.dt.core.platform.IBmModelManager; import com._1c.g5.v8.dt.core.platform.IResourceLookup; import com._1c.g5.v8.dt.core.platform.IV8Project; @@ -183,10 +184,7 @@ public class FunctionCtorReturnSectionCheck Set checkTypes = getCheckTypes(parameters); - Set computedReturnTypeNames = computedReturnTypes.stream() - .map(McoreUtil::getTypeName) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); + Collection computedReturnTypeNames = BslUtil.computeTypeNames(computedReturnTypes, method); if (isUserDataTypes(computedReturnTypeNames, checkTypes)) { @@ -269,11 +267,8 @@ public class FunctionCtorReturnSectionCheck { String propertyName = useRussianScript ? declaredProperty.getNameRu() : declaredProperty.getName(); declaredProertyNames.add(propertyName); - List declaredType = declaredProperty.getTypes() - .stream() - .map(McoreUtil::getTypeName) - .filter(Objects::nonNull) - .collect(Collectors.toList()); + Collection declaredType = + com._1c.g5.v8.dt.bsl.util.BslUtil.computeTypeNames(declaredProperty.getTypes(), function); if (declaredType.isEmpty()) { continue; @@ -287,7 +282,7 @@ public class FunctionCtorReturnSectionCheck .collect(Collectors.toList()); List missingTypes = types.stream().filter(t -> { - String typeName = McoreUtil.getTypeName(t); + String typeName = McoreUtil.getTypeCategory(t); if (typeName != null) { if (!declaredType.contains(typeName)) diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/constructor-function-return-section.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/constructor-function-return-section.bsl index 1f36fed3..96254f6b 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/constructor-function-return-section.bsl +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/constructor-function-return-section.bsl @@ -41,5 +41,15 @@ Function CorrectCheckForCommonModule() Export return new Structure("Key1, Key2", 10, CommonModule); EndFunction +// Returns: +// Structure - complaint: +// * Ref - CatalogRef - +Function CorrectCheckForTypeSets() Export + EmptyRef = Catalogs.Catalog1.EmptyRef(); + Str = Новый Structure; + Str.Вставить("Ref", EmptyRef); + Возврат Str; +EndFunction + diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java index a8ae4b39..6e372bb0 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java @@ -387,8 +387,8 @@ public class CommonModuleStrictTypesTest Module module = updateAndGetModule(checkId); - List finctions = EcoreUtil2.eAllOfType(module, Function.class); - assertEquals(4, finctions.size()); + List functions = EcoreUtil2.eAllOfType(module, Function.class); + assertEquals(5, functions.size()); List markers = getMarters(checkId, module);