|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Specific Class type in xtext grammar [message #1734752 is a reply to message #1734751] |
Sat, 11 June 2016 06:50 |
|
so what i miss in your grammar is somthing like
Model:
(imports=XImportSection)?
actions+=Action*;
Action:
"action" type=[types::JvmDeclaredType] "." field=[types::JvmField]
;
class MyDslScopeProvider extends AbstractMyDslScopeProvider {
override getScope(EObject context, EReference reference) {
if (reference === MyDslPackage.Literals.ACTION__FIELD) {
if (context instanceof Action) {
val result = Scopes.scopeFor(context.type.members.filter(JvmField).filter[isStatic],[QualifiedName.create(simpleName)], IScope.NULLSCOPE) //TODO filter
println(result)
return result
}
}
return super.getScope(context, reference)
}
}
or
Model:
(imports=XImportSection)?
actions+=Action*;
Action:
"action" target=XMemberFeatureCall
;
class MyDslJvmModelInferrer extends AbstractModelInferrer {
@Inject extension JvmTypesBuilder
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
acceptor.accept(element.toClass("my.company.greeting.MyTest")) [
var i = 0;
for (a : element.actions) {
members += a.toMethod("getActionTarget" + i, typeRef("a.b.c.IAction")) [
body = a.target
]
i = i + 1
}
]
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05336 seconds