fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionRegistrarParameter Java Examples

The following examples show how to use fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionRegistrarParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoutingGotoCompletionRegistrar.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement(), psiElement -> {
        if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent != null && (
            MethodMatcher.getMatchedSignatureWithDepth(parent, URL_GENERATOR) != null ||
            PhpElementsUtil.isFunctionReference(parent, 0, "route") ||
            PhpElementsUtil.isFunctionReference(parent, 0, "link_to_route")
        )) {
            return new RouteNameGotoCompletionProvider(parent);
        }

        return null;
    });
}
 
Example #2
Source File: TranslationPlaceholderGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // {{ 'symfony.great'|trans({'fo<caret>f'}, 'symfony')) }}
    registrar.register(
        TwigPattern.getFunctionWithFirstParameterAsKeyLiteralPattern("trans"),
        new MyTwigTransFilterCompletionContributor("trans")
    );

    // {{ 'symfony.great'|transchoice(12, {'fo<caret>f'}, 'symfony')) }}
    registrar.register(
        TwigPattern.getFunctionWithSecondParameterAsKeyLiteralPattern("transchoice"),
        new MyTwigTransFilterCompletionContributor("transchoice")
    );

    // $x->trans('symfony.great', ['%fo<caret>obar%', null], 'symfony')
    registrar.register(
        PlatformPatterns.psiElement().withParent(StringLiteralExpression.class),
        new MyPhpTranslationCompletionContributor("trans", 1, 2)
    );

    // $x->transChoice('symfony.great', 10, ['%fo<caret>obar%', null], 'symfony')
    registrar.register(
        PlatformPatterns.psiElement().withParent(StringLiteralExpression.class),
        new MyPhpTranslationCompletionContributor("transChoice", 2, 3)
    );
}
 
Example #3
Source File: PhpMessageSubscriberGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(REGISTRAR_PATTERN, psiElement -> {
        Method method = PsiTreeUtil.getParentOfType(psiElement, Method.class, true, Function.class);

        if (method == null) {
            return null;
        }

        if (!PhpElementsUtil.isMethodInstanceOf(method, "\\Symfony\\Component\\Messenger\\Handler\\MessageSubscriberInterface", "getHandledMessages")) {
            return null;
        }

        return new PhpClassPublicMethodProvider(method.getContainingClass());
    });
}
 
Example #4
Source File: TranslationTagGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // {% trans from "app" %}<caret>{% endtrans %}
    registrar.register(
        getTranslationTagValuePattern(), psiElement -> {
            TwigCompositeElement element = getTagOnTwigViewProvider(psiElement);
            if(element == null) {
                return null;
            }

            String domain = TwigUtil.getDomainFromTranslationTag(element);
            if(domain == null) {
                domain = TwigUtil.getTransDefaultDomainOnScope(element);
            }

            // overall fallback if no "trans*" scope was found
            if(domain == null) {
                domain = "messages";
            }

            return new MyTranslationGotoCompletionProvider(element, domain);
        }
    );
}
 
Example #5
Source File: GotoCompletionUtil.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public static Collection<GotoCompletionContributor> getContributors(final PsiElement psiElement) {

        final Collection<GotoCompletionContributor> contributors = new ArrayList<>();

        GotoCompletionRegistrarParameter registrar = (pattern, contributor) -> {
            if(pattern.accepts(psiElement)) {
                contributors.add(contributor);
            }
        };

        for(GotoCompletionRegistrar register: EXTENSIONS.getExtensions()) {
            register.register(registrar);
        }

        return contributors;
    }
 
Example #6
Source File: ConfigCompletionGoto.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {

        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent == null) {
            return null;
        }

        MethodMatcher.MethodMatchParameter methodMatchParameter = MethodMatcher.getMatchedSignatureWithDepth(parent, CONFIG);
        if(methodMatchParameter == null) {
            return null;
        }

        return new FormReferenceCompletionProvider(parent);

    });
}
 
Example #7
Source File: YamlRouteKeyCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    PsiElementPattern.Capture<PsiElement> filePattern = PlatformPatterns.psiElement().inFile(PlatformPatterns.psiFile().withName(PlatformPatterns.string().endsWith(".routing.yml")));

    registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getParentKeyName("defaults"), filePattern), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new DefaultRoutes(psiElement);
    });

    registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getParentKeyName("requirements"), filePattern), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new EntityAccessRoutes(psiElement);
    });
}
 
