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

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


  public Void visitDefaultFormalParameter(DefaultFormalParameter node) {
    ElementHolder holder = new ElementHolder();

    NormalFormalParameter normalParameter = node.getParameter();
    SimpleIdentifier parameterName = normalParameter.getIdentifier();
    ParameterElementImpl parameter;
    if (normalParameter instanceof FieldFormalParameter) {
      parameter = new DefaultFieldFormalParameterElementImpl(parameterName);
      FieldElement field = fieldMap == null ? null : fieldMap.get(parameterName.getName());
      if (field != null) {
        ((DefaultFieldFormalParameterElementImpl) parameter).setField(field);
      }
    } else {
      parameter = new DefaultParameterElementImpl(parameterName);
    }
    parameter.setConst(node.isConst());
    parameter.setFinal(node.isFinal());
    parameter.setParameterKind(node.getKind());

    // set initializer, default value range
    Expression defaultValue = node.getDefaultValue();
    if (defaultValue != null) {
      visit(holder, defaultValue);

      FunctionElementImpl initializer = new FunctionElementImpl(
          defaultValue.getBeginToken().getOffset());
      initializer.setFunctions(holder.getFunctions());
      initializer.setLabels(holder.getLabels());
      initializer.setLocalVariables(holder.getLocalVariables());
      initializer.setParameters(holder.getParameters());
      initializer.setSynthetic(true);

      parameter.setInitializer(initializer);
      parameter.setDefaultValueCode(defaultValue.toSource());
    }

    // visible range
    setParameterVisibleRange(node, parameter);
View Full Code Here


  @Override
  public Void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
      parameter.setParameterKind(node.getKind());
      setParameterVisibleRange(node, parameter);

      currentHolder.addParameter(parameter);
      parameterName.setStaticElement(parameter);
    }
View Full Code Here

  @Override
  public Void visitSimpleFormalParameter(SimpleFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
      parameter.setConst(node.isConst());
      parameter.setFinal(node.isFinal());
      parameter.setParameterKind(node.getKind());
      setParameterVisibleRange(node, parameter);

      currentHolder.addParameter(parameter);
      parameterName.setStaticElement(parameter);
    }
View Full Code Here

      variable.setGetter(getter);

      if (!isFinal) {
        PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(variable);
        setter.setSetter(true);
        ParameterElementImpl parameter = new ParameterElementImpl(
            "_" + variable.getName(),
            variable.getNameOffset());
        parameter.setSynthetic(true);
        parameter.setParameterKind(ParameterKind.REQUIRED);
        setter.setParameters(new ParameterElement[] {parameter});

        currentHolder.addAccessor(setter);
        variable.setSetter(setter);
      }
