Package com.google.dart.engine.ast

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


  @Override
  public Void visitInstanceCreationExpression(InstanceCreationExpression node) {
    isInConstInstanceCreation = node.isConst();
    try {
      ConstructorName constructorName = node.getConstructorName();
      TypeName typeName = constructorName.getType();
      Type type = typeName.getType();
      if (type instanceof InterfaceType) {
        InterfaceType interfaceType = (InterfaceType) type;
        checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
        checkForConstOrNewWithEnum(node, typeName, interfaceType);
View Full Code Here


   */
  private boolean checkForAllRedirectConstructorErrorCodes(ConstructorDeclaration node) {
    //
    // Prepare redirected constructor node
    //
    ConstructorName redirectedConstructor = node.getRedirectedConstructor();
    if (redirectedConstructor == null) {
      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(
View Full Code Here

   * @see CompileTimeErrorCode#RECURSIVE_FACTORY_REDIRECT
   */
  private boolean checkForRecursiveFactoryRedirect(ConstructorDeclaration node,
      ConstructorElement constructorElement) {
    // prepare redirected constructor
    ConstructorName redirectedConstructorNode = node.getRedirectedConstructor();
    if (redirectedConstructorNode == null) {
      return false;
    }
    // OK if no cycle
    if (!hasRedirectingFactoryConstructorCycle(constructorElement)) {
View Full Code Here

  private boolean checkForRedirectingConstructorErrorCodes(ConstructorDeclaration node) {
    boolean errorReported = false;
    //
    // Check for default values in the parameters
    //
    ConstructorName redirectedConstructor = node.getRedirectedConstructor();
    if (redirectedConstructor != null) {
      for (FormalParameter parameter : node.getParameters().getParameters()) {
        if (parameter instanceof DefaultFormalParameter
            && ((DefaultFormalParameter) parameter).getDefaultValue() != null) {
          errorReporter.reportErrorForNode(
View Full Code Here

   * @see CompileTimeErrorCode#REDIRECT_TO_NON_CONST_CONSTRUCTOR
   */
  private boolean checkForRedirectToNonConstConstructor(ConstructorDeclaration node,
      ConstructorElement constructorElement) {
    // prepare redirected constructor
    ConstructorName redirectedConstructorNode = node.getRedirectedConstructor();
    if (redirectedConstructorNode == null) {
      return false;
    }
    // prepare element
    if (constructorElement == null) {
View Full Code Here

      // constructor name. If so, fix the AST structure and then proceed.
      //
      AstNode parent = node.getParent();
      if (typeName instanceof PrefixedIdentifier && parent instanceof ConstructorName
          && argumentList == null) {
        ConstructorName name = (ConstructorName) parent;
        if (name.getName() == null) {
          PrefixedIdentifier prefixedIdentifier = (PrefixedIdentifier) typeName;
          SimpleIdentifier prefix = prefixedIdentifier.getPrefix();
          element = getNameScope().lookup(prefix, getDefiningLibrary());
          if (element instanceof PrefixElement) {
            if (parent.getParent() instanceof InstanceCreationExpression
                && ((InstanceCreationExpression) parent.getParent()).isConst()) {
              // If, if this is a const expression, then generate a
              // CompileTimeErrorCode.CONST_WITH_NON_TYPE error.
              reportErrorForNode(
                  CompileTimeErrorCode.CONST_WITH_NON_TYPE,
                  prefixedIdentifier.getIdentifier(),
                  prefixedIdentifier.getIdentifier().getName());
            } else {
              // Else, if this expression is a new expression, report a NEW_WITH_NON_TYPE warning.
              reportErrorForNode(
                  StaticWarningCode.NEW_WITH_NON_TYPE,
                  prefixedIdentifier.getIdentifier(),
                  prefixedIdentifier.getIdentifier().getName());
            }
            setElement(prefix, element);
            return null;
          } else if (element != null) {
            //
            // Rewrite the constructor name. The parser, when it sees a constructor named "a.b",
            // cannot tell whether "a" is a prefix and "b" is a class name, or whether "a" is a
            // class name and "b" is a constructor name. It arbitrarily chooses the former, but
            // in this case was wrong.
            //
            name.setName(prefixedIdentifier.getIdentifier());
            name.setPeriod(prefixedIdentifier.getPeriod());
            node.setName(prefix);
            typeName = prefix;
          }
        }
      }
View Full Code Here

   *         redirected constructor, or {@code null} otherwise
   */
  private RedirectingConstructorKind getRedirectingConstructorKind(TypeName typeName) {
    AstNode parent = typeName.getParent();
    if (parent instanceof ConstructorName) {
      ConstructorName constructorName = (ConstructorName) parent;
      parent = constructorName.getParent();
      if (parent instanceof ConstructorDeclaration) {
        ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) parent;
        if (constructorDeclaration.getRedirectedConstructor() == constructorName) {
          if (constructorDeclaration.getConstKeyword() != null) {
            return RedirectingConstructorKind.CONST;
View Full Code Here

   */
  private boolean isTypeNameInInstanceCreationExpression(TypeName typeName) {
    AstNode parent = typeName.getParent();
    if (parent instanceof ConstructorName
        && parent.getParent() instanceof InstanceCreationExpression) {
      ConstructorName constructorName = (ConstructorName) parent;
      return constructorName != null && constructorName.getType() == typeName;
    }
    return false;
  }
View Full Code Here

  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    super.visitConstructorDeclaration(node);
    ConstructorElement element = node.getElement();
    if (element instanceof ConstructorElementImpl) {
      ConstructorElementImpl constructorElement = (ConstructorElementImpl) element;
      ConstructorName redirectedNode = node.getRedirectedConstructor();
      if (redirectedNode != null) {
        // set redirected factory constructor
        ConstructorElement redirectedElement = redirectedNode.getStaticElement();
        constructorElement.setRedirectedConstructor(redirectedElement);
      } else {
        // set redirected generative constructor
        for (ConstructorInitializer initializer : node.getInitializers()) {
          if (initializer instanceof RedirectingConstructorInvocation) {
View Full Code Here

TOP

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

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.