Example #8
Source File: YamlMenuGotoCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    PsiElementPattern.Capture<PsiElement> menuPattern = PlatformPatterns.psiElement().inFile(PlatformPatterns.psiFile().withName(PlatformPatterns.string().endsWith(".menu.yml")));

    registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getSingleLineScalarKey("parent"), menuPattern), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new ParentMenu(psiElement);
    });


    registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getWithFirstRootKey(), menuPattern), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MenuKeys(psiElement);
    });
}
 
Example #9
Source File: GotoCompletionUtil.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
public static Collection<GotoCompletionContributor> getContributors(final PsiElement psiElement) {
    Collection<GotoCompletionContributor> contributors = new ArrayList<>();

    GotoCompletionRegistrarParameter registrar = (pattern, contributor) -> {
        if(pattern.accepts(psiElement)) {
            contributors.add(contributor);
        }
    };

    for(GotoCompletionRegistrar register: CONTRIBUTORS) {
        // filter on language
        if(register instanceof GotoCompletionLanguageRegistrar) {
            if(((GotoCompletionLanguageRegistrar) register).support(psiElement.getLanguage())) {
                register.register(registrar);
            }
        } else {
            register.register(registrar);
        }
    }

    return contributors;
}
 
Example #10
Source File: DicCompletionRegistrar.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement(), psiElement -> {
        if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent != null && (
            MethodMatcher.getMatchedSignatureWithDepth(parent, DIC) != null ||
            PhpElementsUtil.isFunctionReference(parent, 0, "app")
        )) {
            return new DicGotoCompletionProvider(parent);
        }

        return null;

    });
}
 
Example #11
Source File: TranslationReferences.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement(), psiElement -> {
        if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent != null && (
            MethodMatcher.getMatchedSignatureWithDepth(parent, TRANSLATION_KEY) != null || PhpElementsUtil.isFunctionReference(parent, 0, "trans", "__", "trans_choice")
        )) {
            return new TranslationKey(parent);
        }

        // for blade @lang directive
        if(BladePsiUtil.isDirectiveWithInstance(psiElement, "Illuminate\\Support\\Facades\\Lang", "get")) {
            return new TranslationKey(psiElement);
        }

        return null;
    });
}
 
Example #12
Source File: YamlPermissionGotoCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(YamlElementPatternHelper.getSingleLineScalarKey("_permission"), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MyGotoCompletionProvider(psiElement);
    });
}
 
Example #13
Source File: PhpEventDispatcherGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 *
 * \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents
 *
 * return array(
 *  'pre.foo' => array('preFoo', 10),
 *  'post.foo' => array('postFoo'),
 * ');
 *
 */
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {

    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {
        PsiElement parent = psiElement.getParent();
        if(!(parent instanceof StringLiteralExpression)) {
            return null;
        }

        PsiElement arrayValue = parent.getParent();
        if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
            PhpReturn phpReturn = PsiTreeUtil.getParentOfType(arrayValue, PhpReturn.class);
            if(phpReturn != null) {
                Method method = PsiTreeUtil.getParentOfType(arrayValue, Method.class);
                if(method != null) {
                    String name = method.getName();
                    if("getSubscribedEvents".equals(name)) {
                        PhpClass containingClass = method.getContainingClass();
                        if(containingClass != null && PhpElementsUtil.isInstanceOf(containingClass, "\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface")) {
                            return new PhpClassPublicMethodProvider(containingClass);
                        }
                    }
                }
            }
        }

        return null;
    });

}
 
Example #14
Source File: AppConfigReferences.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement(), psiElement -> {
        if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent != null && (PsiElementUtils.isFunctionReference(parent, "config", 0) || MethodMatcher.getMatchedSignatureWithDepth(parent, CONFIG) != null)) {
            return new ConfigKeyProvider(parent);
        }

        return null;
    });
}
 
