Skip to content

Commit 512a8b1

Browse files
committed
use idiomatic streaming for getRoutesForPathWithPlaceholderMatch
1 parent 8e4684d commit 512a8b1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,17 @@ public static PsiElement[] getMethodsForPathWithPlaceholderMatch(@NotNull Projec
197197
*/
198198
@NotNull
199199
public static Collection<Route> getRoutesForPathWithPlaceholderMatch(@NotNull Project project, @NotNull String searchPath) {
200-
Collection<Route> targets = new ArrayList<>();
201-
202-
RouteHelper.getAllRoutes(project).values()
200+
return new ArrayList<>(RouteHelper.getAllRoutes(project).values())
203201
.parallelStream()
204-
.forEach(route -> {
205-
if (route != null && isReverseRoutePatternMatch(route, searchPath)) {
206-
targets.add(route);
202+
.filter(Objects::nonNull)
203+
.map(route -> {
204+
if (isReverseRoutePatternMatch(route, searchPath)) {
205+
return route;
207206
}
208-
});
209-
210-
return targets;
207+
return null;
208+
})
209+
.filter(Objects::nonNull)
210+
.collect(Collectors.toList());
211211
}
212212

213213
/**

0 commit comments

Comments
 (0)