Package com.google.dart.engine.ast

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


   * Continues resolution of the given {@link Annotation}.
   *
   * @param annotation the {@link Annotation} to resolve
   */
  private void resolveAnnotationElement(Annotation annotation) {
    SimpleIdentifier nameNode1;
    SimpleIdentifier nameNode2;
    {
      Identifier annName = annotation.getName();
      if (annName instanceof PrefixedIdentifier) {
        PrefixedIdentifier prefixed = (PrefixedIdentifier) annName;
        nameNode1 = prefixed.getPrefix();
        nameNode2 = prefixed.getIdentifier();
      } else {
        nameNode1 = (SimpleIdentifier) annName;
        nameNode2 = null;
      }
    }
    SimpleIdentifier nameNode3 = annotation.getConstructorName();
    ConstructorElement constructor = null;
    //
    // CONST or Class(args)
    //
    if (nameNode1 != null && nameNode2 == null && nameNode3 == null) {
      Element element1 = nameNode1.getStaticElement();
      // CONST
      if (element1 instanceof PropertyAccessorElement) {
        resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) element1);
        return;
      }
      // Class(args)
      if (element1 instanceof ClassElement) {
        ClassElement classElement = (ClassElement) element1;
        constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(null, definingLibrary);
      }
    }
    //
    // prefix.CONST or prefix.Class() or Class.CONST or Class.constructor(args)
    //
    if (nameNode1 != null && nameNode2 != null && nameNode3 == null) {
      Element element1 = nameNode1.getStaticElement();
      Element element2 = nameNode2.getStaticElement();
      // Class.CONST - not resolved yet
      if (element1 instanceof ClassElement) {
        ClassElement classElement = (ClassElement) element1;
        element2 = classElement.lookUpGetter(nameNode2.getName(), definingLibrary);
      }
      // prefix.CONST or Class.CONST
      if (element2 instanceof PropertyAccessorElement) {
        nameNode2.setStaticElement(element2);
        annotation.setElement(element2);
        resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) element2);
        return;
      }
      // prefix.Class()
      if (element2 instanceof ClassElement) {
        ClassElement classElement = (ClassElement) element2;
        constructor = classElement.getUnnamedConstructor();
      }
      // Class.constructor(args)
      if (element1 instanceof ClassElement) {
        ClassElement classElement = (ClassElement) element1;
        constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(
            nameNode2.getName(),
            definingLibrary);
        nameNode2.setStaticElement(constructor);
      }
    }
    //
    // prefix.Class.CONST or prefix.Class.constructor(args)
    //
    if (nameNode1 != null && nameNode2 != null && nameNode3 != null) {
      Element element2 = nameNode2.getStaticElement();
      // element2 should be ClassElement
      if (element2 instanceof ClassElement) {
        ClassElement classElement = (ClassElement) element2;
        String name3 = nameNode3.getName();
        // prefix.Class.CONST
        PropertyAccessorElement getter = classElement.lookUpGetter(name3, definingLibrary);
        if (getter != null) {
          nameNode3.setStaticElement(getter);
          annotation.setElement(element2);
          resolveAnnotationElementGetter(annotation, getter);
          return;
        }
        // prefix.Class.constructor(args)
        constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(name3, definingLibrary);
        nameNode3.setStaticElement(constructor);
      }
    }
    // we need constructor
    if (constructor == null) {
      resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, annotation);
View Full Code Here


    HashSet<String> usedNames = new HashSet<String>();
    boolean noBlankArguments = true;
    for (int i = 0; i < argumentCount; i++) {
      Expression argument = arguments.get(i);
      if (argument instanceof NamedExpression) {
        SimpleIdentifier nameNode = ((NamedExpression) argument).getName().getLabel();
        String name = nameNode.getName();
        ParameterElement element = namedParameters.get(name);
        if (element == null) {
          ErrorCode errorCode = reportError ? CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER
              : StaticWarningCode.UNDEFINED_NAMED_PARAMETER;
          resolver.reportErrorForNode(errorCode, nameNode, name);
        } else {
          resolvedParameters[i] = element;
          nameNode.setStaticElement(element);
        }
        if (!usedNames.add(name)) {
          resolver.reportErrorForNode(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, nameNode, name);
        }
      } else {
View Full Code Here

    return unmatchedElements.isEmpty();
  }

  @Override
  public Void visitCatchClause(CatchClause node) {
    SimpleIdentifier exceptionParameter = node.getExceptionParameter();
    if (exceptionParameter != null) {
      LocalVariableElement[] localVariables = enclosingExecutable.getLocalVariables();
      LocalVariableElement exceptionElement = findIdentifier(localVariables, exceptionParameter);
      processElement(exceptionElement);

      SimpleIdentifier stackTraceParameter = node.getStackTraceParameter();
      if (stackTraceParameter != null) {
        LocalVariableElement stackTraceElement = findIdentifier(localVariables, stackTraceParameter);
        processElement(stackTraceElement);
      }
    }
View Full Code Here

  @Override
  public Void visitClassDeclaration(ClassDeclaration node) {
    ClassElement outerClass = enclosingClass;
    try {
      SimpleIdentifier className = node.getName();
      enclosingClass = findIdentifier(enclosingUnit.getTypes(), className);
      processElement(enclosingClass);
      if (!hasConstructor(node)) {
        ConstructorElement constructor = enclosingClass.getUnnamedConstructor();
        if (constructor.isSynthetic()) {
View Full Code Here

  @Override
  public Void visitClassTypeAlias(ClassTypeAlias node) {
    ClassElement outerClass = enclosingClass;
    try {
      SimpleIdentifier className = node.getName();
      enclosingClass = findIdentifier(enclosingUnit.getTypes(), className);
      processElement(enclosingClass);
      return super.visitClassTypeAlias(node);
    } finally {
      enclosingClass = outerClass;
View Full Code Here

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

    }
  }

  @Override
  public Void visitDeclaredIdentifier(DeclaredIdentifier node) {
    SimpleIdentifier variableName = node.getIdentifier();
    LocalVariableElement element = findIdentifier(
        enclosingExecutable.getLocalVariables(),
        variableName);
    processElement(element);
    return super.visitDeclaredIdentifier(node);
View Full Code Here

    return super.visitDeclaredIdentifier(node);
  }

  @Override
  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 {
View Full Code Here

  }

  @Override
  public Void visitFieldFormalParameter(FieldFormalParameter node) {
    if (!(node.getParent() instanceof DefaultFormalParameter)) {
      SimpleIdentifier parameterName = node.getIdentifier();
      ParameterElement element = getElementForParameter(node, parameterName);
      ParameterElement outerParameter = enclosingParameter;
      try {
        enclosingParameter = element;
        processElement(enclosingParameter);
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) {
          enclosingExecutable = findIdentifier(enclosingExecutable.getFunctions(), functionName);
        } else {
View Full Code Here

TOP

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

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.