Package com.google.dart.engine.element

Examples of com.google.dart.engine.element.ParameterElement


  }

  @Override
  public Void visitDefaultFormalParameter(DefaultFormalParameter node) {
    SimpleIdentifier parameterName = node.getParameter().getIdentifier();
    ParameterElement element = getElementForParameter(node, parameterName);
    Expression defaultValue = node.getDefaultValue();
    if (defaultValue != null) {
      ExecutableElement outerExecutable = enclosingExecutable;
      try {
        if (element == null) {
          // TODO(brianwilkerson) Report this internal error.
        } else {
          enclosingExecutable = element.getInitializer();
        }
        defaultValue.accept(this);
      } finally {
        enclosingExecutable = outerExecutable;
      }
      processElement(enclosingExecutable);
    }
    ParameterElement outerParameter = enclosingParameter;
    try {
      enclosingParameter = element;
      processElement(enclosingParameter);
      return super.visitDefaultFormalParameter(node);
    } finally {
View Full Code Here


  @Override
  public Void visitFieldFormalParameter(FieldFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElement element = getElementForParameter(node, parameterName);
      ParameterElement outerParameter = enclosingParameter;
      try {
        enclosingParameter = element;
        processElement(enclosingParameter);
        return super.visitFieldFormalParameter(node);
      } finally {
View Full Code Here

  @Override
  public Void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElement element = getElementForParameter(node, parameterName);
      ParameterElement outerParameter = enclosingParameter;
      try {
        enclosingParameter = element;
        processElement(enclosingParameter);
        return super.visitFunctionTypedFormalParameter(node);
      } finally {
View Full Code Here

  @Override
  public Void visitSimpleFormalParameter(SimpleFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElement element = getElementForParameter(node, parameterName);
      ParameterElement outerParameter = enclosingParameter;
      try {
        enclosingParameter = element;
        processElement(enclosingParameter);
        return super.visitSimpleFormalParameter(node);
      } finally {
View Full Code Here

   */
  private static List<String> getNamedParameterNames(ExecutableElement executableElement) {
    ArrayList<String> namedParameterNames = new ArrayList<String>();
    ParameterElement[] parameters = executableElement.getParameters();
    for (int i = 0; i < parameters.length; i++) {
      ParameterElement parameterElement = parameters[i];
      if (parameterElement.getParameterKind() == ParameterKind.NAMED) {
        namedParameterNames.add(parameterElement.getName());
      }
    }
    return namedParameterNames;
  }
View Full Code Here

  private static int getNumOfParameters(ExecutableElement executableElement,
      ParameterKind parameterKind) {
    int parameterCount = 0;
    ParameterElement[] parameters = executableElement.getParameters();
    for (int i = 0; i < parameters.length; i++) {
      ParameterElement parameterElement = parameters[i];
      if (parameterElement.getParameterKind() == parameterKind) {
        parameterCount++;
      }
    }
    return parameterCount;
  }
View Full Code Here

    for (int i = 0; i < argumentCount; i++) {
      Expression argument = arguments.get(i);
      if (argument instanceof NamedExpression) {
        SimpleIdentifier nameNode = ((NamedExpression) argument).getName().getLabel();
        String name = nameNode.getName();
        ParameterElement element = namedParameters.get(name);
        if (element == null) {
          ErrorCode errorCode = reportError ? CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER
              : StaticWarningCode.UNDEFINED_NAMED_PARAMETER;
          resolver.reportErrorForNode(errorCode, nameNode, name);
        } else {
View Full Code Here

    // set inferred types for parameters
    NodeList<FormalParameter> parameters = closure.getParameters().getParameters();
    ParameterElement[] expectedParameters = expectedClosureType.getParameters();
    for (int i = 0; i < parameters.size() && i < expectedParameters.length; i++) {
      FormalParameter parameter = parameters.get(i);
      ParameterElement element = parameter.getElement();
      Type currentType = getBestType(element);
      // may be override the type
      Type expectedType = expectedParameters[i].getType();
      if (currentType == null || expectedType.isMoreSpecificThan(currentType)) {
        overrideManager.setType(element, expectedType);
View Full Code Here

  /**
   * Try to infer types of parameters of the {@link FunctionExpression} arguments.
   */
  private void inferFunctionExpressionsParametersTypes(ArgumentList argumentList) {
    for (Expression argument : argumentList.getArguments()) {
      ParameterElement parameter = argument.getPropagatedParameterElement();
      if (parameter == null) {
        parameter = argument.getStaticParameterElement();
      }
      if (parameter != null) {
        inferFunctionExpressionParametersTypes(argument, parameter.getType());
      }
    }
  }
View Full Code Here

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

TOP

Related Classes of com.google.dart.engine.element.ParameterElement

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.