Examples of PhpClass


Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        PhpDocTag phpDocTag = PsiTreeUtil.getParentOfType(psiElement, PhpDocTag.class);
        if(phpDocTag == null) {
            return;
        }

        PhpClass phpClass = AnnotationUtil.getAnnotationReference(phpDocTag);
        if(phpClass == null) {
            return;
        }

        for(Field field: phpClass.getFields()) {
            if(field.getName().equals(psiElement.getText())) {
                targets.add(field);
                return;
            }
        }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

     * @param targets Goto targets
     */
    private void addStaticClassTargets(PsiElement psiElement, List<PsiElement> targets) {

        String text = psiElement.getText();
        PhpClass phpClass = PhpElementsUtil.getClassByContext(psiElement, text);
        if(phpClass != null) {
            targets.add(phpClass);
        }

    }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        PsiElement docStatic = psiElement.getPrevSibling();
        if(docStatic != null && docStatic.getNode().getElementType() == PhpDocTokenTypes.DOC_STATIC) {
            PsiElement docIdentifier = docStatic.getPrevSibling();
            if(docIdentifier != null && docIdentifier.getNode().getElementType() == PhpDocTokenTypes.DOC_IDENTIFIER) {
                String className = docIdentifier.getText();
                PhpClass phpClass = PhpElementsUtil.getClassByContext(psiElement, className);
                if(phpClass != null) {
                    Field field = phpClass.findFieldByName(constName, true);
                    if(field != null) {
                        targets.add(field);
                    }
                }
            }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        List<LookupElement> results = new ArrayList<LookupElement>();
        PhpIndex phpIndex = PhpIndex.getInstance(getElement().getProject());

        // find Repository interface to filter RepositoryClasses out
        PhpClass repositoryInterface = PhpElementsUtil.getInterface(phpIndex, DoctrineTypes.REPOSITORY_INTERFACE);
        if(null == repositoryInterface) {
            return results.toArray();
        }

        results.addAll(getModelLookupElements(getElement().getProject(), this.useClassNameAsLookupString, this.doctrineManagers.toArray(new DoctrineTypes.Manager[this.doctrineManagers.size()])));
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

            return;
        }

        PhpIndex phpIndex = PhpIndex.getInstance(parameters.getOriginalFile().getProject());

        PhpClass repositoryInterface = PhpElementsUtil.getInterface(phpIndex, DoctrineTypes.REPOSITORY_INTERFACE);
        if(null == repositoryInterface) {
            return;
        }

        Map<String, String> entityNamespaces = ServiceXmlParserFactory.getInstance(parameters.getOriginalFile().getProject(), EntityNamesServiceParser.class).getEntityNameMap();
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        parameter = PhpTypeProviderUtil.getResolvedParameter(phpIndex, parameter);
        if(parameter == null) {
            return phpNamedElementCollections;
        }

        PhpClass phpClass = EntityHelper.resolveShortcutName(project, parameter);
        if(phpClass == null) {
            return phpNamedElementCollections;
        }

        if(method.getName().equals("findAll") || method.getName().equals("findBy")) {
            method.getType().add(phpClass.getFQN() + "[]");
            return phpNamedElementCollections;
        }

        return Arrays.asList(phpClass);
    }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        }

        List<QueryBuilderRelation> relations = collect.getRelationMap().get(joinSplit[0]);
        for(QueryBuilderRelation relation: relations) {
            if(joinSplit[1].equals(relation.getFieldName()) && relation.getTargetEntity() != null) {
                PhpClass phpClass = PhpElementsUtil.getClassInterface(psiElement.getProject(), relation.getTargetEntity());
                if(phpClass != null) {
                    targets.add(phpClass);
                }

            }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

                    if(relationMap.containsKey(foreignJoinAlias)) {
                        for(QueryBuilderRelation queryBuilderRelation: relationMap.get(foreignJoinAlias)) {
                            if(queryBuilderRelation.getFieldName().equals(foreignJoinField)) {
                                String targetEntity = queryBuilderRelation.getTargetEntity();
                                if(targetEntity != null) {
                                    PhpClass phpClass = PhpElementsUtil.getClassInterface(project, targetEntity);
                                    if(phpClass != null) {
                                        relationMap.put(queryBuilderJoin.getAlias(), QueryBuilderMethodReferenceParser.attachRelationFields(phpClass));
                                        queryBuilderJoin.setResolvedClass(targetEntity);
                                        collect();
                                    }
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

        // first tableMap entry is root, we add several initial data
        if(qb.getTableMap().size() > 0) {
            Map.Entry<String, String> entry = qb.getTableMap().entrySet().iterator().next();
            String className = entry.getKey();
            PhpClass phpClass = PhpElementsUtil.getClassInterface(project, className);

            // add root select fields
            if(phpClass != null) {

                qb.addPropertyAlias(entry.getValue(), new QueryBuilderPropertyAlias(entry.getValue(), null, new DoctrineModelField(entry.getValue()).addTarget(phpClass).setTypeName(phpClass.getPresentableFQN())));

                List<QueryBuilderRelation> relationList = new ArrayList<QueryBuilderRelation>();

                //qb.addRelation(entry.getValue(), attachRelationFields(phpClass));
                for(DoctrineModelField field: EntityHelper.getModelFields(phpClass)) {
View Full Code Here

Examples of com.jetbrains.php.lang.psi.elements.PhpClass

            // getRepository('Foo')->createQueryBuilder('test');
            if("getRepository".equals(methodReferenceName)) {
                String possibleRepository = PhpElementsUtil.getStringValue(PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 0));
                if(possibleRepository != null) {
                    repository = possibleRepository;
                    PhpClass phpClass = EntityHelper.resolveShortcutName(project, repository);
                    if(phpClass != null) {
                        repository = phpClass.getPresentableFQN();
                    }
                }
            }

            // $qb->from('Foo\Class', 'article')
            if("from".equals(methodReferenceName)) {
                String table = PhpElementsUtil.getStringValue(PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 0));
                String alias = PhpElementsUtil.getStringValue(PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 1));
                if(table != null && alias != null) {
                    PhpClass phpClass = EntityHelper.resolveShortcutName(project, table);
                    if(phpClass != null) {
                        table = phpClass.getPresentableFQN();
                    }

                    roots.put(table, alias);
                }
            }

        }

        // we have a valid root so add it
        if(rootAlias != null && repository != null) {
            roots.put(repository, rootAlias);
        }

        // we found a alias but not a repository name, so try a scope search if we are inside repository class
        // class implements \Doctrine\Common\Persistence\ObjectRepository, so search for model name of "repositoryClass"
        if(rootAlias != null && repository == null) {
            MethodReference methodReference = methodReferences.iterator().next();
            PhpClass phpClass = PsiTreeUtil.getParentOfType(methodReference, PhpClass.class);
            if(new Symfony2InterfacesUtil().isInstanceOf(phpClass, "\\Doctrine\\Common\\Persistence\\ObjectRepository")) {
                for(DoctrineModel model: EntityHelper.getModelClasses(project)) {
                    String className = model.getPhpClass().getPresentableFQN();
                    if(className != null) {
                        PhpClass resolvedRepoName = EntityHelper.getEntityRepositoryClass(project, className);
                        if(PhpElementsUtil.isEqualClassName(resolvedRepoName, phpClass.getPresentableFQN())) {
                            roots.put(className, rootAlias);
                            return roots;
                        }
                    }
                }
            }

        }

        // search on PhpTypeProvider
        // $er->createQueryBuilder()
        if(rootAlias != null && repository == null) {
            for(MethodReference methodReference: methodReferences) {
                if("createQueryBuilder".equals(methodReference.getName())) {
                    String signature = methodReference.getSignature();
                    int endIndex = signature.lastIndexOf(ObjectRepositoryTypeProvider.TRIM_KEY);
                    if(endIndex != -1) {
                        String parameter = signature.substring(endIndex + 1);
                        int point = parameter.indexOf(".");
                        if(point > -1) {
                            parameter = parameter.substring(0, point);
                            parameter = PhpTypeProviderUtil.getResolvedParameter(PhpIndex.getInstance(project), parameter);
                            if(parameter != null) {
                                PhpClass phpClass = EntityHelper.resolveShortcutName(project, parameter);
                                if(phpClass != null && phpClass.getPresentableFQN() != null) {
                                    roots.put(phpClass.getPresentableFQN(), rootAlias);
                                    return roots;
                                }
                            }
                        }
                    }
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.