Package com.google.dart.engine.ast

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


   *
   * @param typeName the type name to analyzer
   * @return {@code true} if the given type name is used as the exception type in a catch clause
   */
  private boolean isTypeNameInCatchClause(TypeName typeName) {
    AstNode parent = typeName.getParent();
    if (parent instanceof CatchClause) {
      CatchClause catchClause = (CatchClause) parent;
      return catchClause.getExceptionType() == typeName;
    }
    return false;
View Full Code Here


   * @param typeName the type name to analyzer
   * @return {@code true} if the given type name is used as the type in an instance creation
   *         expression
   */
  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

   *
   * @param typeName the type name to analyzer
   * @return {@code true} if the given type name is used as the type in an is expression
   */
  private boolean isTypeNameInIsExpression(TypeName typeName) {
    AstNode parent = typeName.getParent();
    if (parent instanceof IsExpression) {
      IsExpression isExpression = (IsExpression) parent;
      return isExpression.getType() == typeName;
    }
    return false;
View Full Code Here

   * Return {@code true} if the given identifier is the return type of a constructor declaration.
   *
   * @return {@code true} if the given identifier is the return type of a constructor declaration.
   */
  private static boolean isConstructorReturnType(SimpleIdentifier identifier) {
    AstNode parent = identifier.getParent();
    if (parent instanceof ConstructorDeclaration) {
      return ((ConstructorDeclaration) parent).getReturnType() == identifier;
    }
    return false;
  }
View Full Code Here

   *
   * @return {@code true} if the given identifier is the return type of a factory constructor
   *         declaration.
   */
  private static boolean isFactoryConstructorReturnType(SimpleIdentifier node) {
    AstNode parent = node.getParent();
    if (parent instanceof ConstructorDeclaration) {
      ConstructorDeclaration constructor = (ConstructorDeclaration) parent;
      return constructor.getReturnType() == node && constructor.getFactoryKeyword() != null;
    }
    return false;
View Full Code Here

   *
   * @param node the node being tested
   * @return {@code true} if the given node is the prefix in an import directive
   */
  private boolean isValidAsPrefix(SimpleIdentifier node) {
    AstNode parent = node.getParent();
    if (parent instanceof ImportDirective) {
      return ((ImportDirective) parent).getPrefix() == node;
    } else if (parent instanceof PrefixedIdentifier) {
      return true;
    } else if (parent instanceof MethodInvocation) {
View Full Code Here

      try {
        ExecutableElement functionElement = node.getElement();
        if (functionElement == null) {
          StringBuilder builder = new StringBuilder();
          builder.append("Missing element for function ");
          AstNode parent = node.getParent();
          while (parent != null) {
            if (parent instanceof Declaration) {
              Element parentElement = ((Declaration) parent).getElement();
              builder.append(parentElement == null ? "<unknown> " : (parentElement.getName() + " "));
            }
            parent = parent.getParent();
          }
          builder.append("in ");
          builder.append(getDefiningLibrary().getSource().getFullName());
          AnalysisEngine.getInstance().getLogger().logInformation(
              builder.toString(),
View Full Code Here

    // Ignore if already resolved - declaration or type.
    if (node.getStaticElement() != null) {
      return null;
    }
    // Ignore if qualified.
    AstNode parent = node.getParent();
    if (parent instanceof PrefixedIdentifier
        && ((PrefixedIdentifier) parent).getIdentifier() == node) {
      return null;
    }
    if (parent instanceof PropertyAccess && ((PropertyAccess) parent).getPropertyName() == node) {
View Full Code Here

   *
   * @param node the root of the AST structure to be resolved
   * @throws AnalysisException if the node could not be resolved
   */
  public void resolve(AstNode node) throws AnalysisException {
    AstNode rootNode = findResolutionRoot(node);
    Scope scope = ScopeBuilder.scopeFor(rootNode, errorListener);
    if (elementModelChanged(rootNode.getParent())) {
      throw new AnalysisException("Cannot resolve node: element model changed");
    }
    resolveTypes(node, scope);
    resolveVariables(node, scope);
    resolveReferences(node, scope);
View Full Code Here

   * @param node the node at which the search is to begin
   * @return the smallest AST node that can be resolved independently of any other nodes
   * @throws AnalysisException if there is no such node
   */
  private AstNode findResolutionRoot(AstNode node) throws AnalysisException {
    AstNode result = node;
    AstNode parent = result.getParent();
    while (parent != null && !canBeResolved(parent)) {
      result = parent;
      parent = result.getParent();
    }
    if (parent == null) {
View Full Code Here

TOP

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

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.