Skip to content

Commit c586f82

Browse files
authored
Merge pull request #1460 from Haehnchen/feature/service-cleanup
filter some special debug service and move the into lower priority
2 parents 43a0659 + 1fdc68c commit c586f82

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/XmlService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ public static XmlService createFromXml(@NotNull Element node) {
103103
if (id.startsWith(".")) {
104104
// <service id=".service_locator.XSes1R5" class="Symfony\Component\DependencyInjection\ServiceLocator" public="false">
105105
// <service id=".service_locator.tHpW6v3" alias=".service_locator.Y7gDuDN" public="false"/>
106-
if (id.startsWith(".service_locator") && id.matches("^\\.service_locator.*\\.[\\w_]+$")) {
106+
if (id.startsWith(".service_locator.") || id.startsWith(".abstract.") || id.startsWith(".instanceof.") || id.startsWith(".debug.") || id.startsWith(".errored.")) {
107107
return null;
108108
}
109109

110110
// <service id=".1_ArrayCache~kSL.YwK" class="Doctrine\Common\Cache\ArrayCache" public="false"/>
111111
// <service id=".2_~NpzP6Xn" public="false">
112-
if (id.matches("^\\.[\\w]+_.*\\.[\\w_]+$") || id.matches("^\\.[\\w]+_~[\\w_]+$")) {
112+
if (id.matches("^\\.[\\w-]+~.*$")) {
113113
return null;
114114
}
115115
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/util/ServiceContainerUtil.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,19 @@ public static int getServiceUsage(@NotNull Project project, @NotNull String id)
625625
return usage;
626626
}
627627

628-
public static boolean isLowerPriority(String name) {
629-
for(String lowerName: LOWER_PRIORITY) {
630-
if(name.contains(lowerName)) {
628+
/**
629+
* Move services done which are possible "garbage" or should not be taken like ".debug"
630+
*
631+
* - ".1_~NpzP6Xn"
632+
* - ".debug."
633+
* - "router.debug"
634+
*/
635+
public static boolean isLowerPriority(@NotNull String name) {
636+
for (String lowerName: LOWER_PRIORITY) {
637+
// reduce the
638+
// - ".1_~NpzP6Xn"
639+
// -
640+
if (name.startsWith(".") || name.contains("~") || name.toLowerCase().contains(lowerName)) {
631641
return true;
632642
}
633643
}

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/dic/ServiceMapParserTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ public void testParse() throws Exception {
2626
"<service id=\"translator\" alias=\"adrienbrault\"/>" +
2727
"<service id=\"translator_private\" alias=\"adrienbrault\" public=\"false\"/>" +
2828
"<service id=\".service_locator.SFX6J7Y\" class=\"Symfony\\Component\\DependencyInjection\\ServiceLocator\" public=\"false\"/>" +
29+
"<service id=\".instanceof.SFX6J7Y\" class=\"Symfony\\Component\\DependencyInjection\\ServiceLocator\" public=\"false\"/>" +
30+
"<service id=\".abstract.SFX6J7Y\" class=\"Symfony\\Component\\DependencyInjection\\ServiceLocator\" public=\"false\"/>" +
31+
"<service id=\".debug.SFX6J7Y\" class=\"Symfony\\Component\\DependencyInjection\\ServiceLocator\" public=\"false\"/>" +
32+
"<service id=\".errored.SFX6J7Y\" class=\"Symfony\\Component\\DependencyInjection\\ServiceLocator\" public=\"false\"/>" +
2933
"<service id=\"Psr\\Log\\LoggerInterface $securityLogger\" alias=\"monolog.logger.security\"/>" +
3034
"<service id=\".1_~NpzP6Xn\" public=\"false\"/>" +
3135
"<service id=\".2_PhpArrayAdapter~kSL.YwK\" class=\"Symfony\\Component\\Cache\\Adapter\\PhpArrayAdapter\" public=\"false\"/>" +
36+
"<service id=\".1_RouteLoaderContainer~Na7uo_Q\" class=\"Symfony\\Component\\Cache\\Adapter\\PhpArrayAdapter\" public=\"false\"/>" +
3237
"</container>";
3338

3439
ServiceMap serviceMap = serviceMapParser.parse(new ByteArrayInputStream(xmlString.getBytes()));
@@ -56,5 +61,10 @@ public void testParse() throws Exception {
5661
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".service_locator.SFX6J7Y".equals(s.getId())).count());
5762
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".1_~NpzP6Xn".equals(s.getId())).count());
5863
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".2_PhpArrayAdapter~kSL.YwK".equals(s.getId())).count());
64+
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".1_RouteLoaderContainer~Na7uo_Q".equals(s.getId())).count());
65+
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".abstract.SFX6J7Y".equals(s.getId())).count());
66+
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".instanceof.SFX6J7Y".equals(s.getId())).count());
67+
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".debug.SFX6J7Y".equals(s.getId())).count());
68+
assertEquals(0, serviceMap.getServices().stream().filter(s -> ".errored.SFX6J7Y".equals(s.getId())).count());
5969
}
6070
}

0 commit comments

Comments
 (0)