Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.MethodDeclaration


    boolean foundError = false;
    HashMap<String, ClassMember> memberHashMap = new HashMap<String, ClassMember>(
        classMembers.size());
    for (ClassMember classMember : classMembers) {
      if (classMember instanceof MethodDeclaration) {
        MethodDeclaration method = (MethodDeclaration) classMember;
        if (method.isStatic()) {
          continue;
        }
        // prepare name
        SimpleIdentifier name = method.getName();
        if (name == null) {
          continue;
        }

        boolean addThisMemberToTheMap = true;

        boolean isGetter = method.isGetter();
        boolean isSetter = method.isSetter();
        boolean isOperator = method.isOperator();
        boolean isMethod = !isGetter && !isSetter && !isOperator;

        // Do lookups in the enclosing class (and the inherited member) if the member is a method or
        // a setter for StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER warning.
        if (isMethod) {
          String setterName = name.getName() + "=";
          Element enclosingElementOfSetter = null;
          ClassMember conflictingSetter = memberHashMap.get(setterName);
          if (conflictingSetter != null) {
            enclosingElementOfSetter = conflictingSetter.getElement().getEnclosingElement();
          } else {
            ExecutableElement elementFromInheritance = inheritanceManager.lookupInheritance(
                enclosingClass,
                setterName);
            if (elementFromInheritance != null) {
              enclosingElementOfSetter = elementFromInheritance.getEnclosingElement();
            }
          }
          if (enclosingElementOfSetter != null) {
            // report problem
            errorReporter.reportErrorForNode(
                StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER,
                name,
                enclosingClass.getDisplayName(),
                name.getName(),
                enclosingElementOfSetter.getDisplayName());
            foundError |= true;
            addThisMemberToTheMap = false;
          }
        } else if (isSetter) {
          String methodName = name.getName();
          ClassMember conflictingMethod = memberHashMap.get(methodName);
          if (conflictingMethod != null && conflictingMethod instanceof MethodDeclaration
              && !((MethodDeclaration) conflictingMethod).isGetter()) {
            // report problem
            errorReporter.reportErrorForNode(
                StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2,
                name,
                enclosingClass.getDisplayName(),
                name.getName());
            foundError |= true;
            addThisMemberToTheMap = false;
          }
        }

        // Finally, add this member into the HashMap.
        if (addThisMemberToTheMap) {
          if (method.isSetter()) {
            memberHashMap.put(name.getName() + "=", method);
          } else {
            memberHashMap.put(name.getName(), method);
          }
        }
View Full Code Here


      }
      if (n instanceof ConstructorInitializer) {
        return false;
      }
      if (n instanceof MethodDeclaration) {
        MethodDeclaration method = (MethodDeclaration) n;
        return !method.isStatic();
      }
    }
    return false;
  }
View Full Code Here

      }
      if (n instanceof ConstructorFieldInitializer) {
        return false;
      }
      if (n instanceof MethodDeclaration) {
        MethodDeclaration method = (MethodDeclaration) n;
        return !method.isStatic();
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.MethodDeclaration

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.