Package org.eclipse.php.internal.core.compiler.ast.nodes

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


    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    ClassInstanceCreation expression = (ClassInstanceCreation) typedGoal
        .getExpression();
    Expression className = expression.getClassName();
    if ((className instanceof TypeReference)) {
      if (isSelf((TypeReference) className)
          && (goal.getContext() instanceof MethodContext)) {
        MethodContext methodContext = (MethodContext) goal.getContext();
        result = methodContext.getInstanceType();
View Full Code Here


                    // this is a direct ClassInstanceCreation, ie:
                    // return array('user' => new User());
                } else if (value.getClass() == ClassInstanceCreation.class) {

                    ClassInstanceCreation instance = (ClassInstanceCreation) value;

                    if (instance.getClassName().getClass() == FullyQualifiedReference.class) {

                        FullyQualifiedReference fqcn = (FullyQualifiedReference) instance.getClassName();
                        NamespaceReference nsRef = createFromFQCN(fqcn);

                        if (nsRef != null) {
                            TemplateVariable variable = new TemplateVariable(currentMethod, varName.getValue(),
                                    varName.sourceStart(), varName.sourceEnd(), nsRef.getNamespace(), nsRef.getClassName());
View Full Code Here

                        }
                    }
                    // a simple ClassInstanceCreation, ie. $contact = new ContactType();
                } else if (s.getValue().getClass() == ClassInstanceCreation.class) {

                    ClassInstanceCreation instance = (ClassInstanceCreation) s.getValue();

                    if (instance.getClassName().getClass() == FullyQualifiedReference.class) {

                        FullyQualifiedReference fqcn = (FullyQualifiedReference) instance.getClassName();
                        NamespaceReference nsRef = createFromFQCN(fqcn);

                        if (nsRef != null) {
                            TemplateVariable variable = new TemplateVariable(currentMethod, var.getName(),
                                    var.sourceStart(), var.sourceEnd(), nsRef.getNamespace(), nsRef.getClassName());
View Full Code Here

                }
            });
        }

        if (s instanceof ClassInstanceCreation) {
            ClassInstanceCreation instance = (ClassInstanceCreation) s;
            if (SymfonyCoreConstants.APP_KERNEL.equals(instance.getClassName().toString())) {
                List args = instance.getCtorParams().getChilds();
                if (args.get(0) instanceof Scalar) {
                    Scalar environment = (Scalar) args.get(0);
                    String value = environment.getValue().replace("\"", "").replace("'", "");
                    String path = sourceModule.getPath().toString();
                    Logger.debugMSG("indexing environment: " + value + " => " + path);
                    ReferenceInfo info = new ReferenceInfo(ISymfonyModelElement.ENVIRONMENT, instance.sourceStart(), instance.sourceEnd()-instance.sourceStart(), value, null, path);
                    requestor.addReference(info);
                }
            }
        }
        return super.visit(s);
View Full Code Here

                        }

                        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)) {
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.compiler.ast.nodes.ClassInstanceCreation

Copyright © 2018 www.massapicom. 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.