@Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if (!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } XmlEventParser xmlEventParser = ServiceXmlParserFactory.getInstance( completionParameters.getPosition().getProject(), XmlEventParser.class); for (Map.Entry<String, String> event : xmlEventParser.get().entrySet()) { completionResultSet.addElement( LookupElementBuilder.create(event.getKey()) .withTypeText(event.getValue(), true) .withIcon(Symfony2Icons.EVENT)); } for (EventDispatcherSubscribedEvent event : EventDispatcherSubscriberUtil.getSubscribedEvents( completionParameters.getPosition().getProject())) { completionResultSet.addElement( LookupElementBuilder.create(event.getStringValue()) .withTypeText("EventSubscriber", true) .withIcon(Symfony2Icons.EVENT)); } }
@Test public void testParse() throws Exception { File testFile = new File(this.getClass().getResource("appDevDebugProjectContainer.xml").getFile()); XmlEventParser serviceMapParser = new XmlEventParser(); serviceMapParser.parser(testFile); Map<String, String> tags = serviceMapParser.get(); assertTrue(tags.containsKey("kernel.controller")); assertEquals("kernel.event_listener", tags.get("kernel.controller")); assertTrue(serviceMapParser.getEventSubscribers("kernel.controller").size() > 0); assertEquals( "Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RouterDataCollector", serviceMapParser.getEventSubscribers("kernel.controller").get(0).getFqnClassName()); }