Skip to content

Commit 43c5c95

Browse files
committed
only getOwnFields is not having cache issues for extracting routes by its constants
1 parent d2e8a8d commit 43c5c95

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,17 @@ public static Map<String, Route> getRoutesInsideUrlGeneratorFile(@NotNull PsiFil
393393

394394
// Symfony < 2.8
395395
// static private $declaredRoutes = array(...)
396-
Field declaredRoutes = phpClass.findOwnFieldByName("declaredRoutes", true);
397-
if (declaredRoutes != null) {
398-
PsiElement defaultValue = declaredRoutes.getDefaultValue();
399-
if(!(defaultValue instanceof ArrayCreationExpression)) {
400-
continue;
401-
}
396+
// only "getOwnFields" is uncached and dont breaks; find* methods are cached resulting in exceptions
397+
Field[] ownFields = phpClass.getOwnFields();
398+
for (Field ownField : ownFields) {
399+
if ("declaredRoutes".equals(ownField.getName())) {
400+
PsiElement defaultValue = ownField.getDefaultValue();
401+
if(!(defaultValue instanceof ArrayCreationExpression)) {
402+
continue;
403+
}
402404

403-
collectRoutesOnArrayCreation(routes, (ArrayCreationExpression) defaultValue);
405+
collectRoutesOnArrayCreation(routes, (ArrayCreationExpression) defaultValue);
406+
}
404407
}
405408

406409
// Symfony >= 2.8

0 commit comments

Comments
 (0)