Search in sources :

Example 1 with RouteStub

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));
            });
        }
    }
}
Also used : StringLiteralExpression(com.jetbrains.php.lang.psi.elements.StringLiteralExpression) RouteStub(com.cedricziel.idea.typo3.routing.RouteStub) PsiElement(com.intellij.psi.PsiElement)

Example 2 with RouteStub

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());
}
Also used : RouteStub(com.cedricziel.idea.typo3.routing.RouteStub)

Aggregations

RouteStub (com.cedricziel.idea.typo3.routing.RouteStub)2 PsiElement (com.intellij.psi.PsiElement)1 StringLiteralExpression (com.jetbrains.php.lang.psi.elements.StringLiteralExpression)1