Example #15
Source File: ProviderGotoCompletion.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement(), psiElement -> {
        if(psiElement == null || !psiElement.getContainingFile().getName().contains("app.php")) {
            return null;
        }

        // array('providers' => array('foo'))
        PsiElement literal = psiElement.getParent();
        if(literal instanceof StringLiteralExpression) {
            PsiElement arrayValue = literal.getParent();
            if(arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
                PsiElement arrayCreation = arrayValue.getParent();
                if(arrayCreation instanceof ArrayCreationExpression) {
                    PsiElement arrayValueKey = arrayCreation.getParent();
                    if(arrayValueKey.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
                        PsiElement hashArrayElement = arrayValueKey.getParent();
                        if(hashArrayElement instanceof ArrayHashElement) {
                            PhpPsiElement key = ((ArrayHashElement) hashArrayElement).getKey();
                            if(key instanceof StringLiteralExpression && "providers".equals(((StringLiteralExpression) key).getContents())) {
                                return new ProviderName(psiElement);
                            }

                        }
                    }
                }
            }
        }

        return null;
    });

}
 
Example #16
Source File: FilterGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // {% trans foo<caret>bar %}
    registrar.register(TwigPattern.getFilterTagPattern(), psiElement -> {
        if (!Symfony2ProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MyFilterTagGotoCompletionProvider(psiElement);
    });
}
 
Example #17
Source File: RenderParameterGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(
        PlatformPatterns.psiElement().withParent(StringLiteralExpression.class),
        MyTemplateVariablesGotoCompletionProvider::new
    );
}
 
Example #18
Source File: PhpCommandGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {

    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {
        PsiElement context = psiElement.getContext();
        if (!(context instanceof StringLiteralExpression)) {
            return null;
        }

        for(String s : new String[] {"Option", "Argument"}) {
            MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterRecursiveMatcher(context, 0)
                    .withSignature("Symfony\\Component\\Console\\Input\\InputInterface", "get" + s)
                    .withSignature("Symfony\\Component\\Console\\Input\\InputInterface", "has" + s)
                    .match();

            if(methodMatchParameter != null) {
                PhpClass phpClass = PsiTreeUtil.getParentOfType(methodMatchParameter.getMethodReference(), PhpClass.class);
                if(phpClass != null) {
                    return new CommandGotoCompletionProvider(phpClass, s);
                }

            }
        }

        return null;
    });

}
 
Example #19
Source File: ConsoleHelperGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {
        PsiElement context = psiElement.getContext();
        if (!(context instanceof StringLiteralExpression)) {
            return null;
        }

        if (MethodMatcher.getMatchedSignatureWithDepth(context, CONSOLE_HELP_SET) == null) {
            return null;
        }

        return new MyGotoCompletionProvider(psiElement);
    });
}
 
Example #20
Source File: YamlGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // defaults:
    //   route: <caret>
    registrar.register(
        YamlElementPatternHelper.getSingleLineScalarKey("route"),
        RouteGotoCompletionProvider::new
    );

    // defaults:
    //   template: <caret>
    registrar.register(
        YamlElementPatternHelper.getSingleLineScalarKey("template"),
        TemplateGotoCompletionRegistrar::new
    );

    // foo.service:
    //   decorates: <caret>
    registrar.register(
        YamlElementPatternHelper.getSingleLineScalarKey("decorates"),
        MyDecoratedServiceCompletionProvider::new
    );

    // key: !php/const <caret>
    registrar.register(
        YamlElementPatternHelper.getPhpConstPattern(),
        PhpConstGotoCompletionProvider::new
    );
}
 
Example #21
Source File: TaggedParameterGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // arguments: [!tagged twig.extension]
    // <argument type="tagged" tag="foobar" />
    registrar.register(
        PlatformPatterns.or(
            YamlElementPatternHelper.getTaggedServicePattern(),
            XmlPatterns.psiElement().withParent(XmlHelper.getTypeTaggedTagAttribute())
        ),
        new MyTagGotoCompletionContributor()
    );
}
 
Example #22
Source File: FormOptionGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(
        PlatformPatterns.psiElement().withLanguage(PhpLanguage.INSTANCE),
        new FormOptionBuilderCompletionContributor()
    );

    /*
     * eg "$resolver->setDefault('<caret>')"
     */
    registrar.register(
        PlatformPatterns.psiElement().withParent(PhpElementsUtil.getMethodWithFirstStringPattern()),
        new OptionDefaultCompletionContributor()
    );
}
 
