Пример #1
0
  ClassElement makeListElement() {
    final TypeVariable typeVar = typeVar("E", itype(object));
    final ClassElement element = element("List", itype(object), typeVar);
    DartTypeNode returnTypeNode =
        new DartTypeNode(
            new DartIdentifier("Iterator"),
            Arrays.asList(new DartTypeNode(new DartIdentifier("E"))));

    DartMethodDefinition iteratorMethod =
        DartMethodDefinition.create(
            new DartIdentifier("iterator"),
            new DartFunction(
                Collections.<DartParameter>emptyList(),
                new DartBlock(Collections.<DartStatement>emptyList()),
                returnTypeNode),
            Modifiers.NONE,
            Collections.<DartInitializer>emptyList());
    MethodNodeElement iteratorMethodElement =
        Elements.methodFromMethodNode(iteratorMethod, element);
    Type returnType = Types.interfaceType(iterElement, Arrays.<Type>asList(typeVar));
    FunctionType functionType =
        ftype(function, returnType, Collections.<String, Type>emptyMap(), null);
    Elements.setType(iteratorMethodElement, functionType);
    Elements.addMethod(element, iteratorMethodElement);
    return element;
  }
Пример #2
0
 ClassElement element(String name, InterfaceType supertype, TypeVariable... parameters) {
   ClassElement element = Elements.classNamed(name);
   element.setSupertype(supertype);
   element.setType(itype(element, parameters));
   coreElements.put(name, element);
   return element;
 }
Пример #3
0
 static TypeVariable typeVar(String name, Type bound) {
   TypeVariableElement element = Elements.typeVariableElement(name, bound);
   return new TypeVariableImplementation(element);
 }