|
10 | 10 | import fr.adrienbrault.idea.symfony2plugin.dic.XmlServiceParser;
|
11 | 11 | import fr.adrienbrault.idea.symfony2plugin.routing.Route;
|
12 | 12 | import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper;
|
| 13 | +import fr.adrienbrault.idea.symfony2plugin.stubs.ContainerCollectionResolver; |
13 | 14 | import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;
|
14 | 15 | import fr.adrienbrault.idea.symfony2plugin.util.PhpIndexUtil;
|
15 | 16 | import fr.adrienbrault.idea.symfony2plugin.util.SymfonyBundleUtil;
|
| 17 | +import fr.adrienbrault.idea.symfony2plugin.util.dict.ServiceUtil; |
16 | 18 | import fr.adrienbrault.idea.symfony2plugin.util.dict.SymfonyBundle;
|
17 | 19 | import fr.adrienbrault.idea.symfony2plugin.util.service.ServiceXmlParserFactory;
|
18 | 20 | import org.jetbrains.annotations.Nullable;
|
|
21 | 23 |
|
22 | 24 | public class ControllerIndex {
|
23 | 25 |
|
24 |
| - Project project; |
25 |
| - PhpIndex phpIndex; |
| 26 | + private Project project; |
| 27 | + private PhpIndex phpIndex; |
| 28 | + |
| 29 | + private ContainerCollectionResolver.LazyServiceCollector lazyServiceCollector; |
26 | 30 |
|
27 | 31 | public ControllerIndex(Project project) {
|
28 | 32 | this.project = project;
|
@@ -52,20 +56,17 @@ public ControllerAction getControllerActionOnService(String shortcutName) {
|
52 | 56 | String serviceId = shortcutName.substring(0, shortcutName.lastIndexOf(":"));
|
53 | 57 | String methodName = shortcutName.substring(shortcutName.lastIndexOf(":") + 1);
|
54 | 58 |
|
55 |
| - ServiceMap serviceMap = ServiceXmlParserFactory.getInstance(this.project, XmlServiceParser.class).getServiceMap(); |
56 |
| - |
57 |
| - if(serviceMap.getMap().containsKey(serviceId)) { |
58 |
| - Collection<? extends PhpNamedElement> methodCalls = this.phpIndex.getBySignature("#M#C" + serviceMap.getMap().get(serviceId) + "." + methodName, null, 0); |
59 |
| - |
60 |
| - for(PhpNamedElement phpNamedElement : methodCalls) { |
61 |
| - if(phpNamedElement instanceof Method) { |
62 |
| - return new ControllerAction(serviceId, (Method) phpNamedElement); |
63 |
| - } |
64 |
| - } |
| 59 | + PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(this.project, serviceId, getLazyServiceCollector(this.project)); |
| 60 | + if(phpClass == null) { |
| 61 | + return null; |
| 62 | + } |
65 | 63 |
|
| 64 | + Method method = phpClass.findMethodByName(methodName); |
| 65 | + if(method == null) { |
| 66 | + return null; |
66 | 67 | }
|
67 | 68 |
|
68 |
| - return null; |
| 69 | + return new ControllerAction(serviceId, method); |
69 | 70 | }
|
70 | 71 |
|
71 | 72 | @Nullable
|
@@ -190,6 +191,10 @@ public Method resolveShortcutName(String controllerName) {
|
190 | 191 | return null;
|
191 | 192 | }
|
192 | 193 |
|
| 194 | + private ContainerCollectionResolver.LazyServiceCollector getLazyServiceCollector(Project project) { |
| 195 | + return this.lazyServiceCollector == null ? this.lazyServiceCollector = new ContainerCollectionResolver.LazyServiceCollector(project) : this.lazyServiceCollector; |
| 196 | + } |
| 197 | + |
193 | 198 | static public List<LookupElement> getControllerLookupElements(Project project) {
|
194 | 199 | List<LookupElement> lookupElements = new ArrayList<LookupElement>();
|
195 | 200 |
|
|
0 commit comments