Search in sources :

Example 1 with InterfaceDeclaration

use of ceylon.language.meta.declaration.InterfaceDeclaration in project ceylon by eclipse.

the class ClassOrInterfaceImpl method getInterfaces.

@SuppressWarnings({ "unchecked", "rawtypes", "hiding" })
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Type") })
@TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::MemberInterface<Container,Type>>")
public <Container, Type> ceylon.language.Sequential<? extends ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>> getInterfaces(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Sequenced ceylon.language.Sequential<? extends ceylon.language.meta.model.Type<? extends java.lang.annotation.Annotation>> annotations) {
    checkInit();
    Sequential<? extends InterfaceDeclaration> declaredDeclarations = declaration.<InterfaceDeclaration>memberDeclarations(InterfaceDeclaration.$TypeDescriptor$);
    if (declaredDeclarations.getEmpty())
        return (ceylon.language.Sequential) empty_.get_();
    org.eclipse.ceylon.model.typechecker.model.Type reifiedContainer = Metamodel.getProducedType($reifiedContainer);
    org.eclipse.ceylon.model.typechecker.model.Type reifiedType = Metamodel.getProducedType($reifiedType);
    Iterator<?> iterator = declaredDeclarations.iterator();
    Object it;
    TypeDescriptor[] annotationTypeDescriptors = Metamodel.getTypeDescriptors(annotations);
    TypeDescriptor reifiedKind = TypeDescriptor.klass(ceylon.language.meta.model.MemberInterface.class, $reifiedContainer, $reifiedType);
    ArrayList<ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>> members = new ArrayList<ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>>((int) declaredDeclarations.getSize());
    while ((it = iterator.next()) != finished_.get_()) {
        InterfaceDeclarationImpl decl = (InterfaceDeclarationImpl) it;
        MemberLookup<InterfaceDeclarationImpl, Container> lookup = lookupMember(InterfaceDeclarationImpl.$TypeDescriptor$, $reifiedContainer, reifiedContainer, decl);
        if (lookup == null)
            continue;
        // skip generic classes
        if (!lookup.declaration.getTypeParameterDeclarations().getEmpty())
            continue;
        // ATM this is an AND WRT annotation types: all must be present
        if (!Metamodel.hasAllAnnotations(lookup.declaration, annotationTypeDescriptors))
            continue;
        addInterfaceIfCompatible($reifiedContainer, $reifiedType, members, lookup.declaration, lookup.qualifyingType, lookup.containerMetamodel, reifiedType);
    }
    ceylon.language.meta.model.MemberInterface[] array = members.toArray(new ceylon.language.meta.model.MemberInterface[0]);
    ObjectArrayIterable<ceylon.language.meta.model.MemberInterface> iterable = new ObjectArrayIterable<ceylon.language.meta.model.MemberInterface>(reifiedKind, array);
    return (ceylon.language.Sequential) iterable.sequence();
}
Also used : ArrayList(java.util.ArrayList) InterfaceDeclaration(ceylon.language.meta.declaration.InterfaceDeclaration) ClassOrInterfaceDeclaration(ceylon.language.meta.declaration.ClassOrInterfaceDeclaration) InterfaceDeclarationImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.InterfaceDeclarationImpl) ClassOrInterfaceDeclarationImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl) ObjectArrayIterable(org.eclipse.ceylon.compiler.java.language.ObjectArrayIterable) ReifiedType(org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType) TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) Sequential(ceylon.language.Sequential) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) TypeParameters(org.eclipse.ceylon.compiler.java.metadata.TypeParameters) TypeInfo(org.eclipse.ceylon.compiler.java.metadata.TypeInfo)

Example 2 with InterfaceDeclaration

use of ceylon.language.meta.declaration.InterfaceDeclaration in project ceylon by eclipse.

the class ClassOrInterfaceImpl method getDeclaredInterfaces.

