Package com.google.dart.engine.element

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


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


    return getBaseElement().isFactory();
  }

  @Override
  public String toString() {
    ConstructorElement baseElement = getBaseElement();
    ParameterElement[] parameters = getParameters();
    FunctionType type = getType();
    StringBuilder builder = new StringBuilder();
    builder.append(baseElement.getEnclosingElement().getDisplayName());
    String name = getDisplayName();
    if (name != null && !name.isEmpty()) {
      builder.append(".");
      builder.append(name);
    }
View Full Code Here

    if (element != null && element.isDeprecated()) {
      String displayName = element.getDisplayName();
      if (element instanceof ConstructorElement) {
        // TODO(jwren) We should modify ConstructorElement.getDisplayName(), or have the logic
        // centralized elsewhere, instead of doing this logic here.
        ConstructorElement constructorElement = (ConstructorElement) element;
        displayName = constructorElement.getEnclosingElement().getDisplayName();
        if (!constructorElement.getDisplayName().isEmpty()) {
          displayName = displayName + '.' + constructorElement.getDisplayName();
        }
      }
      errorReporter.reportErrorForNode(HintCode.DEPRECATED_MEMBER_USE, node, displayName);
      return true;
    }
View Full Code Here

    return null;
  }

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    ConstructorElement element = node.getElement();
    // define
    {
      Location location;
      if (node.getName() != null) {
        int start = node.getPeriod().getOffset();
View Full Code Here

    }
  }

  @Override
  public Void visitConstructorName(ConstructorName node) {
    ConstructorElement element = node.getStaticElement();
    // in 'class B = A;' actually A constructors are invoked
    if (element != null && element.isSynthetic() && element.getRedirectedConstructor() != null) {
      element = element.getRedirectedConstructor();
    }
    // prepare location
    Location location;
    if (node.getName() != null) {
      int start = node.getPeriod().getOffset();
View Full Code Here

    return super.visitSimpleIdentifier(node);
  }

  @Override
  public Void visitSuperConstructorInvocation(SuperConstructorInvocation node) {
    ConstructorElement element = node.getStaticElement();
    Location location;
    if (node.getConstructorName() != null) {
      int start = node.getPeriod().getOffset();
      int end = node.getConstructorName().getEnd();
      location = createLocationFromOffset(start, end - start);
View Full Code Here

      if (element == null) {
        throw new AnalysisException("Cannot build a scope for an unresolved class type alias");
      }
      scope = new ClassScope(new TypeParameterScope(scope, element), element);
    } else if (node instanceof ConstructorDeclaration) {
      ConstructorElement element = ((ConstructorDeclaration) node).getElement();
      if (element == null) {
        throw new AnalysisException("Cannot build a scope for an unresolved constructor");
      }
      FunctionScope functionScope = new FunctionScope(scope, element);
      functionScope.defineParameters();
View Full Code Here

  }

  @Override
  public ConstructorElement lookUpConstructor(String constructorName, LibraryElement library) {
    // prepare base ConstructorElement
    ConstructorElement constructorElement;
    if (constructorName == null) {
      constructorElement = getElement().getUnnamedConstructor();
    } else {
      constructorElement = getElement().getNamedConstructor(constructorName);
    }
    // not found or not accessible
    if (constructorElement == null || !constructorElement.isAccessibleIn(library)) {
      return null;
    }
    // return member
    return ConstructorMember.from(constructorElement, this);
  }
View Full Code Here

      if (!superInvocationFound) {
        // No explicit superconstructor invocation found, so we need to manually insert
        // a reference to the implicit superconstructor.
        InterfaceType superclass = ((InterfaceType) entry.getKey().getReturnType()).getSuperclass();
        if (superclass != null && !superclass.isObject()) {
          ConstructorElement unnamedConstructor = superclass.getElement().getUnnamedConstructor();
          ConstructorDeclaration superConstructorDeclaration = findConstructorDeclaration(unnamedConstructor);
          if (superConstructorDeclaration != null) {
            referenceGraph.addEdge(declaration, superConstructorDeclaration);
          }
        }
      }
      for (FormalParameter parameter : declaration.getParameters().getParameters()) {
        referenceGraph.addNode(parameter);
        referenceGraph.addEdge(declaration, parameter);
        if (parameter instanceof DefaultFormalParameter) {
          Expression defaultValue = ((DefaultFormalParameter) parameter).getDefaultValue();
          if (defaultValue != null) {
            ReferenceFinder parameterReferenceFinder = new ReferenceFinder(
                parameter,
                referenceGraph,
                variableDeclarationMap,
                constructorDeclarationMap);
            defaultValue.accept(parameterReferenceFinder);
          }
        }
      }
    }
    for (InstanceCreationExpression expression : constructorInvocations) {
      referenceGraph.addNode(expression);
      ConstructorElement constructor = expression.getStaticElement();
      if (constructor == null) {
        break;
      }
      constructor = followConstantRedirectionChain(constructor);
      ConstructorDeclaration declaration = findConstructorDeclaration(constructor);
View Full Code Here

      Element element = declaration.getElement();
      EvaluationResultImpl result = declaration.getInitializer().accept(createConstantVisitor());
      ((VariableElementImpl) element).setEvaluationResult(result);
    } else if (constNode instanceof InstanceCreationExpression) {
      InstanceCreationExpression expression = (InstanceCreationExpression) constNode;
      ConstructorElement constructor = expression.getStaticElement();
      if (constructor == null) {
        // Couldn't resolve the constructor so we can't compute a value.  No problem--the error
        // has already been reported.
        return;
      }
      ConstantVisitor constantVisitor = createConstantVisitor();
      EvaluationResultImpl result = evaluateConstructorCall(
          constNode,
          expression.getArgumentList().getArguments(),
          constructor,
          constantVisitor);
      expression.setEvaluationResult(result);
    } else if (constNode instanceof ConstructorDeclaration) {
      ConstructorDeclaration declaration = (ConstructorDeclaration) constNode;
      NodeList<ConstructorInitializer> initializers = declaration.getInitializers();
      ConstructorElementImpl constructor = (ConstructorElementImpl) declaration.getElement();
      constructor.setConstantInitializers(new InitializerCloner().cloneNodeList(initializers));
    } else if (constNode instanceof FormalParameter) {
      if (constNode instanceof DefaultFormalParameter) {
        DefaultFormalParameter parameter = ((DefaultFormalParameter) constNode);
        ParameterElement element = parameter.getElement();
        Expression defaultValue = parameter.getDefaultValue();
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.