|
7 | 7 | import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
|
8 | 8 | import fr.adrienbrault.idea.symfony2plugin.config.yaml.YamlElementPatternHelper;
|
9 | 9 | import fr.adrienbrault.idea.symfony2plugin.dic.ContainerService;
|
10 |
| -import fr.adrienbrault.idea.symfony2plugin.stubs.ServiceIndexUtil; |
11 | 10 | import fr.adrienbrault.idea.symfony2plugin.util.dict.ServiceUtil;
|
12 | 11 | import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
|
13 | 12 | import org.apache.commons.lang.StringUtils;
|
@@ -39,32 +38,34 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
|
39 | 38 | return;
|
40 | 39 | }
|
41 | 40 |
|
| 41 | + final LazyDecoratedServiceValues[] lazyDecoratedServices = {null}; |
| 42 | + |
42 | 43 | // services -> service_name
|
43 | 44 | psiElements.stream()
|
44 | 45 | .filter(psiElement -> psiElement instanceof YAMLKeyValue && YamlElementPatternHelper.getServiceIdKeyValuePattern().accepts(psiElement))
|
45 |
| - .forEach(psiElement -> visitServiceId((YAMLKeyValue) psiElement, result)); |
| 46 | + .forEach((PsiElement psiElement) -> { |
| 47 | + if(lazyDecoratedServices[0] == null) { |
| 48 | + lazyDecoratedServices[0] = new LazyDecoratedServiceValues(psiElements.get(0).getProject()); |
| 49 | + } |
46 | 50 |
|
47 |
| - decoratedServiceCache = null; |
| 51 | + visitServiceId((YAMLKeyValue) psiElement, result, lazyDecoratedServices[0]); |
| 52 | + }); |
48 | 53 | }
|
49 | 54 |
|
50 |
| - private void visitServiceId(@NotNull YAMLKeyValue yamlKeyValue, @NotNull Collection<LineMarkerInfo> result) { |
| 55 | + private void visitServiceId(@NotNull YAMLKeyValue yamlKeyValue, @NotNull Collection<LineMarkerInfo> result, @NotNull LazyDecoratedServiceValues lazyDecoratedServices) { |
51 | 56 | String id = yamlKeyValue.getKeyText();
|
52 | 57 | if(StringUtils.isBlank(id)) {
|
53 | 58 | return;
|
54 | 59 | }
|
55 | 60 |
|
56 | 61 | // decorates: @foobar
|
57 | 62 | String decorates = YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "decorates");
|
58 |
| - if(StringUtils.isNotBlank(decorates)) { |
| 63 | + if(decorates != null && StringUtils.isNotBlank(decorates)) { |
59 | 64 | result.add(ServiceUtil.getLineMarkerForDecoratesServiceId(yamlKeyValue, decorates, result));
|
60 | 65 | }
|
61 | 66 |
|
62 |
| - if(this.decoratedServiceCache == null) { |
63 |
| - this.decoratedServiceCache = ServiceIndexUtil.getDecoratedServices(yamlKeyValue.getProject()); |
64 |
| - } |
65 |
| - |
66 | 67 | NavigationGutterIconBuilder<PsiElement> lineMarker = ServiceUtil.getLineMarkerForDecoratedServiceId(
|
67 |
| - yamlKeyValue.getProject(), this.decoratedServiceCache, id |
| 68 | + yamlKeyValue.getProject(), lazyDecoratedServices.getDecoratedServices(), id |
68 | 69 | );
|
69 | 70 |
|
70 | 71 | if(lineMarker == null) {
|
|
0 commit comments