3636import fr .adrienbrault .idea .symfony2plugin .routing .dic .ServiceRouteContainer ;
3737import fr .adrienbrault .idea .symfony2plugin .routing .dict .RoutingFile ;
3838import fr .adrienbrault .idea .symfony2plugin .stubs .SymfonyProcessors ;
39+ import fr .adrienbrault .idea .symfony2plugin .stubs .cache .FileIndexCaches ;
3940import fr .adrienbrault .idea .symfony2plugin .stubs .dict .StubIndexedRoute ;
4041import fr .adrienbrault .idea .symfony2plugin .stubs .indexes .RoutesStubIndex ;
4142import fr .adrienbrault .idea .symfony2plugin .ui .dict .AbstractUiFilePath ;
@@ -368,7 +369,7 @@ private static Map<String, Route> getCompiledRoutes(@NotNull Project project) {
368369
369370 return CachedValueProvider .Result .create (
370371 Collections .unmodifiableMap (routesContainerMap ),
371- new StringModificationTracker (project ),
372+ new CompiledRoutePathFilesModificationTracker (project ),
372373 new AbsoluteFileModificationTracker (compiledRouteFiles )
373374 );
374375 },
@@ -1154,34 +1155,34 @@ public static List<PsiElement> getRouteDefinitionTargets(Project project, String
11541155 }
11551156
11561157 @ NotNull
1157- synchronized public static Map <String , Route > getAllRoutes (final @ NotNull Project project ) {
1158+ public static Map <String , Route > getAllRoutes (final @ NotNull Project project ) {
11581159 return CachedValuesManager .getManager (project ).getCachedValue (
11591160 project ,
11601161 ROUTE_CACHE ,
1161- () -> CachedValueProvider .Result .create (getAllRoutesProxy (project ), PsiModificationTracker .MODIFICATION_COUNT ),
1162- false
1163- );
1164- }
1165-
1166- @ NotNull
1167- private static Map <String , Route > getAllRoutesProxy (@ NotNull Project project ) {
1168-
1169- Map <String , Route > routes = new HashMap <>(RouteHelper .getCompiledRoutes (project ));
1170-
1171- Set <String > uniqueKeySet = new HashSet <>(routes .keySet ());
1162+ () -> {
1163+ Map <String , Route > routes = new HashMap <>(RouteHelper .getCompiledRoutes (project ));
1164+ Set <String > uniqueKeySet = new HashSet <>(routes .keySet ());
11721165
1173- for (String routeName : SymfonyProcessors .createResult (project , RoutesStubIndex .KEY , uniqueKeySet )) {
1174- if (uniqueKeySet .contains (routeName )) {
1175- continue ;
1176- }
1166+ for (String routeName : SymfonyProcessors .createResult (project , RoutesStubIndex .KEY , uniqueKeySet )) {
1167+ if (uniqueKeySet .contains (routeName )) {
1168+ continue ;
1169+ }
11771170
1178- for (StubIndexedRoute route : FileBasedIndex .getInstance ().getValues (RoutesStubIndex .KEY , routeName , GlobalSearchScope .allScope (project ))) {
1179- uniqueKeySet .add (routeName );
1180- routes .put (routeName , new Route (route ));
1181- }
1182- }
1171+ for (StubIndexedRoute route : FileBasedIndex .getInstance ().getValues (RoutesStubIndex .KEY , routeName , GlobalSearchScope .allScope (project ))) {
1172+ uniqueKeySet .add (routeName );
1173+ routes .put (routeName , new Route (route ));
1174+ }
1175+ }
11831176
1184- return routes ;
1177+ return CachedValueProvider .Result .create (
1178+ Collections .unmodifiableMap (routes ),
1179+ FileIndexCaches .getModificationTrackerForIndexId (project , RoutesStubIndex .KEY ), // index
1180+ new CompiledRoutePathFilesModificationTracker (project ), // compiled
1181+ new AbsoluteFileModificationTracker (getCompiledRouteFiles (project )) // compiled
1182+ );
1183+ },
1184+ false
1185+ );
11851186 }
11861187
11871188 /**
@@ -1204,11 +1205,11 @@ public static boolean isRouteClassAnnotation(@NotNull String clazz) {
12041205 return ROUTE_CLASSES .stream ().anyMatch (s -> s .equalsIgnoreCase (myClazz ));
12051206 }
12061207
1207- private static class StringModificationTracker extends SimpleModificationTracker {
1208+ private static class CompiledRoutePathFilesModificationTracker extends SimpleModificationTracker {
12081209 private final @ NotNull Project project ;
12091210 private int last = 0 ;
12101211
1211- public StringModificationTracker (@ NotNull Project project ) {
1212+ public CompiledRoutePathFilesModificationTracker (@ NotNull Project project ) {
12121213 this .project = project ;
12131214 }
12141215
0 commit comments