use of ceylon.language.Sequential in project ceylon by eclipse.
the class ClassOrInterfaceImpl method getDeclaredAttributes.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Get"), @TypeParameter(value = "Set") })
@TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::Attribute<Container,Get,Set>>")
public <Container, Get, Set> ceylon.language.Sequential<? extends ceylon.language.meta.model.Attribute<? super Container, ? extends Get, ? super Set>> getDeclaredAttributes(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedGet, @Ignore TypeDescriptor $reifiedSet, @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 ValueDeclaration> declaredDeclarations = declaration.<ValueDeclaration>declaredMemberDeclarations(ValueDeclaration.$TypeDescriptor$);
if (declaredDeclarations.getEmpty())
return (ceylon.language.Sequential) empty_.get_();
org.eclipse.ceylon.model.typechecker.model.Type reifiedGet = Metamodel.getProducedType($reifiedGet);
org.eclipse.ceylon.model.typechecker.model.Type reifiedSet = Metamodel.getProducedType($reifiedSet);
Iterator<?> iterator = declaredDeclarations.iterator();
Object it;
TypeDescriptor[] annotationTypeDescriptors = Metamodel.getTypeDescriptors(annotations);
TypeDescriptor reifiedKind = TypeDescriptor.klass(ceylon.language.meta.model.Attribute.class, $reifiedType, $reifiedGet, $reifiedSet);
ArrayList<ceylon.language.meta.model.Attribute<? super Container, ? extends Get, ? super Set>> members = new ArrayList<ceylon.language.meta.model.Attribute<? super Container, ? extends Get, ? super Set>>((int) declaredDeclarations.getSize());
while ((it = iterator.next()) != finished_.get_()) {
ValueDeclarationImpl decl = (ValueDeclarationImpl) it;
// ATM this is an AND WRT annotation types: all must be present
if (!Metamodel.hasAllAnnotations(decl, annotationTypeDescriptors))
continue;
addAttributeIfCompatible($reifiedContainer, $reifiedGet, $reifiedSet, members, decl, this.producedType, (ceylon.language.meta.model.Type<Container>) this, reifiedGet, reifiedSet);
}
Attribute[] array = members.toArray(new ceylon.language.meta.model.Attribute[0]);
ObjectArrayIterable<Attribute> iterable = new ObjectArrayIterable<ceylon.language.meta.model.Attribute>(reifiedKind, array);
return (ceylon.language.Sequential) iterable.sequence();
}
use of ceylon.language.Sequential in project ceylon by eclipse.
the class ClassOrInterfaceImpl method getClasses.
@SuppressWarnings({ "unchecked", "rawtypes", "hiding" })
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Type"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
@TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::MemberClass<Container,Type,Arguments>>")
public <Container, Type, Arguments extends Sequential<? extends Object>> ceylon.language.Sequential<? extends ceylon.language.meta.model.MemberClass<? super Container, ? extends Type, ? super Arguments>> getClasses(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Ignore TypeDescriptor $reifiedArguments, @Sequenced ceylon.language.Sequential<? extends ceylon.language.meta.model.Type<? extends java.lang.annotation.Annotation>> annotations) {
checkInit();
Sequential<? extends ClassDeclaration> declaredDeclarations = declaration.<ClassDeclaration>memberDeclarations(ClassDeclaration.$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);
org.eclipse.ceylon.model.typechecker.model.Type reifiedArguments = Metamodel.getProducedType($reifiedArguments);
Iterator<?> iterator = declaredDeclarations.iterator();
Object it;
TypeDescriptor[] annotationTypeDescriptors = Metamodel.getTypeDescriptors(annotations);
TypeDescriptor reifiedKind = TypeDescriptor.klass(ceylon.language.meta.model.MemberClass.class, $reifiedContainer, $reifiedType, $reifiedArguments);
ArrayList<ceylon.language.meta.model.MemberClass<? super Container, ? extends Type, ? super Arguments>> members = new ArrayList<ceylon.language.meta.model.MemberClass<? super Container, ? extends Type, ? super Arguments>>((int) declaredDeclarations.getSize());
while ((it = iterator.next()) != finished_.get_()) {
ClassDeclarationImpl decl = (ClassDeclarationImpl) it;
MemberLookup<ClassDeclarationImpl, Container> lookup = lookupMember(ClassDeclarationImpl.$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;
addClassIfCompatible($reifiedContainer, $reifiedType, $reifiedArguments, members, lookup.declaration, lookup.qualifyingType, lookup.containerMetamodel, reifiedType, reifiedArguments);
}
ceylon.language.meta.model.MemberClass[] array = members.toArray(new ceylon.language.meta.model.MemberClass[0]);
ObjectArrayIterable<ceylon.language.meta.model.MemberClass> iterable = new ObjectArrayIterable<ceylon.language.meta.model.MemberClass>(reifiedKind, array);
return (ceylon.language.Sequential) iterable.sequence();
}
use of ceylon.language.Sequential in project ceylon by eclipse.
the class CallableConstructorDeclarationImpl method apply.
@Override
public <Result, Arguments extends Sequential<? extends Object>> CallableConstructor<Result, Arguments> apply(TypeDescriptor $reified$Result, TypeDescriptor $reified$Arguments, Sequential<? extends Type<? extends Object>> typeArguments) {
// apply the given type arguments to the containing class
ClassDeclaration clsDecl = getContainer();
ceylon.language.meta.model.Class<? extends Result, ?> cls = clsDecl.<Result, Sequential<? extends java.lang.Object>>classApply($reified$Result, Nothing.NothingType, typeArguments);
// then get the constructor from that
return Util.assertExists((CallableConstructor) cls.<Arguments>getDeclaredConstructor($reified$Arguments, getName()));
}
use of ceylon.language.Sequential in project ceylon by eclipse.
the class ClassOrInterfaceDeclarationImpl method filteredMembers.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <Kind> Sequential<? extends Kind> filteredMembers(@Ignore TypeDescriptor $reifiedKind, Predicates.Predicate predicate) {
if (predicate == Predicates.false_()) {
return (Sequential<? extends Kind>) empty_.get_();
}
checkInit();
ArrayList<Kind> members = new ArrayList<Kind>(declarations.size());
for (ceylon.language.meta.declaration.NestableDeclaration decl : declarations) {
Declaration declaration2 = ((NestableDeclarationImpl) decl).declaration;
if (!declaration2.isNativeHeader() && predicate.accept(declaration2)) {
members.add((Kind) decl);
}
}
java.lang.Object[] array = members.toArray(new java.lang.Object[0]);
ObjectArrayIterable<Kind> iterable = new ObjectArrayIterable<Kind>($reifiedKind, (Kind[]) array);
return (ceylon.language.Sequential) iterable.sequence();
}
use of ceylon.language.Sequential in project ceylon by eclipse.
the class ClassOrInterfaceDeclarationImpl method init.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void init() {
org.eclipse.ceylon.model.typechecker.model.ClassOrInterface declaration = (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) this.declaration;
Type superType = declaration.getExtendedType();
if (superType != null)
this.superclass = (ceylon.language.meta.declaration.OpenClassType) Metamodel.getMetamodel(superType);
List<Type> satisfiedTypes = declaration.getSatisfiedTypes();
ceylon.language.meta.declaration.OpenInterfaceType[] interfaces = new ceylon.language.meta.declaration.OpenInterfaceType[satisfiedTypes.size()];
int i = 0;
for (Type pt : satisfiedTypes) {
interfaces[i++] = (ceylon.language.meta.declaration.OpenInterfaceType) Metamodel.getMetamodel(pt);
}
this.interfaces = Util.sequentialWrapper(ceylon.language.meta.declaration.OpenInterfaceType.$TypeDescriptor$, interfaces);
if (declaration.getCaseTypes() != null)
this.caseTypes = Metamodel.getMetamodelSequential(declaration.getCaseTypes());
else
this.caseTypes = (Sequential<? extends ceylon.language.meta.declaration.OpenType>) (Sequential) empty_.get_();
this.typeParameters = Metamodel.getTypeParameters(declaration);
List<org.eclipse.ceylon.model.typechecker.model.Declaration> memberModelDeclarations = declaration.getMembers();
this.declaredDeclarations = new LinkedList<ceylon.language.meta.declaration.NestableDeclaration>();
for (org.eclipse.ceylon.model.typechecker.model.Declaration memberModelDeclaration : memberModelDeclarations) {
addDeclarationTo(memberModelDeclaration, declaredDeclarations);
}
Collection<org.eclipse.ceylon.model.typechecker.model.Declaration> inheritedModelDeclarations = collectMembers(declaration);
this.declarations = new LinkedList<ceylon.language.meta.declaration.NestableDeclaration>();
for (org.eclipse.ceylon.model.typechecker.model.Declaration memberModelDeclaration : inheritedModelDeclarations) {
addDeclarationTo(memberModelDeclaration, declarations);
}
}
Aggregations