Package com.google.dart.engine.type

Examples of com.google.dart.engine.type.FunctionType


   */
  private Type getIteratorElementType(Expression iteratorExpression) {
    Type expressionType = iteratorExpression.getBestType();
    if (expressionType instanceof InterfaceType) {
      InterfaceType interfaceType = (InterfaceType) expressionType;
      FunctionType iteratorFunction = inheritanceManager.lookupMemberType(interfaceType, "iterator");
      if (iteratorFunction == null) {
        // TODO(brianwilkerson) Should we report this error?
        return null;
      }
      Type iteratorType = iteratorFunction.getReturnType();
      if (iteratorType instanceof InterfaceType) {
        InterfaceType iteratorInterfaceType = (InterfaceType) iteratorType;
        FunctionType currentFunction = inheritanceManager.lookupMemberType(
            iteratorInterfaceType,
            "current");
        if (currentFunction == null) {
          // TODO(brianwilkerson) Should we report this error?
          return null;
        }
        return currentFunction.getReturnType();
      }
    }
    return null;
  }
View Full Code Here


    FunctionExpression closure = (FunctionExpression) mayBeClosure;
    // prepare expected closure type
    if (!(mayByFunctionType instanceof FunctionType)) {
      return;
    }
    FunctionType expectedClosureType = (FunctionType) mayByFunctionType;

    // If the expectedClosureType is not more specific than the static type, return.
    Type staticClosureType = closure.getElement() != null ? closure.getElement().getType() : null;
    if (staticClosureType != null && !expectedClosureType.isMoreSpecificThan(staticClosureType)) {
      return;
    }

    // set propagated type for the closure
    closure.setPropagatedType(expectedClosureType);
    // 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
View Full Code Here

    if (element instanceof PropertyAccessorElement) {
      //
      // This is a function invocation expression disguised as something else. We are invoking a
      // getter and then invoking the returned function.
      //
      FunctionType propertyType = ((PropertyAccessorElement) element).getType();
      if (propertyType != null) {
        Type returnType = propertyType.getReturnType();
        if (returnType.isDartCoreFunction()) {
          return dynamicType;
        } else if (returnType instanceof InterfaceType) {
          MethodElement callMethod = ((InterfaceType) returnType).lookUpMethod(
              FunctionElement.CALL_METHOD_NAME,
              resolver.getDefiningLibrary());
          if (callMethod != null) {
            return callMethod.getType().getReturnType();
          }
        } else if (returnType instanceof FunctionType) {
          Type innerReturnType = ((FunctionType) returnType).getReturnType();
          if (innerReturnType != null) {
            return innerReturnType;
          }
        }
        if (returnType != null) {
          return returnType;
        }
      }
    } else if (element instanceof ExecutableElement) {
      FunctionType type = ((ExecutableElement) element).getType();
      if (type != null) {
        // TODO(brianwilkerson) Figure out the conditions under which the type is null.
        return type.getReturnType();
      }
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      Type variableType = promoteManager.getStaticType(variable);
      if (variableType instanceof FunctionType) {
View Full Code Here

   *          accessor is a parameter type, then the type of the LHS can be used to get more
   *          specific type information
   * @return the type that should be recorded for a node that resolved to the given accessor
   */
  private Type getTypeOfProperty(PropertyAccessorElement accessor, Type context) {
    FunctionType functionType = accessor.getType();
    if (functionType == null) {
      // TODO(brianwilkerson) Report this internal error. This happens when we are analyzing a
      // reference to a property before we have analyzed the declaration of the property or when
      // the property does not have a defined type.
      return dynamicType;
    }
    if (accessor.isSetter()) {
      Type[] parameterTypes = functionType.getNormalParameterTypes();
      if (parameterTypes != null && parameterTypes.length > 0) {
        return parameterTypes[0];
      }
      PropertyAccessorElement getter = accessor.getVariable().getGetter();
      if (getter != null) {
        functionType = getter.getType();
        if (functionType != null) {
          return functionType.getReturnType();
        }
      }
      return dynamicType;
    }
    Type returnType = functionType.getReturnType();
    if (returnType instanceof TypeParameterType && context instanceof InterfaceType) {
      // if the return type is a TypeParameter, we try to use the context [that the function is being
      // called on] to get a more accurate returnType type
      InterfaceType interfaceTypeContext = ((InterfaceType) context);
//      Type[] argumentTypes = interfaceTypeContext.getTypeArguments();
View Full Code Here

TOP

Related Classes of com.google.dart.engine.type.FunctionType

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.