Package com.google.dart.engine.element

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


      }
    }
    // Evaluate explicit or implicit call to super().
    InterfaceType superclass = definingClass.getSuperclass();
    if (superclass != null && !superclass.isObject()) {
      ConstructorElement superConstructor = superclass.lookUpConstructor(
          superName,
          constructor.getLibrary());
      if (superConstructor != null) {
        if (superArguments == null) {
          superArguments = new NodeList<Expression>(null);
View Full Code Here


        // dart:core.Symbol, and let [evaluateInstanceCreationExpression] handle it specially.
        break;
      }

      constructorsVisited.add(constructor);
      ConstructorElement redirectedConstructor = constructor.getRedirectedConstructor();
      if (redirectedConstructor == null) {
        // This can happen if constructor is an external factory constructor.
        break;
      }
      if (!redirectedConstructor.isConst()) {
        // Delegating to a non-const constructor--this is not allowed (and
        // is checked elsewhere--see [ErrorVerifier.checkForRedirectToNonConstConstructor()]).
        break;
      }
      if (constructorsVisited.contains(redirectedConstructor)) {
View Full Code Here

  }

  @Override
  public Void visitSuperConstructorInvocation(SuperConstructorInvocation node) {
    super.visitSuperConstructorInvocation(node);
    ConstructorElement constructor = node.getStaticElement();
    if (constructor != null && constructor.isConst()) {
      ConstructorDeclaration constructorDeclaration = constructorDeclarationMap.get(constructor);
      // The declaration will be null when the constructor is not defined in the compilation
      // units that were used to produce the constructorDeclarationMap.  In such cases, the
      // constructor should already have its initializer AST's stored in it, but we don't bother
      // to check because there's nothing we can do about it at this point.
View Full Code Here

   * Checks if given {@link Annotation} is an annotation with required name.
   */
  private boolean isAnnotation(Annotation annotation, String name) {
    Element element = annotation.getElement();
    if (element instanceof ConstructorElement) {
      ConstructorElement constructorElement = (ConstructorElement) element;
      return constructorElement.getReturnType().getDisplayName().equals(name);
    }
    return false;
  }
View Full Code Here

  public boolean isDeprecated() {
    if (element != null) {
      LibraryElement library = element.getLibrary();
      if (library != null && library.isDartCore()) {
        if (element instanceof ConstructorElement) {
          ConstructorElement constructorElement = (ConstructorElement) element;
          if (constructorElement.getEnclosingElement().getName().equals(DEPRECATED_CLASS_NAME)) {
            return true;
          }
        } else if (element instanceof PropertyAccessorElement
            && element.getName().equals(DEPRECATED_VARIABLE_NAME)) {
          return true;
View Full Code Here

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    super.visitConstructorDeclaration(node);
    if (node.getConstKeyword() != null) {
      ConstructorElement element = node.getElement();
      if (element != null) {
        constructorMap.put(element, node);
      }
    }
    return null;
View Full Code Here

  public Void visitAnnotation(Annotation node) {
    super.visitAnnotation(node);
    // check annotation creation
    Element element = node.getElement();
    if (element instanceof ConstructorElement) {
      ConstructorElement constructorElement = (ConstructorElement) element;
      // should 'const' constructor
      if (!constructorElement.isConst()) {
        errorReporter.reportErrorForNode(
            CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR,
            node);
        return null;
      }
View Full Code Here

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    ExecutableElement outerFunction = enclosingFunction;
    try {
      ConstructorElement constructorElement = node.getElement();
      enclosingFunction = constructorElement;
      isEnclosingConstructorConst = node.getConstKeyword() != null;
      isInFactory = node.getFactoryKeyword() != null;
      checkForInvalidModifierOnBody(
          node.getBody(),
View Full Code Here

      return false;
    }
    //
    // Prepare redirected constructor type
    //
    ConstructorElement redirectedElement = redirectedConstructor.getStaticElement();
    if (redirectedElement == null) {
      //
      // If the element is null, we check for the REDIRECT_TO_MISSING_CONSTRUCTOR case
      //
      TypeName constructorTypeName = redirectedConstructor.getType();
      Type redirectedType = constructorTypeName.getType();
      if (redirectedType != null && redirectedType.getElement() != null
          && !redirectedType.isDynamic()) {
        //
        // Prepare the constructor name
        //
        String constructorStrName = constructorTypeName.getName().getName();
        if (redirectedConstructor.getName() != null) {
          constructorStrName += '.' + redirectedConstructor.getName().getName();
        }
        ErrorCode errorCode = node.getConstKeyword() != null
            ? CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR
            : StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR;
        errorReporter.reportErrorForNode(
            errorCode,
            redirectedConstructor,
            constructorStrName,
            redirectedType.getDisplayName());
        return true;
      }
      return false;
    }
    FunctionType redirectedType = redirectedElement.getType();
    Type redirectedReturnType = redirectedType.getReturnType();
    //
    // Report specific problem when return type is incompatible
    //
    FunctionType constructorType = node.getElement().getType();
View Full Code Here

    }
    // try to find and check super constructor invocation
    for (ConstructorInitializer initializer : node.getInitializers()) {
      if (initializer instanceof SuperConstructorInvocation) {
        SuperConstructorInvocation superInvocation = (SuperConstructorInvocation) initializer;
        ConstructorElement element = superInvocation.getStaticElement();
        if (element == null || element.isConst()) {
          return false;
        }
        errorReporter.reportErrorForNode(
            CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
            superInvocation,
            element.getEnclosingElement().getDisplayName());
        return true;
      }
    }
    // no explicit super constructor invocation, check default constructor
    InterfaceType supertype = enclosingClass.getSupertype();
    if (supertype == null) {
      return false;
    }
    if (supertype.isObject()) {
      return false;
    }
    ConstructorElement unnamedConstructor = supertype.getElement().getUnnamedConstructor();
    if (unnamedConstructor == null) {
      return false;
    }
    if (unnamedConstructor.isConst()) {
      return false;
    }
    // default constructor is not 'const', report problem
    errorReporter.reportErrorForNode(
        CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
View Full Code Here

TOP

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

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.