|
Re: Issue generating a DSL grammar [message #1016499 is a reply to message #1016319] |
Wed, 06 March 2013 16:56 |
|
Hi,
i think this is basically a scoping issue never the less.
in your grammar you have
Preconditions:
'precondition :' param=[Parameters|QualifiedName] 'NOT IN' attribute=[Attributes|QualifiedName];
so let us change it to
Preconditions:
'precondition :' param=[Attributes|QualifiedName] 'NOT IN' attribute=[Attributes|QualifiedName];
and use scoping like
class MyDslScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider {
def IScope scope_Preconditions_param(Operations ctx, EReference ref) {
if (ctx.parameter.type instanceof Entity) {
Scopes::scopeFor((ctx.parameter.type as Entity).attribute, [Attributes a|QualifiedName::create(ctx.parameter.name, a.name)], IScope::NULLSCOPE)
} else{
IScope::NULLSCOPE
}
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Issue generating a DSL grammar [message #1031015 is a reply to message #1016499] |
Mon, 01 April 2013 04:12 |
John Castano Messages: 7 Registered: December 2012 |
Junior Member |
|
|
Hi Christian,
I did what you recommended me and It Works partially.
I put your instrutions (red color) with some changes (blue color) in the Scope Class, but i have a problem trying to pass the arguments to the method named "scopeFor" when i translated the code "[Attributes a|QualifiedName::create(ctx.parameter.name, a.name)]" because an argument type function is mandatory. If I omit this parameter , i can get the attributes of the entity without a Qualified part.
public class MyDslScopeProvider extends AbstractDeclarativeScopeProvider {
IScope scope_Preconditions_param(Operations ctx, EReference ref) {
// if (ctx.parameter.type instanceof Entity) {
// Scopes.scopeFor((ctx.parameter.type as Entity).attribute, [Attributes a|QualifiedName::create(ctx.parameter.name, a.name)], IScope::NULLSCOPE)
// } else{
// IScope :: NULLSCOPE
// }
if(ctx.getParameter().getType() instanceof Entity) {
return Scopes.scopeFor (((Entity)(ctx.getParameter().getType())).getAttribute()/*,QualifiedName.create(ctx.getParameter().getName())*/, IScope.NULLSCOPE);
} else {
return IScope.NULLSCOPE;
}
}
}
Do you know how can i solve this issue?
Thanks in advance for your help.
|
|
|
|
|
Re: Issue generating a DSL grammar [message #1031736 is a reply to message #1016319] |
Tue, 02 April 2013 06:16 |
michael m Messages: 17 Registered: March 2013 |
Junior Member |
|
|
Hi,
you could try this:
return Scopes.scopeFor (((Entity)(ctx.getParameter().getType())).getAttribute(),
new com.google.common.base.Function<Attributes, QualifiedName>() {
public QualifiedName apply(Attributes a) {
return QualifiedName.create(ctx.getParameter().getName(), a.getName());
}
}
,IScope.NULLSCOPE);
and define the method args as final e.g. "final Operations ctx".
[Updated on: Tue, 02 April 2013 06:18] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05462 seconds