Couldn't resolve reference to PanelType 'NavigationBar' [message #1800718] |
Mon, 07 January 2019 08:26 |
Bert Roos Messages: 6 Registered: January 2019 |
Junior Member |
|
|
Hi,
I'm doing a little experiment with Xtext.
In my grammar, I have this:
Panel:
'panel' '(' ('type' ':' type=[PanelType] ')'
;
PanelType: name=ID;
My test involves trying to provide a set of values for different types of panels. To accomplish that, I wrote a simple scope provider:
class LayoutScopeProvider extends AbstractLayoutScopeProvider {
val panelTypes = newArrayList('NavigationBar', 'Patients', 'Results', 'Result', 'Chats', 'Chat')
override getScope(EObject context, EReference reference) {
if (context instanceof Panel && reference == LayoutPackage.Literals.PANEL__TYPE) {
val eclass = reference.eClass
return MapBasedScope.createScope(IScope.NULLSCOPE, panelTypes.stream().map(n|QualifiedName.create(n)).map([ qn |
EObjectDescription.create(qn, eclass)]).collect(Collectors.toList));
}
return super.getScope(context, reference);
}
}
With this scope provider, autocompletion works, resulting in a line like this:
panel ( type : NavigationBar )
However, Eclipse shows an error:
Couldn't resolve reference to PanelType 'NavigationBar'.
Any idea what I'm doing wrong?
Thanks in advance,
Bert
|
|
|
|
|
|
Re: Couldn't resolve reference to PanelType 'NavigationBar' [message #1800800 is a reply to message #1800778] |
Tue, 08 January 2019 13:51 |
Bert Roos Messages: 6 Registered: January 2019 |
Junior Member |
|
|
Thanks Christian!
That brings me a step forward, I believe. I've changed the code into this:
class LayoutScopeProvider extends AbstractLayoutScopeProvider {
val panelTypes = createPanelTypes()
override getScope(EObject context, EReference reference) {
if (context instanceof Panel && reference == LayoutPackage.Literals.PANEL__TYPE) {
return MapBasedScope.createScope(IScope.NULLSCOPE, panelTypes);
}
return super.getScope(context, reference);
}
def static createPanelTypes() {
val panelTypeNames = newArrayList('NavigationBar', 'Patients', 'Results', 'Result', 'Chats', 'Chat')
return panelTypeNames.stream().map([ n |
EObjectDescription.create(QualifiedName.create(n), LayoutFactory.eINSTANCE.createPanelType() => [name = n])
]).collect(Collectors.toList)
}
}
Now I get a different error message:
The feature 'type' of 'com.us.dsl.layout.impl.PanelImpl@4ae0e2dc{platform:/resource/MyDslTest/Patient.phlayout#//@elements.0}'
contains a dangling reference 'com.us.dsl.layout.impl.PanelTypeImpl@373442ad{#//}'
According to this forum posting, I should implement an IResourceServiceProvider. Unfortunately, that article does have any information on how to do this. It mentions GenericResourceServiceProvider, but the JavaDoc for that class is nearly empty and Google doesn't find any examples.
Do you have any suggestions?
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.18497 seconds