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

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


    return false;
  }

  public boolean visit(ReflectionArrayVariableReference s) throws Exception {
    if (s.getExpression() instanceof Scalar) {
      Scalar name = (Scalar) s.getExpression();
      if (name.getScalarType() == Scalar.TYPE_STRING) {
        String dolarName = DOLLAR + name.getValue();
        check(dolarName, name.start(), name.end());
      }
    }
    operations.push(Operation.USE);

    return super.visit(s);
View Full Code Here


    return super.endvisit(s);
  }

  public boolean visit(ReflectionVariableReference s) throws Exception {
    if (s.getExpression() instanceof Scalar) {
      Scalar name = (Scalar) s.getExpression();
      if (name.getScalarType() == Scalar.TYPE_STRING) {
        String dolarName = DOLLAR + name.getValue();
        check(dolarName, name.start(), name.end());
      }
    }
    operations.push(Operation.USE);

    return super.visit(s);
View Full Code Here

            if (!(element.getKey() instanceof Scalar)) {
                return false;
            }
           
            if (element.getValue() instanceof InfixExpression) {
                Scalar namespace = (Scalar) element.getKey();
                Scalar path = (Scalar) ((InfixExpression) element.getValue()).getRight();
                VariableReference reference = (VariableReference) ((InfixExpression) element.getValue()).getLeft();
                extractPsr0(namespace, path, reference);
                return false;
            } else if(element.getValue() instanceof ArrayCreation) {
                Scalar namespace = (Scalar) element.getKey();
                ArrayCreation paths = (ArrayCreation) element.getValue();
                for (ArrayElement elem  : paths.getElements()) {
                  if (elem.getValue() instanceof InfixExpression) {
                    Scalar path = (Scalar) ((InfixExpression) elem.getValue()).getRight();
                        VariableReference reference = (VariableReference) ((InfixExpression) elem.getValue()).getLeft();
                        extractPsr0(namespace, path, reference);
                  }
                  return false;
                }
View Full Code Here

      return null;
    }
    if (node instanceof ConstantDeclaration) {
      ConstantDeclaration constantDeclaration = (ConstantDeclaration) node;
      if (constantDeclaration.getConstantValue() instanceof Scalar) {
        Scalar scalar = (Scalar) constantDeclaration.getConstantValue();
        return scalar.getValue();
      }
    }
    return null;

  }
View Full Code Here

        List<ASTNode> childs = args.getChilds();
        int i = 0;
        argNames = new String[childs.size()];
        for (ASTNode o : childs) {
          if (o instanceof Scalar) {
            Scalar arg = (Scalar) o;
            argNames[i] = ASTUtils.stripQuotes(arg.getValue());
          }
          i++;
        }
      }
      return new MethodElementReturnTypeGoal(typedGoal.getContext(),
View Full Code Here

        if (args.size() == 2) {
          ASTNode firstArg = args.get(0);
          ASTNode secondArg = args.get(0);
          if (firstArg instanceof Scalar
              && secondArg instanceof Scalar) {
            Scalar constantName = (Scalar) firstArg;
            Scalar constantValue = (Scalar) secondArg;
            if (this.constantName.equals(stripQuotes(constantName
                .getValue()))) {
              declarations.add(constantValue);
            }
          }
View Full Code Here

        if (!(infix.getLeft() instanceof Scalar) || !(infix.getRight() instanceof Scalar)) {
          return;
        }
       
        Scalar left = (Scalar) infix.getLeft();       
        Scalar right = (Scalar) infix.getRight();
       
        if ("__DIR__".equals(left.getValue())) {
                   
          String rightPath = right.getValue().replace("'", "").replace("\"", "").replaceFirst("/", "");
          paths.add(path.append(rightPath));
         
        }
               
      } catch (Exception e) {
View Full Code Here

        if (list.getChilds().size() > 1) {

            if (list.getChilds().get(0) instanceof Scalar && list.getChilds().get(1) instanceof ArrayCreation) {

                Scalar scalar = (Scalar) list.getChilds().get(0);
                String viewPath = StringUtils.stripQuotes(scalar.getValue());
                ArrayCreation params = (ArrayCreation) list.getChilds().get(1);
                parseVariablesFromArray(params, viewPath);

            }
        }
View Full Code Here

                if (callName.startsWith(SymfonyCoreConstants.RENDER_PREFIX)) {

                    CallArgumentsList args = expression.getArgs();
                    List<ASTNode> children = args.getChilds();

                    Scalar view = (Scalar) children.get(0);

                    if (children.size() >= 2 && children.get(1).getClass() == ArrayCreation.class) {
                        parseVariablesFromArray((ArrayCreation) children.get(1), PathUtils.createViewPath(view));
                    } else {
                        Logger.log(Logger.WARNING, "Unable to parse view variable from " + children.toString());
View Full Code Here

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

            if (key.getClass() == Scalar.class) {

                Scalar varName = (Scalar) key;

                // something in the form:  return array ('foo' => $bar);
                // check the type of $bar:
                if (value.getClass() == VariableReference.class) {

                    VariableReference ref = (VariableReference) value;

                    for (TemplateVariable variable : deferredVariables) {

                        // we got the variable, add it the the templateVariables
                        if (ref.getName().equals(variable.getName())) {
                            // alter the variable name

                            variable.setName(varName.getValue());

                            templateVariables.put(variable, viewPath);
                            break;
                        }
                    }

                    // this is more complicated, something like:
                    // return array('form' => $form->createView());
                    // we need to infer $form and then check the returntype of createView()
                } else if(value.getClass() == PHPCallExpression.class) {

                    PHPCallExpression callExp = (PHPCallExpression) value;

                    VariableReference varRef = null;
                    try {
                        varRef = (VariableReference) callExp.getReceiver();
                    } catch (ClassCastException e) {
                        Logger.log(Logger.WARNING, callExp.getReceiver().getClass().toString()
                                + " could not be cast to VariableReference in " + currentMethod.getName() );

                    }


                    if (varRef == null) {
                        continue;
                    }

                    SimpleReference callName = callExp.getCallName();

                    // we got the variable name (in this case $form)
                    // now search for the defferedVariable:
                    for (TemplateVariable deferred : deferredVariables) {

                        // we got it, find the returntype of the
                        // callExpression
                        if (deferred.getName().equals(varRef.getName())) {

                            TemplateVariable tempVar = SymfonyModelAccess.getDefault()
                                    .createTemplateVariableByReturnType(source, currentMethod,
                                            callName, deferred.getClassName(), deferred.getNamespace(),
                                            varRef.getName(), cache);

                            templateVariables.put(tempVar, viewPath);
                            break;
                        }
                    }

                    // 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());
                            templateVariables.put(variable, viewPath);
                        }
                    }
                } else {
View Full Code Here

TOP

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

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.