JvmOperation and JvmField in dsl [message #714471] |
Wed, 10 August 2011 11:12  |
Eclipse User |
|
|
|
Hello,
in my dsl I have following rule:
Method:
name=[jvmTypes::JvmOperation|QualifiedName]'('request=[jvmTypes::JvmType|QualifiedName]')'{'
'field:' field=[jvmTypes::JvmField|QualifiedName]
'}'
;
QualifiedName:
ID('.'ID)*
;
At runtime I got a lot of proposals for the request element (JvmType), but NO proposals for name (JvmOperation) and field (JvmField). Is my approach
completely wrong, or what did I miss?
What I want to achieve is, that I got a list of Java method proposals for name(JvmOperation) and a list of field proposals for the field (JvmField).
How can I get this to run?
Thanks in advance,
Markus
|
|
|
|
|
Re: JvmOperation and JvmField in dsl [message #714848 is a reply to message #714654] |
Thu, 11 August 2011 11:25  |
Eclipse User |
|
|
|
Hi Markus,
looks good to me.
Some minor remarks:
There is EObjectDescription.create(String, EObject) which takes care of
converting the simple string to a qualified name. There is
JvmDeclaredType#getDeclaredOperations which renders your cast and the
instanceof check obsolete.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 11.08.11 09:05, Markus Schindler wrote:
>
> Hi Sebastian,
>
> thanks for the quick response. Works like a charme!
> Here is my scoping method. Could you please take a look on it, if that's
> the way to go, or could this be simpler with same Helper classes (Which
> I don't know).
>
> public IScope scope_Method_name(WebService ws, EReference ref) {
> JvmType wsType = ws.getClazz().getName();
> List<IEObjectDescription> descriptions = new
> ArrayList<IEObjectDescription>();;
> if (wsType instanceof JvmGenericType) {
> JvmGenericType gt = (JvmGenericType) wsType;
> for (JvmMember member : gt.getMembers()) {
> if (member instanceof JvmOperation) {
> descriptions.add(EObjectDescription.create(QualifiedName.create(((JvmOperation)
> member).getSimpleName()), member));
> }
> }
> }
> return new SimpleScope(descriptions);
> }
>
>
> Regards,
> Markus
>
|
|
|
Powered by
FUDForum. Page generated in 0.05989 seconds