forked from unshare/hybris-integration-intellij-idea-plugin
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#307 | Relation qualifier and modifiers must not be declared for part…
… with navigable false
- Loading branch information
1 parent
e725007
commit c1081f1
Showing
14 changed files
with
134 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ces/inspectionDescriptions/TSQualifierAndModifiersMustNotBeDeclaredForNavigableFalse.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
~ This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. | ||
~ Copyright (C) 2019 EPAM Systems <[email protected]> | ||
~ | ||
~ This program is free software: you can redistribute it and/or modify | ||
~ it under the terms of the GNU Lesser General Public License as | ||
~ published by the Free Software Foundation, either version 3 of the | ||
~ License, or (at your option) any later version. | ||
~ | ||
~ This program is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
~ See the GNU Lesser General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU Lesser General Public License | ||
~ along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<html> | ||
<body> | ||
Qualifier and modifiers must not be declared for navigable false in many-to-many relation | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...deInspection/rule/typeSystem/TSQualifierAndModifiersMustNotBeDeclaredForNavigableFalse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. | ||
* Copyright (C) 2019 EPAM Systems <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.intellij.idea.plugin.hybris.codeInspection.rule.typeSystem | ||
|
||
import com.intellij.idea.plugin.hybris.codeInspection.fix.XmlDeleteAttributeQuickFix | ||
import com.intellij.idea.plugin.hybris.codeInspection.fix.XmlDeleteTagQuickFix | ||
import com.intellij.idea.plugin.hybris.system.type.model.* | ||
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 | ||
|
||
class TSQualifierAndModifiersMustNotBeDeclaredForNavigableFalse : AbstractTSInspection() { | ||
override fun inspect( | ||
project: Project, | ||
dom: Items, | ||
holder: DomElementAnnotationHolder, | ||
helper: DomHighlightingHelper, | ||
severity: HighlightSeverity | ||
) { | ||
dom.relations.relations | ||
.filter { it.sourceElement.cardinality === Cardinality.MANY && it.targetElement.cardinality === Cardinality.MANY } | ||
.filter { !it.sourceElement.navigable || !it.targetElement.navigable } | ||
.forEach { | ||
checkNonNavigable(it.sourceElement, holder, severity) | ||
checkNonNavigable(it.targetElement, holder, severity) | ||
} | ||
} | ||
|
||
private fun checkNonNavigable( | ||
relationElement: RelationElement, | ||
holder: DomElementAnnotationHolder, | ||
severity: HighlightSeverity, | ||
) { | ||
if (relationElement.navigable) { | ||
return | ||
} | ||
|
||
if (relationElement.qualifier.exists()) { | ||
holder.createProblem( | ||
relationElement.qualifier, | ||
severity, | ||
displayName, | ||
XmlDeleteAttributeQuickFix(relationElement.qualifier.value) | ||
) | ||
} | ||
if (relationElement.modifiers.exists()) { | ||
holder.createProblem( | ||
relationElement.modifiers, | ||
severity, | ||
displayName, | ||
XmlDeleteTagQuickFix() | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters