Package com.google.dart.engine.internal.element

Examples of com.google.dart.engine.internal.element.ExecutableElementImpl


    DynamicTypeImpl dynamicType = DynamicTypeImpl.getInstance();
    SimpleIdentifier nameIdentifier = new SimpleIdentifier(new StringToken(
        TokenType.IDENTIFIER,
        name,
        0));
    ExecutableElementImpl executable;
    if (elementArrayToMerge[0] instanceof MethodElement) {
      MultiplyInheritedMethodElementImpl unionedMethod = new MultiplyInheritedMethodElementImpl(
          nameIdentifier);
      unionedMethod.setInheritedElements(elementArrayToMerge);
      executable = unionedMethod;
    } else {
      MultiplyInheritedPropertyAccessorElementImpl unionedPropertyAccessor = new MultiplyInheritedPropertyAccessorElementImpl(
          nameIdentifier);
      unionedPropertyAccessor.setGetter(((PropertyAccessorElement) elementArrayToMerge[0]).isGetter());
      unionedPropertyAccessor.setSetter(((PropertyAccessorElement) elementArrayToMerge[0]).isSetter());
      unionedPropertyAccessor.setInheritedElements(elementArrayToMerge);
      executable = unionedPropertyAccessor;
    }

    int numOfParameters = numOfRequiredParameters + numOfPositionalParameters
        + namedParameters.length;
    ParameterElement[] parameters = new ParameterElement[numOfParameters];
    int i = 0;
    for (int j = 0; j < numOfRequiredParameters; j++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl("", 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.REQUIRED);
      parameters[i] = parameter;
    }
    for (int k = 0; k < numOfPositionalParameters; k++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl("", 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.POSITIONAL);
      parameters[i] = parameter;
    }
    for (int m = 0; m < namedParameters.length; m++, i++) {
      ParameterElementImpl parameter = new ParameterElementImpl(namedParameters[m], 0);
      parameter.setType(dynamicType);
      parameter.setParameterKind(ParameterKind.NAMED);
      parameters[i] = parameter;
    }
    executable.setReturnType(dynamicType);
    executable.setParameters(parameters);

    FunctionTypeImpl methodType = new FunctionTypeImpl(executable);
    executable.setType(methodType);

    return executable;
  }
View Full Code Here


    // so we may want [FunctionElementImpl]
    // instead here in some cases? And then there are constructors and property accessors.
    // Maybe the answer is to create a new subclass of [ExecutableElementImpl] which
    // is used for merged executable elements, in analogy with [MultiplyInheritedMethodElementImpl]
    // and [MultiplyInheritedPropertyAcessorElementImpl].
    ExecutableElementImpl e_out = new MethodElementImpl(e_0.getName(), 0);
    e_out.setSynthetic(true);
    e_out.setReturnType(r_out);
    e_out.setParameters(ps_out);
    e_out.setType(new FunctionTypeImpl(e_out));
    // Get NPE in [toString()] w/o this.
    e_out.setEnclosingElement(e_0.getEnclosingElement());
    return e_out;
  }
View Full Code Here

  }

  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    super.visitConstructorDeclaration(node);
    ExecutableElementImpl element = (ExecutableElementImpl) node.getElement();
    if (element == null) {
      ClassDeclaration classNode = node.getAncestor(ClassDeclaration.class);
      StringBuilder builder = new StringBuilder();
      builder.append("The element for the constructor ");
      builder.append(node.getName() == null ? "<unnamed>" : node.getName().getName());
      builder.append(" in ");
      if (classNode == null) {
        builder.append("<unknown class>");
      } else {
        builder.append(classNode.getName().getName());
      }
      builder.append(" in ");
      builder.append(getSource().getFullName());
      builder.append(" was not set while trying to resolve types.");
      AnalysisEngine.getInstance().getLogger().logError(builder.toString(), new AnalysisException());
    } else {
      ClassElement definingClass = (ClassElement) element.getEnclosingElement();
      element.setReturnType(definingClass.getType());
      FunctionTypeImpl type = new FunctionTypeImpl(element);
      type.setTypeArguments(definingClass.getType().getTypeArguments());
      element.setType(type);
    }
    return null;
  }
View Full Code Here

  }

  @Override
  public Void visitFunctionDeclaration(FunctionDeclaration node) {
    super.visitFunctionDeclaration(node);
    ExecutableElementImpl element = (ExecutableElementImpl) node.getElement();
    if (element == null) {
      StringBuilder builder = new StringBuilder();
      builder.append("The element for the top-level function ");
      builder.append(node.getName());
      builder.append(" in ");
      builder.append(getSource().getFullName());
      builder.append(" was not set while trying to resolve types.");
      AnalysisEngine.getInstance().getLogger().logError(builder.toString(), new AnalysisException());
    }
    element.setReturnType(computeReturnType(node.getReturnType()));
    FunctionTypeImpl type = new FunctionTypeImpl(element);
    ClassElement definingClass = element.getAncestor(ClassElement.class);
    if (definingClass != null) {
      type.setTypeArguments(definingClass.getType().getTypeArguments());
    }
    element.setType(type);
    return null;
  }
View Full Code Here

  }

  @Override
  public Void visitMethodDeclaration(MethodDeclaration node) {
    super.visitMethodDeclaration(node);
    ExecutableElementImpl element = (ExecutableElementImpl) node.getElement();
    if (element == null) {
      ClassDeclaration classNode = node.getAncestor(ClassDeclaration.class);
      StringBuilder builder = new StringBuilder();
      builder.append("The element for the method ");
      builder.append(node.getName().getName());
      builder.append(" in ");
      if (classNode == null) {
        builder.append("<unknown class>");
      } else {
        builder.append(classNode.getName().getName());
      }
      builder.append(" in ");
      builder.append(getSource().getFullName());
      builder.append(" was not set while trying to resolve types.");
      AnalysisEngine.getInstance().getLogger().logError(builder.toString(), new AnalysisException());
    }
    element.setReturnType(computeReturnType(node.getReturnType()));
    FunctionTypeImpl type = new FunctionTypeImpl(element);
    ClassElement definingClass = element.getAncestor(ClassElement.class);
    if (definingClass != null) {
      type.setTypeArguments(definingClass.getType().getTypeArguments());
    }
    element.setType(type);
    if (element instanceof PropertyAccessorElement) {
      PropertyAccessorElement accessor = (PropertyAccessorElement) element;
      PropertyInducingElementImpl variable = (PropertyInducingElementImpl) accessor.getVariable();
      if (accessor.isGetter()) {
        variable.setType(type.getReturnType());
View Full Code Here

  }

  @Override
  public Void visitFunctionDeclaration(FunctionDeclaration node) {
    FunctionExpression function = node.getFunctionExpression();
    ExecutableElementImpl functionElement = (ExecutableElementImpl) node.getElement();
    functionElement.setReturnType(computeStaticReturnTypeOfFunctionDeclaration(node));
    recordPropagatedTypeOfFunction(functionElement, function.getBody());
    recordStaticType(function, functionElement.getType());
    return null;
  }
View Full Code Here

  public Void visitFunctionExpression(FunctionExpression node) {
    if (node.getParent() instanceof FunctionDeclaration) {
      // The function type will be resolved and set when we visit the parent node.
      return null;
    }
    ExecutableElementImpl functionElement = (ExecutableElementImpl) node.getElement();
    functionElement.setReturnType(computeStaticReturnTypeOfFunctionExpression(node));
    recordPropagatedTypeOfFunction(functionElement, node.getBody());
    recordStaticType(node, node.getElement().getType());
    return null;
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.element.ExecutableElementImpl

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.