Example #23
Source File: AnnotationExpressionGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // "@Security("is_granted('POST_SHOW', post) and has_role('ROLE_ADMIN')")"
    registrar.register(
        PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_STRING)
        .withParent(PlatformPatterns.psiElement(StringLiteralExpression.class)
            .withParent(PlatformPatterns.psiElement(PhpDocElementTypes.phpDocAttributeList)
                .withParent(PlatformPatterns.psiElement(PhpDocTag.class)
                    .with(PhpDocInstancePatternCondition.INSTANCE)
                )
            )
        ),
        MyGotoCompletionProvider::new
    );
}
 
Example #24
Source File: DoctrineXmlGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(XmlPatterns.psiElement().withParent(PlatformPatterns.or(
        DoctrineMetadataPattern.getXmlModelClass(),
        DoctrineMetadataPattern.getXmlRepositoryClass(),
        DoctrineMetadataPattern.getXmlTargetDocumentClass(),
        DoctrineMetadataPattern.getXmlTargetEntityClass(),
        DoctrineMetadataPattern.getEmbeddableNameClassPattern()
    )), ClassGotoCompletionProvider::new);
}
 
Example #25
Source File: PhpRouteParameterCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(getElementPatternPattern(), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MyGotoCompletionProvider(psiElement);
    });
}
 
Example #26
Source File: ControllerCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(YamlElementPatternHelper.getSingleLineScalarKey("_controller"), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MyGotoCompletionProvider(psiElement);
    });

}
 
Example #27
Source File: YamlEntityFormGotoCompletion.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(YamlElementPatternHelper.getSingleLineScalarKey("_entity_form"), psiElement -> {
        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        return new MyGotoCompletionProvider(psiElement);
    });
}
 
Example #28
Source File: AssetGotoCompletionRegistrar.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    /*
     * view('caret');
     * Factory::make('caret');
     */
    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {
        if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement stringLiteral = psiElement.getParent();
        if(!(stringLiteral instanceof StringLiteralExpression)) {
            return null;
        }

        if(!(
            PsiElementUtils.isFunctionReference(stringLiteral, "asset", 0)
                || PsiElementUtils.isFunctionReference(stringLiteral, "secure_asset", 0)
                || PsiElementUtils.isFunctionReference(stringLiteral, "secureAsset", 0)
        ) && MethodMatcher.getMatchedSignatureWithDepth(stringLiteral, ASSETS) == null) {
            return null;
        }

        return new AssetGotoCompletionProvider(stringLiteral);
    });
}
 
Example #29
Source File: VoterGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // {% is_granted('foobar') %}
    // {% is_granted({'foobar'}) %}
    // {% is_granted(['foobar']) %}
    registrar.register(
        PlatformPatterns.or(
            TwigPattern.getPrintBlockOrTagFunctionPattern("is_granted"),
            TwigPattern.getFunctionWithFirstParameterAsArrayPattern("is_granted"),
            TwigPattern.getFunctionWithFirstParameterAsLiteralPattern("is_granted")
        ),
        MyVisitorGotoCompletionProvider::new
    );

    // Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::isGranted %}
    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {
        PsiElement context = psiElement.getContext();
        if (!(context instanceof StringLiteralExpression)) {
            return null;
        }

        MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterRecursiveMatcher(context, 0)
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "isGranted")
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "denyAccessUnlessGranted")

            // Symfony 3.3 / 3.4
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait", "isGranted")
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait", "denyAccessUnlessGranted")

            .withSignature("Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface", "isGranted")
            .match();

        if(methodMatchParameter != null) {
            return new MyVisitorGotoCompletionProvider(psiElement);
        }

        // ['foobar']
        MethodMatcher.MethodMatchParameter arrayMatchParameter = new MethodMatcher.ArrayParameterMatcher(context, 0)
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "isGranted")
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "denyAccessUnlessGranted")

            // Symfony 4
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController", "isGranted")
            .withSignature("Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController", "denyAccessUnlessGranted")

            .withSignature("Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface", "isGranted")
            .match();

        if(arrayMatchParameter != null) {
            return new MyVisitorGotoCompletionProvider(psiElement);
        }

        return null;
    });
}
 
Example #30
Source File: DoctrineYamlGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.or(
        YamlElementPatternHelper.getOrmSingleLineScalarKey("repositoryClass")
    ), ClassGotoCompletionProvider::new);
}