interface SomeInterface{
Clazz doThing(by("parameter") Clazz clazz);
}
And class Clazz
by("type")
class Clazz(){}
So i want to get from this method parameter - clazz, both annotations:
by("parameter")
by("type")
OK by so calling
'SomeInterface.doThing'.declaration.parameters.each(FunctionOrValueDeclaration element)=> element.annotations<Annotation>()....);
I can extract my first annotation
Now from the method i can obtain also parameter types. By calling Method.parameterTypes.
But in my application, annotations are obtained, when passed Model not declaration or specyfic type. So normally for method or attribute I would call bind on declaration. For the parametter there is apply method in ValueDeclaration (i dont care about functional parameters). It requires specyfic staticly typed type (Value<Clazz> val=parameter.apply()) which i dont have as all operations are generic. I cannot use a variable as type parametter obtained from Method.parameterTypes.
How to obtain Value<> for parameter of SomeInterface.doThing ?
Hello, seems i was mistaken from the beginning. It is not possible (correct me if I'm wrong) to fetch generic OptionalAnnotation's or SequencedAnnotation's from Model declaration. So i made a fallback to optionalAnnotation and sequencedAnnotations built in top level functions and not caching results. But still can we construct a Model declaration from Method.declaration.parameters.first and Method.parameterTypes.first , like we can with function https://modules.ceylon-lang.org/repo/1/ceylon/language/1.3.0/module-doc/api/meta/declaration/FunctionDeclaration.type.html - apply?
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users+unsubscribe@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/6db5703e-f3a6-4384-b835-6fe446b950d9%40googlegroups.com.
Hi, that's what I'm struggling with.. it is not working.
shared test void functionParameterApplyTest() {
FunctionOrValueDeclaration? first = `function testFunc`.parameterDeclarations.first;
assert(exists first, first.name=="arg");
assert(is ValueDeclaration first);
Value<String,String> apply = first.apply<String,String>(); //ceylon.language.meta.model.TypeApplicationException "Cannot apply a member declaration with no container type: use memberApply"
print(apply);
}
shared test void functionParameterMemberApplyTest() {
FunctionOrValueDeclaration? first = `function testFunc`.parameterDeclarations.first;
assert(exists first, first.name=="arg");
assert(is ValueDeclaration first);
ValueModel<> memberApply = first.memberApply(type(testFunc));//ceylon.language.Exception "parameterized test failed, argument provider probably returned incompatible values"
print(memberApply);
}
void testFunc(String arg){}
On Wednesday, 12 October 2016 09:52:02 UTC+2, Stéphane Épardaud wrote:
Sure, you can apply your declarations to get models, even for parameters.
On 11 October 2016 at 23:06, Wojciech Potiopa <wojciech...@gmail.com> wrote:
Hello, seems i was mistaken from the beginning. It is not possible (correct me if I'm wrong) to fetch generic OptionalAnnotation's or SequencedAnnotation's from Model declaration. So i made a fallback to optionalAnnotation and sequencedAnnotations built in top level functions and not caching results. But still can we construct a Model declaration from Method.declaration.parameters.first and Method.parameterTypes.first , like we can with function https://modules.ceylon-lang.org/repo/1/ceylon/language/1.3.0/module-doc/api/meta/declaration/FunctionDeclaration.type.html - apply?
On Friday, 7 October 2016 23:32:00 UTC+2, Wojciech Potiopa wrote:Hello. At beginning i want to apologise for lack of formatting and semantic errors as i'm writing this on a phone.
I'm creating a framework which uses annotations for Configuration of further operation.
In simple words there is an interface which can be annoted. Each it's method and their parameters may be annoted. I want to read this annotations. But for some components i want to read also annotations from underlaying type f.e. let's take method in interfaceinterface SomeInterface{
Clazz doThing(by("parameter") Clazz clazz);
}
And class Clazz
by("type")
class Clazz(){}So i want to get from this method parameter - clazz, both annotations:
by("parameter")
by("type")OK by so calling
'SomeInterface.doThing'.declaration.parameters.each(FunctionOrValueDeclaration element)=> element.annotations<Annotation>()....);
I can extract my first annotationNow from the method i can obtain also parameter types. By calling Method.parameterTypes.
But in my application, annotations are obtained, when passed Model not declaration or specyfic type. So normally for method or attribute I would call bind on declaration. For the parametter there is apply method in ValueDeclaration (i dont care about functional parameters). It requires specyfic staticly typed type (Value<Clazz> val=parameter.apply()) which i dont have as all operations are generic. I cannot use a variable as type parametter obtained from Method.parameterTypes.
How to obtain Value<> for parameter of SomeInterface.doThing ?
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/6db5703e-f3a6-4384-b835-6fe446b950d9%40googlegroups.com.
--Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users+unsubscribe@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/22b2f987-2da5-46bc-b783-146b014ffa41%40googlegroups.com.
Ok, Thank You for answering. I think i cannot do my annotation processing with declaration as i need underlying type f.e.:
Enter code here...final annotation class SeqAnno(shared String val) satisfies SequencedAnnotation<SeqAnno, Annotated>{}
annotation SeqAnno seq(String val) => SeqAnno(val);
seq("TestOne")
seq("TestTwo")
interface AnnoTestInterface satisfies BaseInterface &OptionalBaseIFace {
shared formal OptionalBaseIFace testMethod(seq("Param") AnnoTestInterface param);
by("Method")
seq("Method")
shared formal BaseInterface test2Method(OptionalBaseIFace arg,by("Param") OptionalBaseIFace arg2);
}
seq("TestBaseOne")
seq("TestBaseTwo")
interface BaseInterface{
}
by ("Base")
shared interface OptionalBaseIFace {
}
I want to fetchSeqAnno
annotations from let say
AnnoTestInterface but also if I'm fetching them i want to have annotations from
BaseInterface and OptionalBaseIFace
interfaces. The same with methods, attributes and parameters. So from what i see i cannot get thees types from declaration.
Thank you
Wojciech
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/22b2f987-2da5-46bc-b783-146b014ffa41%40googlegroups.com.
--Stéphane Épardaud--Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users+unsubscribe@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/e9736e7d-a614-4cb8-8cd2-be18b9d3bcc6%40googlegroups.com.