Package com.google.dart.engine.element

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


    Element element = node.getStaticElement();
    if (!(element instanceof MethodElement || element instanceof PropertyAccessorElement)) {
      return false;
    }
    // static element
    ExecutableElement executableElement = (ExecutableElement) element;
    if (executableElement.isStatic()) {
      return false;
    }
    // not a class member
    Element enclosingElement = element.getEnclosingElement();
    if (!(enclosingElement instanceof ClassElement)) {
View Full Code Here


    // prepare member Element
    Element element = name.getStaticElement();
    if (!(element instanceof ExecutableElement)) {
      return false;
    }
    ExecutableElement executableElement = (ExecutableElement) element;
    // OK, top-level element
    if (!(executableElement.getEnclosingElement() instanceof ClassElement)) {
      return false;
    }
    // OK, instance member
    if (!executableElement.isStatic()) {
      return false;
    }
    // report problem
    errorReporter.reportErrorForNode(
        StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER,
View Full Code Here

   */
  // TODO (jwren) In future nit CL, rename this method (and tests) to be consistent with name of error enum
  // TODO (jwren) Revisit error code messages, to add more clarity, we may need the pair split into four codes
  private boolean checkForMismatchedAccessorTypes(Declaration accessorDeclaration,
      String accessorTextName) {
    ExecutableElement accessorElement = (ExecutableElement) accessorDeclaration.getElement();
    if (!(accessorElement instanceof PropertyAccessorElement)) {
      return false;
    }
    PropertyAccessorElement propertyAccessorElement = (PropertyAccessorElement) accessorElement;
    PropertyAccessorElement counterpartAccessor = null;
    ClassElement enclosingClassForCounterpart = null;
    if (propertyAccessorElement.isGetter()) {
      counterpartAccessor = propertyAccessorElement.getCorrespondingSetter();
    } else {
      counterpartAccessor = propertyAccessorElement.getCorrespondingGetter();
      // If the setter and getter are in the same enclosing element, return, this prevents having
      // MISMATCHED_GETTER_AND_SETTER_TYPES reported twice.
      if (counterpartAccessor != null
          && counterpartAccessor.getEnclosingElement() == propertyAccessorElement.getEnclosingElement()) {
        return false;
      }
    }
    if (counterpartAccessor == null) {
      // If the accessor is declared in a class, check the superclasses.
      if (enclosingClass != null) {
        // Figure out the correct identifier to lookup in the inheritance graph, if 'x', then 'x=',
        // or if 'x=', then 'x'.
        String lookupIdentifier = propertyAccessorElement.getName();
        if (StringUtilities.endsWithChar(lookupIdentifier, '=')) {
          lookupIdentifier = lookupIdentifier.substring(0, lookupIdentifier.length() - 1);
        } else {
          lookupIdentifier += "=";
        }
        // lookup with the identifier.
        ExecutableElement elementFromInheritance = inheritanceManager.lookupInheritance(
            enclosingClass,
            lookupIdentifier);
        // Verify that we found something, and that it is an accessor
        if (elementFromInheritance != null
            && elementFromInheritance instanceof PropertyAccessorElement) {
          enclosingClassForCounterpart = (ClassElement) elementFromInheritance.getEnclosingElement();
          counterpartAccessor = (PropertyAccessorElement) elementFromInheritance;
        }
      }
      if (counterpartAccessor == null) {
        return false;
View Full Code Here

    //
    MemberMap membersInheritedFromInterfaces = inheritanceManager.getMapOfMembersInheritedFromInterfaces(enclosingClass);
    MemberMap membersInheritedFromSuperclasses = inheritanceManager.getMapOfMembersInheritedFromClasses(enclosingClass);
    for (int i = 0; i < membersInheritedFromInterfaces.getSize(); i++) {
      String memberName = membersInheritedFromInterfaces.getKey(i);
      ExecutableElement executableElt = membersInheritedFromInterfaces.getValue(i);
      if (memberName == null) {
        break;
      }

      // If the element is not synthetic and can be determined to be defined in Object, skip it.
      if (executableElt.getEnclosingElement() != null
          && ((ClassElement) executableElt.getEnclosingElement()).getType().isObject()) {
        continue;
      }

      // Check to see if some element is in local enclosing class that matches the name of the
      // required member.
      if (isMemberInClassOrMixin(executableElt, enclosingClass)) {
        // We do not have to verify that this implementation of the found method matches the
        // required function type: the set of StaticWarningCode.INVALID_METHOD_OVERRIDE_* warnings
        // break out the different specific situations.
        continue;
      }

      // First check to see if this element was declared in the superclass chain, in which case
      // there is already a concrete implementation.
      ExecutableElement elt = membersInheritedFromSuperclasses.get(memberName);

      // Check to see if an element was found in the superclass chain with the correct name.
      if (elt != null) {

        // Reference the types, if any are null then continue.
        InterfaceType enclosingType = enclosingClass.getType();
        FunctionType concreteType = elt.getType();
        FunctionType requiredMemberType = executableElt.getType();
        if (enclosingType == null || concreteType == null || requiredMemberType == null) {
          continue;
        }

View Full Code Here

    // prepare member Element
    Element element = name.getStaticElement();
    if (!(element instanceof ExecutableElement)) {
      return false;
    }
    ExecutableElement memberElement = (ExecutableElement) element;
    // OK, static
    if (memberElement.isStatic()) {
      return false;
    }
    // report problem
    errorReporter.reportErrorForNode(
        StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER,
View Full Code Here

    }
    // If there is a noSuchMethod method, then don't report the warning, see dartbug.com/16078
    if (classElement.getMethod(FunctionElement.NO_SUCH_METHOD_METHOD_NAME) != null) {
      return false;
    }
    ExecutableElement callMethod = inheritanceManager.lookupMember(classElement, "call");
    if (callMethod == null || !(callMethod instanceof MethodElement)
        || ((MethodElement) callMethod).isAbstract()) {
      errorReporter.reportErrorForNode(StaticWarningCode.FUNCTION_WITHOUT_CALL, node.getName());
      return true;
    }
View Full Code Here

   * @param executableElt the executable to search for in the passed class element
   * @param classElt the class method to search through the members of
   * @return {@code true} iff the passed member is found in the passed class element
   */
  private boolean isMemberInClassOrMixin(ExecutableElement executableElt, ClassElement classElt) {
    ExecutableElement foundElt = null;
    String executableName = executableElt.getName();
    if (executableElt instanceof MethodElement) {
      foundElt = classElt.getMethod(executableName);
      if (foundElt != null && !((MethodElement) foundElt).isAbstract()) {
        return true;
View Full Code Here

    return super.visitCompilationUnit(node);
  }

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    ExecutableElement outerExecutable = enclosingExecutable;
    try {
      SimpleIdentifier constructorName = node.getName();
      if (constructorName == null) {
        enclosingExecutable = enclosingClass.getUnnamedConstructor();
      } else {
View Full Code Here

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

    }
  }

  @Override
  public Void visitFunctionDeclaration(FunctionDeclaration node) {
    ExecutableElement outerExecutable = enclosingExecutable;
    try {
      SimpleIdentifier functionName = node.getName();
      Token property = node.getPropertyKeyword();
      if (property == null) {
        if (enclosingExecutable != null) {
View Full Code Here

TOP

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

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.