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.
#257 | Improved performance of the Global Meta Model and TS LineMarker
- Loading branch information
Showing
44 changed files
with
468 additions
and
486 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
<li><a href="https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/setting_up_environment.html">How to Configure Project Environment For Plugin Developers</a></li> | ||
<li>We are working with <a href="https://help.github.com/articles/about-pull-requests/">Pull Requests</a>. You need to fork this repository, implement a feature in a separate branch, then send us a pull request.</li> | ||
<li>Be sure to include into your pull request and all commit messages the following line: "Signed-off-by: Your Real Name [email protected]" otherwise it can not be accepted. Use your real name.</li> | ||
<li>For additional questions you can send an <a href="mailto:[email protected]">email</a></li>§ | ||
<li>For additional questions you can send an <a href="mailto:[email protected]">email</a></li> | ||
</ul> | ||
<h3>Contributors and Developers</h3> | ||
|
@@ -91,6 +91,10 @@ | |
|
||
<change-notes> | ||
<![CDATA[ | ||
<h3>2023.1.2</h3> | ||
<ul> | ||
<li><i>Feature:</i> Improved performance of the Global Meta Model and TS LineMarker (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/257" target="_blank" rel="nofollow">#257</a>)</li> | ||
</ul> | ||
<h3>2023.1.1</h3> | ||
<ul> | ||
<li><i>Feature:</i> Added possibility to import CCv2 folders as modules (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/238" target="_blank" rel="nofollow">#238</a>)</li> | ||
|
98 changes: 0 additions & 98 deletions
98
src/com/intellij/idea/plugin/hybris/codeInsight/daemon/AbstractItemLineMarkerProvider.java
This file was deleted.
Oops, something went wrong.
135 changes: 0 additions & 135 deletions
135
...intellij/idea/plugin/hybris/codeInsight/daemon/AbstractTSAttributeLineMarkerProvider.java
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
...m/intellij/idea/plugin/hybris/codeInsight/daemon/AbstractTSAttributeLineMarkerProvider.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,83 @@ | ||
/* | ||
* 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.codeInsight.daemon | ||
|
||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo | ||
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message | ||
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons | ||
import com.intellij.idea.plugin.hybris.system.type.meta.TSMetaModelAccess | ||
import com.intellij.idea.plugin.hybris.system.type.meta.model.TSGlobalMetaItem | ||
import com.intellij.idea.plugin.hybris.system.type.meta.model.TSMetaRelation.RelationEnd | ||
import com.intellij.idea.plugin.hybris.system.type.utils.ModelsUtils | ||
import com.intellij.psi.PsiClass | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiIdentifier | ||
import com.intellij.psi.xml.XmlElement | ||
import javax.swing.Icon | ||
|
||
abstract class AbstractTSAttributeLineMarkerProvider<T : PsiElement> : AbstractTSItemLineMarkerProvider<T>() { | ||
|
||
override fun getTooltipText() = message("hybris.editor.gutter.item.attribute.tooltip.navigate.declaration") | ||
override fun getPopupTitle() = message("hybris.editor.gutter.bean.attribute.navigate.choose.class.title") | ||
override fun getEmptyPopupText() = message("hybris.editor.gutter.navigate.no.matching.attributes") | ||
|
||
override fun collectDeclarations(psi: T): RelatedItemLineMarkerInfo<PsiElement>? { | ||
val psiClass = psi.parent | ||
if (psiClass !is PsiClass || !ModelsUtils.isModelFile(psiClass)) return null | ||
|
||
return TSMetaModelAccess.getInstance(psi.project).findMetaItemByName(cleanSearchName(psiClass.name)) | ||
?.let { collect(it, psi) } | ||
} | ||
|
||
protected abstract fun collect(meta: TSGlobalMetaItem, psi: T): RelatedItemLineMarkerInfo<PsiElement>? | ||
|
||
protected open fun getPsiElementRelatedItemLineMarkerInfo( | ||
meta: TSGlobalMetaItem, name: String, nameIdentifier: PsiIdentifier | ||
) = with(getAttributeElements(meta, name)) { | ||
if (this.isEmpty()) { | ||
val groupedRelElements = getRelations(meta, name) | ||
return@with getRelationMarkers(groupedRelElements, RelationEnd.SOURCE, HybrisIcons.TS_RELATION_SOURCE, nameIdentifier) | ||
?: getRelationMarkers(groupedRelElements, RelationEnd.TARGET, HybrisIcons.TS_RELATION_TARGET, nameIdentifier) | ||
} else { | ||
return@with createTargetsWithGutterIcon(nameIdentifier, this, HybrisIcons.TS_ATTRIBUTE) | ||
} | ||
} | ||
|
||
open fun getAttributeElements(meta: TSGlobalMetaItem, name: String) = meta.allAttributes | ||
.filter { it.name == name } | ||
.flatMap { it.declarations } | ||
.map { it.domAnchor } | ||
.mapNotNull { it.retrieveDomElement() } | ||
.mapNotNull { it.xmlElement } | ||
|
||
open fun getRelations(meta: TSGlobalMetaItem, name: String) = meta.allRelationEnds | ||
.filter { it.qualifier == name } | ||
.filter { it.isNavigable } | ||
.filter { it.domAnchor.retrieveDomElement()?.xmlElement != null } | ||
.groupBy({ it.end }, { it.domAnchor.retrieveDomElement()!!.xmlElement!! }) | ||
|
||
open fun getRelationMarkers( | ||
groupedRelElements: Map<RelationEnd, List<XmlElement?>>, | ||
target: RelationEnd, | ||
icon: Icon, | ||
nameIdentifier: PsiIdentifier | ||
) = groupedRelElements[target] | ||
?.let { createTargetsWithGutterIcon(nameIdentifier, it, icon) } | ||
|
||
} |
Oops, something went wrong.