diff --git a/CHANGELOG.md b/CHANGELOG.md index c78f58ed6..6abc40ea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Do not register SAP javadocs for custom extensions [#763](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/763) - Use custom library names for all custom libraries [#764](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/764) +### `items.xml` inspection rules +- Improved detailed message for `TSDeploymentTableMustNotBeRedeclaredInChildTypes` [#772](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/772) + ### `ImpEx` enhancements - Use single space after Header Mode [#761](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/761) diff --git a/resources/i18n/HybrisBundle.properties b/resources/i18n/HybrisBundle.properties index 01779e733..5dad46a3d 100644 --- a/resources/i18n/HybrisBundle.properties +++ b/resources/i18n/HybrisBundle.properties @@ -291,6 +291,7 @@ hybris.inspections.ts.DeploymentTypeCodeMustBeUnique.key=[y] Deployment type cod hybris.inspections.ts.DeploymentTableMustBeUnique.key=[y] Deployment table must be unique hybris.inspections.ts.DeploymentTableMustExistForItemExtendingGenericItem.key=[y] A deployment table must be defined for all Items extending GenericItem hybris.inspections.ts.DeploymentTableMustNotBeRedeclaredInChildTypes.key=[y] Deployment table must be declared only once per Model and not redeclared in child declarations +hybris.inspections.ts.DeploymentTableMustNotBeRedeclaredInChildTypes.problem.key=[y] Deployment table must be declared only once per Model and not redeclared in child declarations. [{0} : {1}] extends [{2} : {3}] hybris.inspections.ts.DeploymentTypeCodeMustBeGreaterThanTenThousand.key=[y] Type codes between 1 and 10000 are reserved for SAP Commerce hybris.inspections.ts.JaloClassIsNotAllowedWhenAddingFieldsToExistingClass.key=[y] The jaloclass attribute is not allowed when autocreate='false' and generate='false' hybris.inspections.ts.DeploymentTableMustExistForManyToManyRelation.key=[y] A deployment table must be defined for all many-to-many relations diff --git a/src/com/intellij/idea/plugin/hybris/codeInspection/rule/typeSystem/TSDeploymentTableMustNotBeRedeclaredInChildTypes.kt b/src/com/intellij/idea/plugin/hybris/codeInspection/rule/typeSystem/TSDeploymentTableMustNotBeRedeclaredInChildTypes.kt index 00f7eefb5..e7ec0180f 100644 --- a/src/com/intellij/idea/plugin/hybris/codeInspection/rule/typeSystem/TSDeploymentTableMustNotBeRedeclaredInChildTypes.kt +++ b/src/com/intellij/idea/plugin/hybris/codeInspection/rule/typeSystem/TSDeploymentTableMustNotBeRedeclaredInChildTypes.kt @@ -1,6 +1,6 @@ /* * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. - * Copyright (C) 2019 EPAM Systems + * Copyright (C) 2019-2023 EPAM Systems and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -19,6 +19,7 @@ package com.intellij.idea.plugin.hybris.codeInspection.rule.typeSystem import com.intellij.idea.plugin.hybris.codeInspection.fix.xml.XmlDeleteSubTagQuickFix +import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message import com.intellij.idea.plugin.hybris.system.type.meta.TSMetaModelAccess import com.intellij.idea.plugin.hybris.system.type.model.ItemType import com.intellij.idea.plugin.hybris.system.type.model.Items @@ -27,7 +28,6 @@ import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.project.Project import com.intellij.util.xml.highlighting.DomElementAnnotationHolder import com.intellij.util.xml.highlighting.DomHighlightingHelper -import org.apache.commons.lang3.StringUtils class TSDeploymentTableMustNotBeRedeclaredInChildTypes : AbstractTSInspection() { @@ -51,19 +51,26 @@ class TSDeploymentTableMustNotBeRedeclaredInChildTypes : AbstractTSInspection() ?: return val currentMetaTypeCode = metaItem.deployment?.typeCode + ?.takeIf { it.isNotBlank() } + ?: return - if (StringUtils.isBlank(currentMetaTypeCode)) return - - val countDeploymentTablesInParents = metaItem.allExtends + val metaItemParent = metaItem.allExtends .flatMap { it.declarations } - .count { StringUtils.isNotBlank(it.deployment?.typeCode) } + .firstOrNull { it.deployment?.typeCode?.isNotBlank() ?: false } + ?: return - if (countDeploymentTablesInParents == 0) return + val message = message( + "hybris.inspections.ts.DeploymentTableMustNotBeRedeclaredInChildTypes.problem.key", + metaItem.name ?: "?", + currentMetaTypeCode, + metaItemParent.name ?: "?", + metaItemParent.deployment?.typeCode ?: "?" + ) holder.createProblem( dom, severity, - displayName, + message, getTextRange(dom), XmlDeleteSubTagQuickFix(ItemType.DEPLOYMENT) )