Examples of PHPMethodDeclaration


Examples of org.eclipse.php.internal.core.compiler.ast.nodes.PHPMethodDeclaration

   * @param type
   * @return boolean
   */
  private boolean isArrayType(MethodContext methodContext, IType type) {

    PHPMethodDeclaration methodDeclaration = (PHPMethodDeclaration) methodContext
        .getMethodNode();

    PHPDocBlock[] docBlocks = new PHPDocBlock[0];

    try {
      IModelElement element = methodContext.getSourceModule()
          .getElementAt(methodDeclaration.getNameStart());
      if (element instanceof IMethod) {
        IMethod method = (IMethod) element;
        if (method.getDeclaringType() != null) {
          docBlocks = PHPModelUtils
              .getTypeHierarchyMethodDoc(
                  method.getDeclaringType(),
                  methodContext.getCache() != null ? methodContext
                      .getCache().getSuperTypeHierarchy(
                          method.getDeclaringType(),
                          null) : null, method
                      .getElementName(), true, null);
        } else {
          docBlocks = new PHPDocBlock[] { methodDeclaration
              .getPHPDoc() };
        }
      } else {
        docBlocks = new PHPDocBlock[] { methodDeclaration.getPHPDoc() };
      }

    } catch (CoreException e) {
      Logger.logException(e);
    }
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.nodes.PHPMethodDeclaration

        if(!isSymfonyResource)
            return false;

        if (s instanceof PHPMethodDeclaration) {

            PHPMethodDeclaration method = (PHPMethodDeclaration) s;
            PHPDocBlock docBlock = method.getPHPDoc();

            if (docBlock != null) {

                PHPDocTag[] tags = docBlock.getTags();

                for (PHPDocTag tag : tags) {

                    String value = tag.getValue();

                    if (tag.getReferences().length == 2) {

                        SimpleReference[] refs = tag.getReferences();
                        SimpleReference varName = refs[0];
                        SimpleReference varType = refs[1];

                        if(varName.getName().equals("$view") && varType.getName().equals("string")) {

                            int length = method.sourceEnd() - method.sourceStart();
                            ReferenceInfo viewMethod = new ReferenceInfo(ISymfonyModelElement.VIEW_METHOD, method.sourceStart()    , length, method.getName(), null, null);
                            requestor.addReference(viewMethod);

                        } else if (value.contains("route") || value.contains("url")) {

                            int length = method.sourceEnd() - method.sourceStart();
                            ReferenceInfo routeMethod = new ReferenceInfo(ISymfonyModelElement.ROUTE_METHOD, method.sourceStart(), length, method.getName(), null, null);
                            requestor.addReference(routeMethod);

                        }
                    }
                }
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.nodes.PHPMethodDeclaration

        if (!methods.contains(s))
            methods.add(s);

        if (s instanceof PHPMethodDeclaration) {

            PHPMethodDeclaration phpMethod = (PHPMethodDeclaration) s;

            if (inTwigExtension&& phpMethod.getName().equals(TwigCoreConstants.GET_FILTERS)) {

                phpMethod.traverse(new PHPASTVisitor()
                {

                    @Override
                    public boolean visit(ArrayElement s) throws Exception
                    {

                        Expression key = s.getKey();
                        Expression value = s.getValue();

                        if (key == null | value == null) {
                            return false;
                        }

                        if (key.getClass() == Scalar.class && value.getClass() == ClassInstanceCreation.class) {

                            Scalar name = (Scalar) key;
                            ClassInstanceCreation filterClass = (ClassInstanceCreation) value;

                            CallArgumentsList ctorParams = filterClass.getCtorParams();
                            Object child = ctorParams.getChilds().get(0);

                            if (child instanceof VariableReference && ((VariableReference)child).getName().equals("$this") &&
                                    filterClass.getClassName().toString().equals((TwigCoreConstants.TWIG_FILTER_METHOD))) {
                               
                                    if (ctorParams.getChilds().size() > 2 && ctorParams.getChilds().get(1) instanceof Scalar) {
                                        Scalar internal = (Scalar) ctorParams.getChilds().get(1);
                                        String elemName = name.getValue().replaceAll("['\"]", "");
                                        Filter filter = new Filter(elemName);
                                        filter.setInternalFunction(internal.getValue().replaceAll("['\"]", ""));
                                        filter.setPhpClass(currentClass.getName());
                                        filters.add(filter);
                                    }
                            }
                           
                            if (!(child instanceof Scalar)) {
                                return true;
                            }

                            Scalar internal = (Scalar) child;

                            if (filterClass.getClassName().toString().equals(TwigCoreConstants.TWIG_FILTER_FUNCTION)) {

                                String elemName = name.getValue().replaceAll("['\"]", "");

                                Filter filter = new Filter(elemName);
                                filter.setInternalFunction(internal.getValue()
                                        .replaceAll("['\"]", ""));
                                filter.setPhpClass(currentClass.getName());

                                filters.add(filter);

                            }
                        }
                        return true;
                    }
                });

            } else if (inTwigExtension && TwigCoreConstants.GET_TESTS.equals(s.getName())) {

                phpMethod.traverse(new PHPASTVisitor()
                {

                    @Override
                    public boolean visit(ArrayElement s) throws Exception
                    {

                        Expression key = s.getKey();
                        Expression value = s.getValue();

                        if (key == null || value == null)
                            return false;

                        if (key.getClass() == Scalar.class && value.getClass() == ClassInstanceCreation.class) {

                            Scalar name = (Scalar) key;
                            ClassInstanceCreation functionClass = (ClassInstanceCreation) value;

                            CallArgumentsList args = functionClass.getCtorParams();
                            Scalar internalFunction = (Scalar) args.getChilds().get(0);

                            if (internalFunction == null)
                                return true;

                            if (functionClass.getClassName().toString().equals(TwigCoreConstants.TWIG_TEST_FUNCTION)) {

                                String elemName = name.getValue().replaceAll("['\"]", "");

                                JSONObject metadata = new JSONObject();
                                metadata.put(TwigType.PHPCLASS,currentClass.getName());

                                Test test = new Test(elemName);
                                test.setPhpClass(currentClass.getName());
                                test.setInternalFunction(internalFunction.getValue().replaceAll("['\"]", ""));
                                tests.add(test);

                            }
                        }
                        return true;
                    }
                });

            } else if (inTwigExtension&& TwigCoreConstants.GET_FUNCTIONS.equals(s.getName())) {

                phpMethod.traverse(new PHPASTVisitor()
                {
                    @Override
                    public boolean visit(ArrayElement s) throws Exception
                    {

                        Expression key = s.getKey();
                        Expression value = s.getValue();

                        if (key == null || value == null) {
                            return false;
                        }

                        if (key.getClass() == Scalar.class && value.getClass() == ClassInstanceCreation.class) {

                            Scalar name = (Scalar) key;
                            ClassInstanceCreation functionClass = (ClassInstanceCreation) value;
                            CallArgumentsList args = functionClass.getCtorParams();
                            String functionClassName = functionClass.getClassName().toString();
                            int index = -1;
                           
                            if (functionClassName.equals(TwigCoreConstants.TWIG_FUNCTION_FUNCTION)) {
                                index = 0;
                            } else if (functionClassName.equals(TwigCoreConstants.TWIG_FUNCTION_METHOD)) {
                                index = 1;
                            }

                            if (index > -1 && args.getChilds().get(index) instanceof Scalar) {

                                Scalar internalFunction = (Scalar) args.getChilds().get(index);

                                if (internalFunction == null) {
                                    return true;
                                }

                                String elemName = name.getValue().replaceAll("['\"]", "");
                                JSONObject metadata = new JSONObject();
                                metadata.put(TwigType.PHPCLASS, currentClass.getName());

                                Function function = new Function(elemName);
                                function.setPhpClass(currentClass.getName());
                                function.setInternalFunction(internalFunction.getValue().replaceAll("['\"]", ""));
                                functions.add(function);
                            }
                        }
                        return true;
                    }
                });

            } else if (inTokenParser && TwigCoreConstants.PARSE_TOKEN_METHOD.equals(s.getName())) {

                inTagParseMethod = true;

            } else if (inTokenParser && TwigCoreConstants.PARSE_GET_TAG_METHOD.equals(s.getName())) {

                phpMethod.traverse(new PHPASTVisitor()
                {
                    @Override
                    public boolean visit(ReturnStatement s) throws Exception
                    {
                        if (s.getExpr().getClass() == Scalar.class) {
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.nodes.PHPMethodDeclaration

    {
        for (Test test : tests) {
            for (MethodDeclaration method : methods) {
                if (method.getName().equals(test.getInternalFunction())) {

                    PHPMethodDeclaration phpMethod = (PHPMethodDeclaration) method;
                    PHPDocBlock doc = phpMethod.getPHPDoc();

                    if (doc != null) {
                        test.addDoc(doc);
                    }

                    Logger.debugMSG("indexing test tag: "
                            + test.getElementName() + " with metadata: "
                            + test.getMetadata());

                    ReferenceInfo info = new ReferenceInfo(
                            ITwigModelElement.TEST, 0, 0,
                            test.getElementName(), test.getMetadata(), null);
                    addReferenceInfo(info);

                }
            }
        }

        for (Function function : functions) {

            for (MethodDeclaration method : methods) {

                if (method.getName().equals(function.getInternalFunction())) {

                    PHPMethodDeclaration phpMethod = (PHPMethodDeclaration) method;
                    PHPDocBlock doc = phpMethod.getPHPDoc();

                    if (doc != null) {
                        function.addDoc(doc);
                    }

                    function.addArgs(method.getArguments());

                    Logger.debugMSG("indexing function: "
                            + function.getElementName() + " with metadata: "
                            + function.getMetadata());
                    ReferenceInfo info = new ReferenceInfo(
                            ITwigModelElement.FUNCTION, 0, 0,
                            function.getElementName(), function.getMetadata(),
                            null);
                    addReferenceInfo(info);

                }
            }
        }

        for (Filter filter : filters) {

            for (MethodDeclaration method : methods) {

                if (method.getName().equals(filter.getInternalFunction())) {

                    PHPMethodDeclaration phpMethod = (PHPMethodDeclaration) method;
                    PHPDocBlock doc = phpMethod.getPHPDoc();

                    if (doc != null) {
                        filter.addDoc(doc);
                    }
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.