Examples of Symfony2InterfacesUtil


Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

                if (parameterList instanceof ParameterList) {
                    PsiElement context = parameterList.getContext();
                    if(context instanceof MethodReference) {
                        ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(arrayCreationExpression);
                        if(currentIndex != null && currentIndex.getIndex() == 2) {
                            if (new Symfony2InterfacesUtil().isFormBuilderFormTypeCall(context)) {
                                return getMatchingOption((ParameterList) parameterList, psiElement);
                            }
                        }
                    }
                }
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

        // heavy stuff here, to get nested routing array :)
        // list($variables, $defaults, $requirements, $tokens, $hostTokens)
        Collection<PhpClass> phpClasses = PsiTreeUtil.findChildrenOfType(psiFile, PhpClass.class);
        for(PhpClass phpClass: phpClasses) {
            if(new Symfony2InterfacesUtil().isInstanceOf(phpClass, "\\Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface")) {
                for(Field field: phpClass.getFields()) {
                    if(field.getName().equals("declaredRoutes")) {
                        PsiElement defaultValue = field.getDefaultValue();
                        if(defaultValue instanceof ArrayCreationExpression) {
                            Iterable<ArrayHashElement> arrayHashElements = ((ArrayCreationExpression) defaultValue).getHashElements();
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

        if(parameter == null) {
            return phpNamedElementCollections;
        }

        // finally search the classes
        if(new Symfony2InterfacesUtil().isContainerGetCall((Method) phpNamedElement)) {

            ContainerService containerService = ContainerCollectionResolver.getService(project, parameter);
            if(containerService != null) {
                String serviceClass = containerService.getClassName();
                if(serviceClass != null) {
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

                PsiElement psiElement = completionParameters.getOriginalPosition();
                if(psiElement == null || !(psiElement.getParent() instanceof MethodReference)) {
                    return;
                }

                Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
                for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {

                    if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.PARAMETER) {
                        attachLookup(completionResultSet, (MethodReference) psiElement.getParent(), symfony2InterfacesUtil, enumProvider);
                    }

                }

            }

        });

        // $test = TEST::HTTP
        extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
            @Override
            protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

                PsiElement psiElement = completionParameters.getOriginalPosition();
                if(psiElement == null) {
                    return;
                }

                BinaryExpression binaryExpression = PsiTreeUtil.getPrevSiblingOfType(psiElement, BinaryExpression.class);
                if(binaryExpression == null) {
                    return;
                }

                // OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
                // @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
                PsiElement leftOperand = binaryExpression.getLeftOperand();
                if(!(leftOperand instanceof MethodReference)) {
                    return;
                }

                Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
                for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
                    if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN) {
                        attachLookup(completionResultSet, (MethodReference) leftOperand, symfony2InterfacesUtil, enumProvider);
                    }
                }

            }

        });

        extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
            @Override
            protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

                PsiElement psiElement = completionParameters.getOriginalPosition();
                if(psiElement == null) {
                    return;
                }

                BinaryExpression binaryExpression = PsiTreeUtil.getPrevSiblingOfType(psiElement, BinaryExpression.class);
                if(binaryExpression == null) {
                    return;
                }

                // OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
                // @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
                PsiElement leftOperand = binaryExpression.getLeftOperand();
                if(!(leftOperand instanceof MethodReference)) {
                    return;
                }

                Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
                for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
                    if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN) {
                        attachLookup(completionResultSet, (MethodReference) leftOperand, symfony2InterfacesUtil, enumProvider);
                    }
                }

            }

        });


        // strings

        extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
            @Override
            protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

                PsiElement psiElement = completionParameters.getPosition().getOriginalElement();
                if(!(psiElement.getParent() instanceof StringLiteralExpression)) {
                    return;
                }

                for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
                    if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.PARAMETER && enumProvider.getEnumConstantFilter().getStringValues() != null) {
                        if(MethodMatcher.getMatchedSignatureWithDepth(psiElement.getParent(), new MethodMatcher.CallToSignature[] {enumProvider.getCallToSignature()}) != null) {
                            for(String stringValue: enumProvider.getEnumConstantFilter().getStringValues()) {
                                completionResultSet.addElement(LookupElementBuilder.create(stringValue));
                            }
                        }
                    }

                }
            }

        });

        extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
            @Override
            protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

                PsiElement psiElement = completionParameters.getPosition().getOriginalElement();
                if(!(psiElement.getParent() instanceof StringLiteralExpression)) {
                    return;
                }

                if(!(psiElement.getParent().getParent() instanceof BinaryExpression)) {
                    return;
                }

                BinaryExpression binaryExpression = (BinaryExpression) psiElement.getParent().getParent();


                // OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
                // @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
                PsiElement leftOperand = binaryExpression.getLeftOperand();
                if(!(leftOperand instanceof MethodReference)) {
                    return;
                }

                Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
                for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
                    if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN && enumProvider.getEnumConstantFilter().getStringValues() != null && symfony2InterfacesUtil.isCallTo((MethodReference) leftOperand, enumProvider.getCallToSignature().getInstance(), enumProvider.getCallToSignature().getMethod())) {
                        for(String stringValue: enumProvider.getEnumConstantFilter().getStringValues()) {
                            completionResultSet.addElement(LookupElementBuilder.create(stringValue));
                        }
                    }
                }
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

    public static MethodReference[] getFormBuilderTypes(Method method) {

        final List<MethodReference> methodReferences = new ArrayList<MethodReference>();

        final Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
        PsiTreeUtil.collectElements(method, new PsiElementFilter() {
            @Override
            public boolean isAccepted(PsiElement psiElement) {

                if (psiElement instanceof MethodReference) {
                    String methodName = ((MethodReference) psiElement).getName();
                    if (methodName != null && (methodName.equals("add") || methodName.equals("create"))) {
                        if(symfony2InterfacesUtil.isFormBuilderFormTypeCall(psiElement)) {
                            methodReferences.add((MethodReference) psiElement);
                            return true;
                        }
                    }
                }
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

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

        if(new Symfony2InterfacesUtil().isCallTo(calledMethodReference, "\\Symfony\\Component\\Form\\FormFactory", "create")) {
            return null;
        }

        // $form = "$this->createForm("new Type()", $entity)";
        PsiElement formType = PsiElementUtils.getMethodParameterPsiElementAt(calledMethodReference, 0);
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

    }

    public static Set<String> getFormAliases(@NotNull PhpClass phpClass) {
        final Set<String> aliases = new HashSet<String>();

        if(!new Symfony2InterfacesUtil().isInstanceOf(phpClass, ABSTRACT_FORM_INTERFACE)) {
            return aliases;
        }

        Method method = PhpElementsUtil.getClassMethod(phpClass, "getName");
        if(method != null) {
View Full Code Here

Examples of fr.adrienbrault.idea.symfony2plugin.Symfony2InterfacesUtil

        if(psiFile == null) {
            return;
        }

        Symfony2ProjectComponent.getLogger().info("update translations: " + file.getPath());
        Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();

        Collection<NewExpression> messageCatalogues = PsiTreeUtil.collectElementsOfType(psiFile, NewExpression.class);
        for(NewExpression newExpression: messageCatalogues) {
            ClassReference classReference = newExpression.getClassReference();
            if(classReference != null) {
                PsiElement constructorMethod = classReference.resolve();
                if(constructorMethod instanceof Method) {
                    PhpClass phpClass = ((Method) constructorMethod).getContainingClass();
                    if(phpClass != null && symfony2InterfacesUtil.isInstanceOf(phpClass, "\\Symfony\\Component\\Translation\\MessageCatalogueInterface")) {
                        this.getTranslationMessages(newExpression);
                    }

                }
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.