Examples of GotoCompletionContributor


Examples of fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionContributor

     * ');
     *
     */
    public void register(GotoCompletionRegistrarParameter registrar) {

        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

                PsiElement parent = psiElement.getParent();
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionContributor

public class FormGotoCompletionRegistrar implements GotoCompletionRegistrar {

    public void register(GotoCompletionRegistrarParameter registrar) {

        // FormBuilderInterface:add("", "type")
        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

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

                MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterMatcher(parent, 1)
                    .withSignature(Symfony2InterfacesUtil.getFormBuilderInterface())
                    .match();

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

                return new FormBuilderAddGotoCompletionProvider(parent);
            }
        });

        /**
         * $options lookup
         * public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array())
         */
        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

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

                MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.ArrayParameterMatcher(parent, 3)
                    .withSignature("\\Symfony\\Component\\Form\\FormFactoryInterface", "createNamedBuilder")
                    .withSignature("\\Symfony\\Component\\Form\\FormFactoryInterface", "createNamed")
                    .match();

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

                return getFormProvider((StringLiteralExpression) parent, methodMatchParameter.getParameters()[1]);

            }

        });


        /**
         * $this->createForm(new FormType(), $entity, array('<foo_key>' => ''));
         * $this->createForm('foo', $entity, array('<foo_key>'));
         */
        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

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

                MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.ArrayParameterMatcher(parent, 2)
                    .withSignature("\\Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "createForm")
                    .withSignature("\\Symfony\\Component\\Form\\FormFactoryInterface", "create")
                    .withSignature("\\Symfony\\Component\\Form\\FormFactory", "createBuilder")
                    .match();

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

                return getFormProvider((StringLiteralExpression) parent, methodMatchParameter.getParameters()[0]);

            }

        });

        /**
         * FormTypeInterface::getParent
         */
        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

                PsiElement parent = psiElement.getParent();
                if(!(parent instanceof StringLiteralExpression|| !PhpElementsUtil.getMethodReturnPattern().accepts(parent)) {
                    return null;
                }

                Method method = PsiTreeUtil.getParentOfType(psiElement, Method.class);
                if(method == null) {
                    return null;
                }

                if(!new Symfony2InterfacesUtil().isCallTo(method, "\\Symfony\\Component\\Form\\FormTypeInterface", "getParent")) {
                    return null;
                }

                return new FormBuilderAddGotoCompletionProvider(parent);

            }

        });


        /**
         * $type lookup
         * public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array())
         */
        registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

                PsiElement parent = psiElement.getParent();
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionContributor

public class BlockCompletionRegistrar implements GotoCompletionRegistrar {

    public void register(GotoCompletionRegistrarParameter registrar) {

        // {{ block('foo_block') }}
        registrar.register(TwigHelper.getPrintBlockFunctionPattern("block"), new GotoCompletionContributor() {
            @Nullable
            @Override
            public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {

                if (!Symfony2ProjectComponent.isEnabled(psiElement)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.