|
6 | 6 | import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
|
7 | 7 | import com.intellij.openapi.project.Project;
|
8 | 8 | import com.intellij.psi.PsiElement;
|
| 9 | +import com.intellij.psi.PsiFile; |
9 | 10 | import com.intellij.psi.util.PsiTreeUtil;
|
10 | 11 | import com.jetbrains.php.lang.psi.elements.*;
|
11 | 12 | import fr.adrienbrault.idea.symfony2plugin.Settings;
|
12 | 13 | import fr.adrienbrault.idea.symfony2plugin.Symfony2Icons;
|
13 | 14 | import fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil;
|
14 | 15 | import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
|
15 | 16 | import fr.adrienbrault.idea.symfony2plugin.dic.XmlServiceParser;
|
| 17 | +import fr.adrienbrault.idea.symfony2plugin.doctrine.EntityHelper; |
16 | 18 | import fr.adrienbrault.idea.symfony2plugin.form.util.FormUtil;
|
17 | 19 | import fr.adrienbrault.idea.symfony2plugin.stubs.ServiceIndexUtil;
|
18 | 20 | import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;
|
| 21 | +import fr.adrienbrault.idea.symfony2plugin.util.dict.DoctrineModel; |
19 | 22 | import fr.adrienbrault.idea.symfony2plugin.util.service.ServiceXmlParserFactory;
|
20 | 23 | import org.apache.commons.lang.StringUtils;
|
21 | 24 | import org.jetbrains.annotations.NotNull;
|
@@ -55,6 +58,7 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
|
55 | 58 |
|
56 | 59 | if(PhpElementsUtil.getClassNamePattern().accepts(psiElement)) {
|
57 | 60 | this.classNameMarker(psiElement, results);
|
| 61 | + this.entityClassMarker(psiElement, results); |
58 | 62 | }
|
59 | 63 |
|
60 | 64 | if(phpHighlightServices) {
|
@@ -121,6 +125,38 @@ private void classNameMarker(PsiElement psiElement, Collection<? super RelatedIt
|
121 | 125 |
|
122 | 126 | }
|
123 | 127 |
|
| 128 | + private void entityClassMarker(PsiElement psiElement, Collection<? super RelatedItemLineMarkerInfo> result) { |
| 129 | + |
| 130 | + PsiElement phpClassContext = psiElement.getContext(); |
| 131 | + if(!(phpClassContext instanceof PhpClass)) { |
| 132 | + return; |
| 133 | + } |
| 134 | + |
| 135 | + String originFqn = ((PhpClass) phpClassContext).getPresentableFQN(); |
| 136 | + if(originFqn == null || !originFqn.toLowerCase().contains("entity")) { |
| 137 | + return; |
| 138 | + } |
| 139 | + |
| 140 | + for(DoctrineModel doctrineModel: EntityHelper.getModelClasses(psiElement.getProject())) { |
| 141 | + PhpClass phpClass = doctrineModel.getPhpClass(); |
| 142 | + if(phpClass != null) { |
| 143 | + String presentableFQN = phpClass.getPresentableFQN(); |
| 144 | + |
| 145 | + if(presentableFQN != null && presentableFQN.equals(originFqn)) { |
| 146 | + PsiFile psiFile = EntityHelper.getModelConfigFile(phpClass); |
| 147 | + if(psiFile != null) { |
| 148 | + NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.DOCTRINE_LINE_MARKER). |
| 149 | + setTarget(psiFile). |
| 150 | + setTooltipText("Navigate to model"); |
| 151 | + |
| 152 | + result.add(builder.createLineMarkerInfo(psiElement)); |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | + |
| 158 | + } |
| 159 | + |
124 | 160 | private void formNameMarker(PsiElement psiElement, Collection<? super RelatedItemLineMarkerInfo> result) {
|
125 | 161 |
|
126 | 162 | if(!(psiElement instanceof StringLiteralExpression)) {
|
|
0 commit comments