4
4
import com .intellij .codeInsight .daemon .LineMarkerProvider ;
5
5
import com .intellij .codeInsight .daemon .RelatedItemLineMarkerInfo ;
6
6
import com .intellij .codeInsight .navigation .NavigationGutterIconBuilder ;
7
+ import com .intellij .icons .AllIcons ;
8
+ import com .intellij .openapi .util .NotNullLazyValue ;
7
9
import com .intellij .patterns .XmlPatterns ;
8
10
import com .intellij .patterns .XmlTagPattern ;
9
11
import com .intellij .psi .PsiElement ;
12
14
import com .intellij .psi .xml .XmlTag ;
13
15
import fr .adrienbrault .idea .symfony2plugin .Symfony2Icons ;
14
16
import fr .adrienbrault .idea .symfony2plugin .Symfony2ProjectComponent ;
17
+ import fr .adrienbrault .idea .symfony2plugin .config .ServiceLineMarkerProvider ;
15
18
import fr .adrienbrault .idea .symfony2plugin .config .xml .XmlHelper ;
19
+ import fr .adrienbrault .idea .symfony2plugin .dic .container .util .ServiceContainerUtil ;
20
+ import fr .adrienbrault .idea .symfony2plugin .util .PsiElementUtils ;
16
21
import fr .adrienbrault .idea .symfony2plugin .util .resource .FileResourceUtil ;
22
+ import org .apache .commons .lang .StringUtils ;
17
23
import org .jetbrains .annotations .NotNull ;
18
24
import org .jetbrains .annotations .Nullable ;
19
25
26
+ import java .util .Arrays ;
20
27
import java .util .Collection ;
28
+ import java .util .Collections ;
21
29
import java .util .List ;
30
+ import java .util .function .Supplier ;
22
31
23
32
/**
24
33
* @author Daniel Espendiller <daniel@espendiller.net>
@@ -39,6 +48,10 @@ public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElemen
39
48
for (PsiElement psiElement : psiElements ) {
40
49
if (XmlHelper .getXmlTagNameLeafStartPattern ().accepts (psiElement )) {
41
50
attachRouteActions (psiElement , lineMarkerInfos );
51
+ attachRouteImport (psiElement , lineMarkerInfos );
52
+
53
+
54
+
42
55
} else if (psiElement instanceof XmlFile ) {
43
56
RelatedItemLineMarkerInfo <PsiElement > lineMarker = FileResourceUtil .getFileImplementsLineMarker ((PsiFile ) psiElement );
44
57
if (lineMarker != null ) {
@@ -68,6 +81,30 @@ private void attachRouteActions(@NotNull PsiElement psiElement, @NotNull Collect
68
81
}
69
82
}
70
83
84
+ private void attachRouteImport (@ NotNull PsiElement psiElement , @ NotNull Collection <? super LineMarkerInfo <?>> lineMarkerInfos ) {
85
+ PsiElement xmlTag = psiElement .getParent ();
86
+ if (!(xmlTag instanceof XmlTag ) || !Pattern .getRouteImport ().accepts (xmlTag )) {
87
+ return ;
88
+ }
89
+
90
+ if (!"annotation" .equals (((XmlTag ) xmlTag ).getAttributeValue ("type" ))) {
91
+ return ;
92
+ }
93
+
94
+ String resource = ((XmlTag ) xmlTag ).getAttributeValue ("resource" );
95
+ if (StringUtils .isBlank (resource )) {
96
+ return ;
97
+ }
98
+
99
+ lineMarkerInfos .add (
100
+ FileResourceUtil .getNavigationGutterForRouteAnnotationResources (
101
+ psiElement .getProject (),
102
+ psiElement .getContainingFile ().getVirtualFile (),
103
+ resource
104
+ ).createLineMarkerInfo (psiElement )
105
+ );
106
+ }
107
+
71
108
@ Nullable
72
109
@ Override
73
110
public LineMarkerInfo <?> getLineMarkerInfo (@ NotNull PsiElement psiElement ) {
@@ -82,6 +119,11 @@ public static XmlTagPattern.Capture getRouteTag() {
82
119
).inFile (XmlHelper .getXmlFilePattern ());
83
120
}
84
121
122
+ public static XmlTagPattern .Capture getRouteImport () {
123
+ return XmlPatterns .xmlTag ().withName ("import" ).withParent (
124
+ XmlPatterns .xmlTag ().withName ("routes" )
125
+ ).inFile (XmlHelper .getXmlFilePattern ());
126
+ }
85
127
}
86
128
87
129
}
0 commit comments