use of ceylon.language.meta.declaration.ClassDeclaration in project ceylon by eclipse.
the class Tuple method $references$.
@Ignore
@Override
public java.util.Collection<ReachableReference> $references$() {
// could put the elements with int indexes and the rest as a String!
ArrayList<ReachableReference> s = new ArrayList<ReachableReference>(2);
ClassDeclaration cd = (ClassDeclaration) Metamodel.getOrCreateMetamodel(Tuple.class);
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "first"))));
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "rest"))));
return s;
}
use of ceylon.language.meta.declaration.ClassDeclaration in project ceylon by eclipse.
the class ValueConstructorDeclarationImpl method apply.
@Override
@TypeInfo("ceylon.language.meta.model::Value<Get>")
@TypeParameters({ @TypeParameter("Get") })
public <Get> ceylon.language.meta.model.ValueConstructor<Get> apply(@Ignore TypeDescriptor $reifiedGet) {
// TODO if(!getToplevel())
// throw new ceylon.language.meta.model.TypeApplicationException("Cannot apply a member declaration with no container type: use memberApply");
// TODO what is Set is anything other than Nothing?
// c.f. classApply with an incorect parameters
org.eclipse.ceylon.model.typechecker.model.Value modelDecl = (org.eclipse.ceylon.model.typechecker.model.Value) declaration;
org.eclipse.ceylon.model.typechecker.model.TypedReference typedReference = modelDecl.appliedTypedReference(null, Collections.<Type>emptyList());
org.eclipse.ceylon.model.typechecker.model.Type getType = typedReference.getType();
TypeDescriptor reifiedGet = Metamodel.getTypeDescriptorForProducedType(getType.getQualifyingType());
// immutable values have Set=Nothing
// org.eclipse.ceylon.model.typechecker.model.Type setType = getVariable() ?
// getType : modelDecl.getUnit().getNothingType();
// TypeDescriptor reifiedSet = getVariable() ? reifiedGet : TypeDescriptor.NothingType;
Metamodel.checkReifiedTypeArgument("apply", "Value<$1>", Variance.OUT, getType, $reifiedGet);
// XXX This is a lie, and we only get away with it due to erasure
ClassDeclaration clsDecl = getContainer();
ceylon.language.meta.model.Class<? extends Get, ?> cls = clsDecl.<Get, Sequential<? extends java.lang.Object>>classApply($reifiedGet, Nothing.NothingType, (Sequential) empty_.get_());
return (ceylon.language.meta.model.ValueConstructor<Get>) new ValueConstructorImpl<Get>(reifiedGet, this, typedReference, (ClassImpl) cls, null);
}
use of ceylon.language.meta.declaration.ClassDeclaration 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.meta.declaration.ClassDeclaration 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()));
}
Aggregations