Package com.google.dart.engine.internal.element

Examples of com.google.dart.engine.internal.element.ConstructorElementImpl


      inFunction = wasInFunction;
    }

    FunctionBody body = node.getBody();
    SimpleIdentifier constructorName = node.getName();
    ConstructorElementImpl element = new ConstructorElementImpl(constructorName);
    if (node.getFactoryKeyword() != null) {
      element.setFactory(true);
    }
    element.setFunctions(holder.getFunctions());
    element.setLabels(holder.getLabels());
    element.setLocalVariables(holder.getLocalVariables());
    element.setParameters(holder.getParameters());
    element.setConst(node.getConstKeyword() != null);
    if (body.isAsynchronous()) {
      element.setAsynchronous(true);
    }
    if (body.isGenerator()) {
      element.setGenerator(true);
    }

    currentHolder.addConstructor(element);
    node.setElement(element);
    if (constructorName == null) {
      Identifier returnType = node.getReturnType();
      if (returnType != null) {
        element.setNameOffset(returnType.getOffset());
      }
    } else {
      constructorName.setStaticElement(element);
    }
    holder.validate();
View Full Code Here


   *
   * @param interfaceType the interface type for which to create a default constructor
   * @return the {@link ConstructorElement}s array with the single default constructor element
   */
  private ConstructorElement[] createDefaultConstructors(InterfaceTypeImpl interfaceType) {
    ConstructorElementImpl constructor = new ConstructorElementImpl(null);
    constructor.setSynthetic(true);
    constructor.setReturnType(interfaceType);
    FunctionTypeImpl type = new FunctionTypeImpl(constructor);
    functionTypesToFix.add(type);
    constructor.setType(type);
    return new ConstructorElement[] {constructor};
  }
View Full Code Here

          constantVisitor);
      expression.setEvaluationResult(result);
    } else if (constNode instanceof ConstructorDeclaration) {
      ConstructorDeclaration declaration = (ConstructorDeclaration) constNode;
      NodeList<ConstructorInitializer> initializers = declaration.getInitializers();
      ConstructorElementImpl constructor = (ConstructorElementImpl) declaration.getElement();
      constructor.setConstantInitializers(new InitializerCloner().cloneNodeList(initializers));
    } else if (constNode instanceof FormalParameter) {
      if (constNode instanceof DefaultFormalParameter) {
        DefaultFormalParameter parameter = ((DefaultFormalParameter) constNode);
        ParameterElement element = parameter.getElement();
        Expression defaultValue = parameter.getDefaultValue();
View Full Code Here

      // case, the error has already been reported, so considering it an unknown value will
      // suppress further errors.
      return constantVisitor.validWithUnknownValue(definingClass);
    }
    beforeGetConstantInitializers(constructor);
    ConstructorElementImpl constructorBase = (ConstructorElementImpl) getConstructorBase(constructor);
    List<ConstructorInitializer> initializers = constructorBase.getConstantInitializers();
    if (initializers == null) {
      // This can happen in some cases where there are compile errors in the code being analyzed
      // (for example if the code is trying to create a const instance using a non-const
      // constructor, or the node we're visiting is involved in a cycle).  The error has already
      // been reported, so consider it an unknown value to suppress further errors.
      return constantVisitor.validWithUnknownValue(definingClass);
    }
    HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImpl>();
    HashMap<String, DartObjectImpl> parameterMap = new HashMap<String, DartObjectImpl>();
    ParameterElement[] parameters = constructorBase.getParameters();
    int parameterCount = parameters.length;
    for (int i = 0; i < parameterCount; i++) {
      ParameterElement parameter = parameters[i];
      while (parameter instanceof ParameterMember) {
        parameter = ((ParameterMember) parameter).getBaseElement();
View Full Code Here

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    super.visitConstructorDeclaration(node);
    ConstructorElement element = node.getElement();
    if (element instanceof ConstructorElementImpl) {
      ConstructorElementImpl constructorElement = (ConstructorElementImpl) element;
      ConstructorName redirectedNode = node.getRedirectedConstructor();
      if (redirectedNode != null) {
        // set redirected factory constructor
        ConstructorElement redirectedElement = redirectedNode.getStaticElement();
        constructorElement.setRedirectedConstructor(redirectedElement);
      } else {
        // set redirected generative constructor
        for (ConstructorInitializer initializer : node.getInitializers()) {
          if (initializer instanceof RedirectingConstructorInvocation) {
            ConstructorElement redirectedElement = ((RedirectingConstructorInvocation) initializer).getStaticElement();
            constructorElement.setRedirectedConstructor(redirectedElement);
          }
        }
      }
      setMetadata(constructorElement, node);
    }
View Full Code Here

   * @param argumentTypes the types with which the parameters are to be replaced
   * @return the implicit constructor that was created
   */
  private ConstructorElement createImplicitContructor(InterfaceType classType,
      ConstructorElement explicitConstructor, Type[] parameterTypes, Type[] argumentTypes) {
    ConstructorElementImpl implicitConstructor = new ConstructorElementImpl(
        explicitConstructor.getName(),
        -1);
    implicitConstructor.setSynthetic(true);
    implicitConstructor.setRedirectedConstructor(explicitConstructor);
    implicitConstructor.setConst(explicitConstructor.isConst());
    implicitConstructor.setReturnType(classType);
    ParameterElement[] explicitParameters = explicitConstructor.getParameters();
    int count = explicitParameters.length;
    if (count > 0) {
      ParameterElement[] implicitParameters = new ParameterElement[count];
      for (int i = 0; i < count; i++) {
        ParameterElement explicitParameter = explicitParameters[i];
        ParameterElementImpl implicitParameter = new ParameterElementImpl(
            explicitParameter.getName(),
            -1);
        implicitParameter.setConst(explicitParameter.isConst());
        implicitParameter.setFinal(explicitParameter.isFinal());
        implicitParameter.setParameterKind(explicitParameter.getParameterKind());
        implicitParameter.setSynthetic(true);
        implicitParameter.setType(explicitParameter.getType().substitute(
            argumentTypes,
            parameterTypes));
        implicitParameters[i] = implicitParameter;
      }
      implicitConstructor.setParameters(implicitParameters);
    }
    FunctionTypeImpl type = new FunctionTypeImpl(implicitConstructor);
    type.setTypeArguments(classType.getTypeArguments());
    implicitConstructor.setType(type);
    return implicitConstructor;
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.element.ConstructorElementImpl

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.