View Full Code Here

    //
    if (parameterElts.size() > 0) {
      if (parameterElts.get(0).getParameterKind() == ParameterKind.NAMED) {
        // Named parameters, consider the names when matching the parameterElts to the overriddenParameterElts
        for (int i = 0; i < parameterElts.size(); i++) {
          ParameterElementImpl parameterElt = parameterElts.get(i);
          EvaluationResultImpl result = parameterElt.getEvaluationResult();
          // TODO (jwren) Ignore Object types, see Dart bug 11287
          if (isUserDefinedObject(result)) {
            continue;
          }
          String parameterName = parameterElt.getName();
          for (int j = 0; j < overriddenParameterElts.size(); j++) {
            ParameterElementImpl overriddenParameterElt = overriddenParameterElts.get(j);
            String overriddenParameterName = overriddenParameterElt.getName();
            if (parameterName != null && parameterName.equals(overriddenParameterName)) {
              EvaluationResultImpl overriddenResult = overriddenParameterElt.getEvaluationResult();
              if (isUserDefinedObject(overriddenResult)) {
                break;
              }
              if (!result.equalValues(typeProvider, overriddenResult)) {
                errorReporter.reportErrorForNode(
                    StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED,
                    formalParameters.get(i),
                    overriddenExecutable.getEnclosingElement().getDisplayName(),
                    overriddenExecutable.getDisplayName(),
                    parameterName);
                foundError = true;
              }
            }
          }
        }
      } else {
        // Positional parameters, consider the positions when matching the parameterElts to the overriddenParameterElts
        for (int i = 0; i < parameterElts.size() && i < overriddenParameterElts.size(); i++) {
          ParameterElementImpl parameterElt = parameterElts.get(i);
          EvaluationResultImpl result = parameterElt.getEvaluationResult();
          // TODO (jwren) Ignore Object types, see Dart bug 11287
          if (isUserDefinedObject(result)) {
            continue;
          }
          ParameterElementImpl overriddenParameterElt = overriddenParameterElts.get(i);
          EvaluationResultImpl overriddenResult = overriddenParameterElt.getEvaluationResult();
          if (isUserDefinedObject(overriddenResult)) {
            continue;
          }
          if (!result.equalValues(typeProvider, overriddenResult)) {
            errorReporter.reportErrorForNode(
View Full Code Here

    int numOfParameters = numOfRequiredParameters + numOfPositionalParameters
        + namedParameters.length;
    ParameterElement[] parameters = new ParameterElement[numOfParameters];
    int i = 0;
    for (int j = 0; j < numOfRequiredParameters; j++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl("", 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.REQUIRED);
      parameters[i] = parameter;
    }
    for (int k = 0; k < numOfPositionalParameters; k++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl("", 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.POSITIONAL);
      parameters[i] = parameter;
    }
    for (int m = 0; m < namedParameters.length; m++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl(namedParameters[m], 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.NAMED);
      parameters[i] = parameter;
    }
    executable.setReturnType(dynamicType);
    executable.setParameters(parameters);
View Full Code Here

    // same order. We compute a type by unioning pointwise.
    ExecutableElement e_0 = elementArrayToMerge[0];
    ParameterElement[] ps_0 = e_0.getParameters();
    ParameterElementImpl[] ps_out = new ParameterElementImpl[ps_0.length];
    for (int j = 0; j < ps_out.length; j++) {
      ps_out[j] = new ParameterElementImpl(ps_0[j].getName(), 0);
      ps_out[j].setSynthetic(true);
      ps_out[j].setType(ps_0[j].getType());
      ps_out[j].setParameterKind(ps_0[j].getParameterKind());
    }
    Type r_out = e_0.getReturnType();
View Full Code Here

        }
      }
    } else if (kind == ElementKind.PARAMETER) {
      node.setStaticElement(element);
      if (node.inSetterContext()) {
        ParameterElementImpl parameterImpl = (ParameterElementImpl) element;
        parameterImpl.markPotentiallyMutatedInScope();
        // If we are in some closure, check if it is not the same as where variable is declared.
        if (enclosingFunction != null
            && !ObjectUtilities.equals(element.getEnclosingElement(), enclosingFunction)) {
          parameterImpl.markPotentiallyMutatedInClosure();
        }
      }
    }
    return null;
  }
View Full Code Here

  @Override
  public Void visitFieldFormalParameter(FieldFormalParameter node) {
    super.visitFieldFormalParameter(node);
    Element element = node.getIdentifier().getStaticElement();
    if (element instanceof ParameterElementImpl) {
      ParameterElementImpl parameter = (ParameterElementImpl) element;
      FormalParameterList parameterList = node.getParameters();
      if (parameterList == null) {
        Type type;
        TypeName typeName = node.getType();
        if (typeName == null) {
          type = dynamicType;
          if (parameter instanceof FieldFormalParameterElement) {
            FieldElement fieldElement = ((FieldFormalParameterElement) parameter).getField();
            if (fieldElement != null) {
              type = fieldElement.getType();
            }
          }
        } else {
          type = getType(typeName);
        }
        parameter.setType(type);
      } else {
        setFunctionTypedParameterType(parameter, node.getType(), node.getParameters());
      }
    } else {
      // TODO(brianwilkerson) Report this internal error
View Full Code Here

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

TOP

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

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.