3
3
import com .intellij .codeInsight .daemon .LineMarkerInfo ;
4
4
import com .intellij .codeInsight .daemon .LineMarkerProvider ;
5
5
import com .intellij .codeInsight .navigation .NavigationGutterIconBuilder ;
6
+ import com .intellij .icons .AllIcons ;
7
+ import com .intellij .openapi .util .NotNullLazyValue ;
6
8
import com .intellij .psi .PsiElement ;
7
9
import fr .adrienbrault .idea .symfony2plugin .Symfony2ProjectComponent ;
8
10
import fr .adrienbrault .idea .symfony2plugin .config .yaml .YamlElementPatternHelper ;
11
+ import fr .adrienbrault .idea .symfony2plugin .config .yaml .YamlGoToDeclarationHandler ;
9
12
import fr .adrienbrault .idea .symfony2plugin .util .dict .ServiceUtil ;
10
13
import fr .adrienbrault .idea .symfony2plugin .util .yaml .YamlHelper ;
11
14
import org .apache .commons .lang .StringUtils ;
@@ -52,7 +55,30 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
52
55
53
56
// services -> service_name
54
57
visitServiceId (psiElement , (YAMLKeyValue ) yamlKeyValue , result , lazyDecoratedServices );
58
+
59
+ // services:
60
+ // App\:
61
+ // resource: '../src/*'
62
+ visitServiceIdForResources (psiElement , (YAMLKeyValue ) yamlKeyValue , result );
63
+ }
64
+ }
65
+
66
+ private void visitServiceIdForResources (PsiElement leafTarget , YAMLKeyValue yamlKeyValue , @ NotNull Collection <LineMarkerInfo > result ) {
67
+ String resource = YamlHelper .getYamlKeyValueAsString (yamlKeyValue , "resource" );
68
+ if (resource == null ) {
69
+ return ;
55
70
}
71
+
72
+ result .add (NavigationGutterIconBuilder .create (AllIcons .Modules .SourceRoot )
73
+ .setTargets (new NotNullLazyValue <Collection <? extends PsiElement >>() {
74
+ @ NotNull
75
+ @ Override
76
+ protected Collection <? extends PsiElement > compute () {
77
+ return YamlGoToDeclarationHandler .getClassesForServiceKey (yamlKeyValue );
78
+ }
79
+ })
80
+ .setTooltipText ("Navigate to class" )
81
+ .createLineMarkerInfo (leafTarget ));
56
82
}
57
83
58
84
private void visitServiceId (@ NotNull PsiElement leafTarget , @ NotNull YAMLKeyValue yamlKeyValue , @ NotNull Collection <LineMarkerInfo > result , @ NotNull LazyDecoratedParentServiceValues lazyDecoratedServices ) {
@@ -63,13 +89,13 @@ private void visitServiceId(@NotNull PsiElement leafTarget, @NotNull YAMLKeyValu
63
89
64
90
// decorates: foobar
65
91
String decorates = YamlHelper .getYamlKeyValueAsString (yamlKeyValue , "decorates" );
66
- if (decorates != null && StringUtils .isNotBlank (decorates )) {
92
+ if (StringUtils .isNotBlank (decorates )) {
67
93
result .add (ServiceUtil .getLineMarkerForDecoratesServiceId (leafTarget , ServiceUtil .ServiceLineMarker .DECORATE , decorates ));
68
94
}
69
95
70
96
// parent: foobar
71
97
String parent = YamlHelper .getYamlKeyValueAsString (yamlKeyValue , "parent" );
72
- if (parent != null && StringUtils .isNotBlank (parent )) {
98
+ if (StringUtils .isNotBlank (parent )) {
73
99
result .add (ServiceUtil .getLineMarkerForDecoratesServiceId (leafTarget , ServiceUtil .ServiceLineMarker .PARENT , parent ));
74
100
}
75
101
0 commit comments