@SuppressWarnings({ "unchecked", "rawtypes", "hiding" })
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Type") })
@TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::MemberInterface<Container,Type>>")
public <Container, Type> ceylon.language.Sequential<? extends ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>> getDeclaredInterfaces(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Sequenced ceylon.language.Sequential<? extends ceylon.language.meta.model.Type<? extends java.lang.annotation.Annotation>> annotations) {
    checkInit();
    // check the container type first
    org.eclipse.ceylon.model.typechecker.model.Type reifiedContainer = Metamodel.getProducedType($reifiedContainer);
    if (!reifiedContainer.isSubtypeOf(this.producedType))
        return (ceylon.language.Sequential) empty_.get_();
    Sequential<? extends InterfaceDeclaration> declaredDeclarations = declaration.<InterfaceDeclaration>declaredMemberDeclarations(InterfaceDeclaration.$TypeDescriptor$);
    if (declaredDeclarations.getEmpty())
        return (ceylon.language.Sequential) empty_.get_();
    org.eclipse.ceylon.model.typechecker.model.Type reifiedType = Metamodel.getProducedType($reifiedType);
    Iterator<?> iterator = declaredDeclarations.iterator();
    Object it;
    TypeDescriptor[] annotationTypeDescriptors = Metamodel.getTypeDescriptors(annotations);
    TypeDescriptor reifiedKind = TypeDescriptor.klass(ceylon.language.meta.model.MemberInterface.class, $reifiedContainer, $reifiedType);
    ArrayList<ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>> members = new ArrayList<ceylon.language.meta.model.MemberInterface<? super Container, ? extends Type>>((int) declaredDeclarations.getSize());
    while ((it = iterator.next()) != finished_.get_()) {
        InterfaceDeclarationImpl decl = (InterfaceDeclarationImpl) it;
        // skip generic classes
        if (!decl.getTypeParameterDeclarations().getEmpty())
            continue;
        // ATM this is an AND WRT annotation types: all must be present
        if (!Metamodel.hasAllAnnotations(decl, annotationTypeDescriptors))
            continue;
        addInterfaceIfCompatible($reifiedContainer, $reifiedType, members, decl, producedType, (ClassOrInterfaceImpl<Container>) this, reifiedType);
    }
    ceylon.language.meta.model.MemberInterface[] array = members.toArray(new ceylon.language.meta.model.MemberInterface[0]);
    ObjectArrayIterable<ceylon.language.meta.model.MemberInterface> iterable = new ObjectArrayIterable<ceylon.language.meta.model.MemberInterface>(reifiedKind, array);
    return (ceylon.language.Sequential) iterable.sequence();
}
Also used : ArrayList(java.util.ArrayList) InterfaceDeclaration(ceylon.language.meta.declaration.InterfaceDeclaration) ClassOrInterfaceDeclaration(ceylon.language.meta.declaration.ClassOrInterfaceDeclaration) InterfaceDeclarationImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.InterfaceDeclarationImpl) ClassOrInterfaceDeclarationImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl) ObjectArrayIterable(org.eclipse.ceylon.compiler.java.language.ObjectArrayIterable) ReifiedType(org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType) TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) Sequential(ceylon.language.Sequential) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) TypeParameters(org.eclipse.ceylon.compiler.java.metadata.TypeParameters) TypeInfo(org.eclipse.ceylon.compiler.java.metadata.TypeInfo)

Aggregations

Sequential (ceylon.language.Sequential)2 ClassOrInterfaceDeclaration (ceylon.language.meta.declaration.ClassOrInterfaceDeclaration)2 InterfaceDeclaration (ceylon.language.meta.declaration.InterfaceDeclaration)2 ArrayList (java.util.ArrayList)2 ObjectArrayIterable (org.eclipse.ceylon.compiler.java.language.ObjectArrayIterable)2 TypeInfo (org.eclipse.ceylon.compiler.java.metadata.TypeInfo)2 TypeParameters (org.eclipse.ceylon.compiler.java.metadata.TypeParameters)2 Metamodel (org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel)2 ClassOrInterfaceDeclarationImpl (org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl)2 InterfaceDeclarationImpl (org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.InterfaceDeclarationImpl)2 ReifiedType (org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType)2 TypeDescriptor (org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor)2