Package com.google.dart.engine.element

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


    boolean isInGetterContext = node.inGetterContext();
    boolean isInSetterContext = node.inSetterContext();

    if (isInGetterContext && isInSetterContext) {
      // lookup setter
      MethodElement setterStaticMethod = lookUpMethod(target, staticType, setterMethodName);
      MethodElement setterPropagatedMethod = lookUpMethod(target, propagatedType, setterMethodName);
      // set setter element
      node.setStaticElement(setterStaticMethod);
      node.setPropagatedElement(setterPropagatedMethod);
      // generate undefined method warning
      checkForUndefinedIndexOperator(
          node,
          target,
          getterMethodName,
          setterStaticMethod,
          setterPropagatedMethod,
          staticType,
          propagatedType);

      // lookup getter method
      MethodElement getterStaticMethod = lookUpMethod(target, staticType, getterMethodName);
      MethodElement getterPropagatedMethod = lookUpMethod(target, propagatedType, getterMethodName);
      // set getter element
      AuxiliaryElements auxiliaryElements = new AuxiliaryElements(
          getterStaticMethod,
          getterPropagatedMethod);
      node.setAuxiliaryElements(auxiliaryElements);
      // generate undefined method warning
      checkForUndefinedIndexOperator(
          node,
          target,
          getterMethodName,
          getterStaticMethod,
          getterPropagatedMethod,
          staticType,
          propagatedType);

    } else if (isInGetterContext) {
      // lookup getter method
      MethodElement staticMethod = lookUpMethod(target, staticType, getterMethodName);
      MethodElement propagatedMethod = lookUpMethod(target, propagatedType, getterMethodName);
      // set getter element
      node.setStaticElement(staticMethod);
      node.setPropagatedElement(propagatedMethod);
      // generate undefined method warning
      checkForUndefinedIndexOperator(
          node,
          target,
          getterMethodName,
          staticMethod,
          propagatedMethod,
          staticType,
          propagatedType);
    } else if (isInSetterContext) {
      // lookup setter method
      MethodElement staticMethod = lookUpMethod(target, staticType, setterMethodName);
      MethodElement propagatedMethod = lookUpMethod(target, propagatedType, setterMethodName);
      // set setter element
      node.setStaticElement(staticMethod);
      node.setPropagatedElement(propagatedMethod);
      // generate undefined method warning
      checkForUndefinedIndexOperator(
View Full Code Here


  public Void visitPostfixExpression(PostfixExpression node) {
    Expression operand = node.getOperand();
    String methodName = getPostfixOperator(node);

    Type staticType = getStaticType(operand);
    MethodElement staticMethod = lookUpMethod(operand, staticType, methodName);
    node.setStaticElement(staticMethod);

    Type propagatedType = getPropagatedType(operand);
    MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, methodName);
    node.setPropagatedElement(propagatedMethod);

    if (shouldReportMissingMember(staticType, staticMethod)) {
      if (doesntHaveProxy(staticType.getElement())) {
        resolver.reportErrorForToken(
View Full Code Here

        || operatorType == TokenType.MINUS_MINUS) {
      Expression operand = node.getOperand();
      String methodName = getPrefixOperator(node);

      Type staticType = getStaticType(operand);
      MethodElement staticMethod = lookUpMethod(operand, staticType, methodName);
      node.setStaticElement(staticMethod);

      Type propagatedType = getPropagatedType(operand);
      MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, methodName);
      node.setPropagatedElement(propagatedMethod);

      if (shouldReportMissingMember(staticType, staticMethod)) {
        if (doesntHaveProxy(staticType.getElement())) {
          resolver.reportErrorForToken(
View Full Code Here

      //
      FunctionType getterType = ((PropertyAccessorElement) element).getType();
      if (getterType != null) {
        Type getterReturnType = getterType.getReturnType();
        if (getterReturnType instanceof InterfaceType) {
          MethodElement callMethod = ((InterfaceType) getterReturnType).lookUpMethod(
              FunctionElement.CALL_METHOD_NAME,
              definingLibrary);
          if (callMethod != null) {
            return resolveArgumentsToFunction(false, argumentList, callMethod);
          }
        } else if (getterReturnType instanceof FunctionType) {
          ParameterElement[] parameters = ((FunctionType) getterReturnType).getParameters();
          return resolveArgumentsToParameters(false, argumentList, parameters);
        }
      }
    } else if (element instanceof ExecutableElement) {
      return resolveArgumentsToFunction(false, argumentList, (ExecutableElement) element);
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      Type type = promoteManager.getStaticType(variable);
      if (type instanceof FunctionType) {
        FunctionType functionType = (FunctionType) type;
        ParameterElement[] parameters = functionType.getParameters();
        return resolveArgumentsToParameters(false, argumentList, parameters);
      } else if (type instanceof InterfaceType) {
        // "call" invocation
        MethodElement callMethod = ((InterfaceType) type).lookUpMethod(
            FunctionElement.CALL_METHOD_NAME,
            definingLibrary);
        if (callMethod != null) {
          ParameterElement[] parameters = callMethod.getParameters();
          return resolveArgumentsToParameters(false, argumentList, parameters);
        }
      }
    }
    return null;
View Full Code Here

      // executable type.
      // example code: NonErrorResolverTest.test_invocationOfNonFunction_proxyOnFunctionClass()
      if (classElement.isProxy() && type.isSubtypeOf(resolver.getTypeProvider().getFunctionType())) {
        return true;
      }
      MethodElement methodElement = classElement.lookUpMethod(
          FunctionElement.CALL_METHOD_NAME,
          definingLibrary);
      return methodElement != null;
    }
    return false;
View Full Code Here

   */
  private MethodElement lookUpMethod(Expression target, Type type, String methodName) {
    type = resolveTypeParameter(type);
    if (type instanceof InterfaceType) {
      InterfaceType interfaceType = (InterfaceType) type;
      MethodElement method;
      if (target instanceof SuperExpression) {
        method = interfaceType.lookUpMethodInSuperclass(methodName, definingLibrary);
      } else {
        method = interfaceType.lookUpMethod(methodName, definingLibrary);
      }
View Full Code Here

    if (visitedInterfaces.contains(targetClass)) {
      return null;
    }
    visitedInterfaces.add(targetClass);
    if (includeTargetType) {
      MethodElement method = targetType.getMethod(methodName);
      if (method != null && method.isAccessibleIn(definingLibrary)) {
        return method;
      }
    }
    for (InterfaceType interfaceType : targetType.getInterfaces()) {
      MethodElement method = lookUpMethodInInterfaces(
          interfaceType,
          true,
          methodName,
          visitedInterfaces);
      if (method != null) {
        return method;
      }
    }
    for (InterfaceType mixinType : targetType.getMixins()) {
      MethodElement method = lookUpMethodInInterfaces(
          mixinType,
          true,
          methodName,
          visitedInterfaces);
      if (method != null) {
View Full Code Here

   * @return all methods named {@code methodName} defined on the union type {@code type}.
   */
  private Set<ExecutableElement> lookupMethods(Expression target, UnionType type, String methodName) {
    Set<ExecutableElement> methods = new HashSet<ExecutableElement>();
    for (Type t : type.getElements()) {
      MethodElement m = lookUpMethod(target, t, methodName);
      if (m != null) {
        methods.add(m);
      }
    }
    return methods;
View Full Code Here

    } else {
      ExecutableElement staticMethodElement = node.getStaticElement();
      Type staticType = computeStaticReturnType(staticMethodElement);
      recordStaticType(node, staticType);

      MethodElement propagatedMethodElement = node.getPropagatedElement();
      if (propagatedMethodElement != staticMethodElement) {
        Type propagatedType = computeStaticReturnType(propagatedMethodElement);
        if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType)) {
          recordPropagatedType(node, propagatedType);
        }
View Full Code Here

    ExecutableElement staticMethodElement = node.getStaticElement();
    Type staticType = computeStaticReturnType(staticMethodElement);
    staticType = refineBinaryExpressionType(node, staticType);
    recordStaticType(node, staticType);

    MethodElement propagatedMethodElement = node.getPropagatedElement();
    if (propagatedMethodElement != staticMethodElement) {
      Type propagatedType = computeStaticReturnType(propagatedMethodElement);
      if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType)) {
        recordPropagatedType(node, propagatedType);
      }
View Full Code Here

TOP

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

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.