Examples of PhpIndex


Examples of com.jetbrains.php.PhpIndex

            if(!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
                return;
            }

            PhpIndex phpIndex = PhpIndex.getInstance(parameters.getOriginalFile().getProject());
            for(PhpClass phpClass: phpIndex.getAllSubclasses("\\Doctrine\\ORM\\EntityRepository")) {
                String presentableFQN = phpClass.getPresentableFQN();
                if(presentableFQN != null) {
                    completionResultSet.addElement(LookupElementBuilder.create(phpClass.getName()).withTypeText(phpClass.getPresentableFQN(), true).withIcon(phpClass.getIcon()));
                }
            }
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

    public static ArrayList<EventDispatcherSubscribedEvent> getSubscribedEvents(Project project) {

        ArrayList<EventDispatcherSubscribedEvent> events = new ArrayList<EventDispatcherSubscribedEvent>();

        // http://symfony.com/doc/current/components/event_dispatcher/introduction.html
        PhpIndex phpIndex = PhpIndex.getInstance(project);
        Collection<PhpClass> phpClasses = phpIndex.getAllSubclasses("\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface");

        for(PhpClass phpClass: phpClasses) {
            if(!PhpUnitUtil.isTestClass(phpClass)) {
                Method method = PhpElementsUtil.getClassMethod(phpClass, "getSubscribedEvents");
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

        }

        String originalSignature = expression.substring(0, endIndex);
        String parameter = expression.substring(endIndex + 1);

        PhpIndex phpIndex = PhpIndex.getInstance(project);
        Collection<? extends PhpNamedElement> phpNamedElementCollections = phpIndex.getBySignature(originalSignature, null, 0);
        if(phpNamedElementCollections.size() == 0) {
            return null;
        }

        // get first matched item
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

    @NotNull
    @Override
    public ResolveResult[] multiResolve(boolean incompleteCode) {

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

        if(this.useClasses) {
            this.attachPhpClassResolveResults(phpIndex.getClassesByFQN(classFQN), results);
        }

        if(this.useInterfaces) {
            this.attachPhpClassResolveResults(phpIndex.getInterfacesByFQN(classFQN.startsWith("\\") ? classFQN : "\\" + classFQN), results);
        }

        return results.toArray(new ResolveResult[results.size()]);
    }
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

            return results.toArray();
        }


        CamelHumpMatcher camelHumpMatcher = new CamelHumpMatcher(this.classFQN);
        PhpIndex phpIndex = PhpIndex.getInstance(this.getElement().getProject());

        if(this.useClasses) {
            for (String name : phpIndex.getAllClassNames(camelHumpMatcher)) {
                attachPhpClassToVariants(results, phpIndex.getClassesByName(name));
            }
        }

        // phpindex interface dont support filter
        if(this.useInterfaces) {
            for (String name : phpIndex.getAllInterfaceNames()) {

                if(this.classFQN.length() > 0 && !name.toLowerCase().contains(this.classFQN.toLowerCase())) {
                    continue;
                }

                attachPhpClassToVariants(results, phpIndex.getInterfacesByName(name));

            }
        }

        return results.toArray();
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

                    PsiElement position = parameters.getPosition();
                    if(!Symfony2ProjectComponent.isEnabled(position)) {
                        return;
                    }

                    PhpIndex instance = PhpIndex.getInstance(position.getProject());
                    for(String constant : instance.getAllConstantNames(PrefixMatcher.ALWAYS_TRUE)) {
                        resultSet.addElement(LookupElementBuilder.create(constant).withIcon(PhpIcons.CONSTANT));
                    }


                    int foo = parameters.getOffset() - position.getTextRange().getStartOffset();
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

            if(psiElement == null || !Symfony2ProjectComponent.isEnabled(psiElement)) {
                return;
            }

            PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
            for (String className : phpIndex.getAllClassNames(resultSet.getPrefixMatcher())) {
                resultSet.addElement(new PhpLookupElement(className, PhpClassIndex.KEY, psiElement.getProject(), PhpReferenceInsertHandler.getInstance()));
            }

        }
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

       return getTwigNamespaces(project, true);
    }

    public static List<TwigPath> getTwigNamespaces(@NotNull Project project, boolean includeSettings) {
        List<TwigPath> twigPaths = new ArrayList<TwigPath>();
        PhpIndex phpIndex = PhpIndex.getInstance(project);

        TwigPathServiceParser twigPathServiceParser = ServiceXmlParserFactory.getInstance(project, TwigPathServiceParser.class);
        twigPaths.addAll(twigPathServiceParser.getTwigPathIndex().getTwigPaths());

        String appDirectoryName = Settings.getInstance(project).directoryToApp + "/Resources/views";
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

        String originalSignature = expression.substring(0, endIndex);
        String parameter = expression.substring(endIndex + 1);

        // search for called method
        PhpIndex phpIndex = PhpIndex.getInstance(project);
        Collection<? extends PhpNamedElement> phpNamedElementCollections = phpIndex.getBySignature(originalSignature, null, 0);
        if(phpNamedElementCollections.size() == 0) {
            return Collections.emptySet();
        }

        // get first matched item
View Full Code Here

Examples of com.jetbrains.php.PhpIndex

              String[] modelNames = matcher.group(1).replaceAll("\\s|\\t|'|\"", "").split(",");

              for (String modelName : modelNames) {
                Collection<PhpClass> phpClasses = PhpIndex.getInstance(psiElement.getProject()).getClassesByFQN(modelName);

                PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());


                for (PhpClass phpClass : phpClasses) {
                  if (phpClass != null) {

//                    PsiReference ref = new com.vexus2.cakestorm.lib.ClassReference(phpClass.getOriginalElement(), phpClass.getContainingFile().getVirtualFile(), phpClass.getContainingFile().getVirtualFile().getPath());
//                    return new PsiReference[]{ref};


//                    Method arr$[] = phpClass.getOwnMethods();
//                    int len$ = arr$.length;
//                    for (int i$ = 0; i$ < len$; i$++) {
//                      Method m = arr$[i$];
//                      if (!PhpUnitUtil.isTestMethod(m))
//
//                    }

                  }
                }

              }

            }
            return PsiReference.EMPTY_ARRAY;
          }

          @Nullable
          private PsiElement getOriginalElement(@NotNull PsiElement selectedElement) {
            if (selectedElement == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalElement must not be null");
            FunctionReference functionReference = (FunctionReference) PhpPsiUtil.getParentByCondition(selectedElement, true, FunctionReference.INSTANCEOF);
            PsiElement selectedParameter = PhpCallbackFunctionUtil.getParentParameterElement(selectedElement);
            if ((functionReference == null) || (selectedParameter == null))
              return null;

            int selectedIndex = PhpCallbackFunctionUtil.getSelectedParameterIndex(selectedParameter);
            if (PhpCallbackFunctionUtil.isClassCallbackFunction(functionReference, selectedIndex)) {
              return getOriginalClass(selectedParameter, getCallerClass(functionReference));
            }

            if (PhpCallbackFunctionUtil.isMethodCallbackFunction(functionReference, selectedIndex)) {
              return getOriginalMethod(selectedParameter.getParent(), getCallerClass(functionReference));
            }

            if (PhpCallbackFunctionUtil.isFieldCallbackFunction(functionReference, selectedIndex)) {
              return getOriginalField(selectedParameter.getParent(), getCallerClass(functionReference));
            }

            if (PhpCallbackFunctionUtil.isFunctionCallbackFunction(functionReference, selectedIndex)) {
              PhpCallbackFunctionUtil.PhpCallbackElement callback = PhpCallbackFunctionUtil.constructCallback(functionReference.getName(), selectedParameter);
              if ((callback instanceof PhpCallbackFunctionUtil.PhpCallbackMemberElement)) {
                if (callback.getCallbackElement() == selectedElement) {
                  return getOriginalMethod(selectedParameter, getCallerClass(functionReference));
                }

                return getOriginalClass(selectedElement, getCallerClass(functionReference));
              }

              if (callback != null) {
                String callbackText = callback.getCallbackText();
                PhpNamedElement originalFunction = getOriginalFunction(selectedElement.getProject(), callbackText);
                return originalFunction == null ? getOriginalMethodByClass(callbackText, getCallerClass(functionReference)) : originalFunction;
              }
            }
            return null;
          }

          @Nullable
          private PhpClassMember getOriginalField(@NotNull PsiElement root, @Nullable PhpClass callerClass) {
            if (root == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalField must not be null");
            PsiElement[] children = root.getChildren();
            String propertyName;
            if (children.length >= 2) {
              Collection classes = resolveClass(PhpIndex.getInstance(root.getProject()), children[0], callerClass);
              propertyName = getCallbackContent(children[1]);
              if ((classes != null) && (StringUtil.isNotEmpty(propertyName))) {
                for (Object clazz : classes) {
                  PhpClass phpClass = (PhpClass) clazz;
                  Field field = phpClass.findFieldByName(propertyName, false);
                  if (field != null) {
                    return field;
                  }
                }
              }
            }
            return null;
          }

          @Nullable
          private PhpClassMember getOriginalMethod(@NotNull PsiElement root, @Nullable PhpClass callerClass) {
            if (root == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalMethod must not be null");
            PsiElement[] children = root.getChildren();
            String methodName;
            if (children.length >= 2) {
              Collection classes = resolveClass(PhpIndex.getInstance(root.getProject()), children[0], callerClass);
              methodName = getCallbackContent(children[1]);
              if ((classes != null) && (StringUtil.isNotEmpty(methodName))) {
                for (Object clazz : classes) {
                  PhpClass phpClass = (PhpClass) clazz;
                  Method method = phpClass.findMethodByName(methodName);
                  if (method != null) {
                    return method;
                  }
                }
              }
            }
            return null;
          }

          @Nullable
          private PhpClassMember getOriginalMethodByClass(@NotNull String methodName, @Nullable PhpClass clazz) {
            if (methodName == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalMethodByClass must not be null");
            if ((clazz != null) && (StringUtil.isNotEmpty(methodName))) {
              Method method = clazz.findMethodByName(methodName);
              if (method != null) {
                return method;
              }
            }
            return null;
          }

          @Nullable
          private PhpNamedElement getOriginalClass(@NotNull PsiElement element, @Nullable PhpClass callerClass) {
            if (element == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalClass must not be null");
            String className = PhpCallbackFunctionUtil.getCallbackString(element);
            if (className != null) {
              PhpClass classByKeyword = checkClassKeywords(className, callerClass);
              if (classByKeyword != null) {
                return classByKeyword;
              }

              PhpIndex index = PhpIndex.getInstance(element.getProject());
              List classes = new SmartList(index.getAnyByFQN(PhpLangUtil.toFQN(className)));
              if (classes.size() > 0) {
                return (PhpNamedElement) classes.get(0);
              }
            }
            return null;
          }

          @Nullable
          private PhpNamedElement getOriginalFunction(@NotNull Project project, @NotNull String fqn) {
            if (project == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalFunction must not be null");
            if (fqn == null)
              throw new IllegalArgumentException("Argument 1 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalFunction must not be null");
            PhpIndex index = PhpIndex.getInstance(project);
            if (StringUtil.isNotEmpty(fqn)) {
              int i = fqn.lastIndexOf('\\');
              String name = i >= 0 ? fqn.substring(i + 1) : fqn;
              String namespace = i >= 0 ? fqn.substring(0, i + 1) : "\\";

              Collection functions = index.getFunctionsByName(name);
              List filteredFunctions = new SmartList(index.filterNamedByNamespace(functions, PhpLangUtil.toFQN(namespace), true));

              if (filteredFunctions.size() > 0) {
                return (PhpNamedElement) filteredFunctions.get(0);
              }
            }
            return null;
          }

          @Nullable
          public Collection<PhpClass> resolveClass(@NotNull PhpIndex index, @NotNull PsiElement element, @Nullable PhpClass callerClass) {
            if (index == null)
              throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.resolveClass must not be null");
            if (element == null)
              throw new IllegalArgumentException("Argument 1 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.resolveClass must not be null");
            PhpClass referencedClass = PhpCallbackFunctionUtil.getFirstClassByReference(element);
            if (referencedClass != null) {
              return new SmartList(referencedClass);
            }

            String callbackContent = getCallbackContent(element);
            PhpClass classByKeyword = checkClassKeywords(callbackContent, callerClass);
            if (classByKeyword != null) {
              return new SmartList(classByKeyword);
            }

            if (callbackContent == null) {
              PhpExpression classExpression = (element instanceof PhpExpression) ? (PhpExpression) element : (PhpExpression) PhpPsiUtil.getChildByCondition(element, PhpExpression.INSTANCEOF);

              callbackContent = PhpCallbackFunctionUtil.getClassFqnByExpression(classExpression);
            }
            return callbackContent == null ? null : index.getAnyByFQN(callbackContent);
          }

          @Nullable
          private PhpClass checkClassKeywords(@Nullable String callbackContent, @Nullable PhpClass callerClass) {
            if ((PhpLangUtil.equalsClassNames("self", callbackContent)) || (PhpLangUtil.equalsClassNames("static", callbackContent))) {
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.