Examples of PHPASTVisitor


Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

            final ISourceModule module = (ISourceModule) ((IModelElement) match.getElement()).getAncestor(IModelElement.SOURCE_MODULE);
            if (module != null && RefactoringAvailabilityTester.isRenameAvailable(module)) {
              ModuleDeclaration moduleDeclaration = SourceParserUtil.getModuleDeclaration(module);
              if (moduleDeclaration != null) {
                try {
                  moduleDeclaration.traverse(new PHPASTVisitor() {
                    @Override
                    public boolean visit(FullyQualifiedReference s) throws Exception {
                      if (s.sourceStart() == match.getOffset() && s.sourceEnd() == match.getOffset() + match.getLength()) {
                        IModelElement sourceElement = PDTModelUtils.getSourceElement(module, s.sourceStart(), s.matchLength());
                        if (sourceElement != null) {
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

        if (enclosingElementSourceRange != null) {
          final int enclosingElementSourceStart = enclosingElementSourceRange.getOffset();
          final int enclosingElementSourceEnd = enclosingElementSourceRange.getOffset() + enclosingElementSourceRange.getLength();

          try {
            moduleDeclaration.traverse(new PHPASTVisitor() {
              @Override
              public boolean visit(ArrayVariableReference s) throws Exception {
                return visit((VariableReference) s);
              }
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

  public static boolean isInUseTraitStatement(ModuleDeclaration rootNode,
      final int offset) {
    final boolean[] found = new boolean[1];
    found[0] = false;
    try {
      rootNode.traverse(new PHPASTVisitor() {
        public boolean visit(TraitUseStatement s) throws Exception {
          if (s.sourceStart() <= offset && s.sourceEnd() >= offset) {
            found[0] = true;
          }
          return false;
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

        if(!isSymfonyResource) {
            return false;
        }

        if (s.getClass() == Block.class) {
            s.traverse(new PHPASTVisitor() {
                @Override
                public boolean visit(UseStatement s) throws Exception {
                    useStatements.add(s);
                    return true;
                }
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

            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.visitor.PHPASTVisitor

    public boolean visit(Statement s) throws Exception
    {
        if (!inTagParseMethod)
            return false;

        s.traverse(new PHPASTVisitor()
        {
            @Override
            public boolean visit(PHPCallExpression callExpr) throws Exception
            {
                SimpleReference ref = callExpr.getCallName();

                if (ref != null
                        && TwigCoreConstants.PARSE_SUB.equals(ref.getName())) {

                    callExpr.traverse(new PHPASTVisitor()
                    {
                        @Override
                        public boolean visit(ArrayCreation array)
                                throws Exception
                        {
View Full Code Here

Examples of org.eclipse.php.internal.core.compiler.ast.visitor.PHPASTVisitor

    {

        final List<String> statements = new ArrayList<String>();

        try {
            method.traverse(new PHPASTVisitor()
            {

                public boolean visit(ReturnStatement s) throws Exception
                {
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.