use of com.cedricziel.idea.typo3.routing.RouteStub in project idea-php-typo3-plugin by cedricziel.
the class RouteLineMarkerProvider method collectNavigationMarkers.
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
if (!(element instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) element;
String value = literalExpression.getContents();
if (value.isEmpty()) {
return;
}
PsiElement methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
if (PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "getAjaxUrl") || PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "buildUriFromRoute")) {
if (RouteIndex.hasRoute(element.getProject(), value)) {
Collection<RouteStub> routes = RouteIndex.getRoute(element.getProject(), value);
routes.forEach(def -> {
PsiElement[] routeDefinitionElements = RouteHelper.getRouteDefinitionElements(element.getProject(), value);
NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(TYPO3CMSIcons.ROUTE_ICON).setTargets(routeDefinitionElements);
if (def.getPath() != null) {
builder.setTooltipTitle("Path: " + def.getPath());
}
result.add(builder.createLineMarkerInfo(element));
});
}
}
}
use of com.cedricziel.idea.typo3.routing.RouteStub in project idea-php-typo3-plugin by cedricziel.
the class RouteIndexTest method assertRouteStubEquals.
private void assertRouteStubEquals(String name, String path, String controllerClass, String action, String access) {
RouteStub stub = RouteIndex.getRoute(myFixture.getProject(), name).iterator().next();
assertEquals(name, stub.getName());
assertEquals(path, stub.getPath());
assertEquals(controllerClass, stub.getController());
assertEquals(action, stub.getMethod());
assertEquals(access, stub.getAccess());
}
Aggregations