ImportUriGlobalScopeProvider: bug? [message #1719773] |
Mon, 11 January 2016 22:10 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
I'm trying to use the ImportURIGlobalScope provider, but I'm running into an error. Consider the following language:
// automatically generated by Xtext
grammar eposse.experiments.xtext.sandbox.mydsl.MySandboxDsl with org.eclipse.xtext.common.Terminals
import "http://www.example.org/sandbox"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
System returns System:
{System}
'System'
name=EString
'{'
(imports+=Import)*
(artifacts+=Artifact | widgets+=Widget | modules+=Module)*
'}';
Import returns Import:
'import' 'ns' importedNamespace=QualifiedName ('.*')?
| 'import' 'uri' importURI=STRING
;
QualifiedName:
ID ('.' ID)*;
EString returns ecore::EString:
STRING | ID;
Artifact returns Artifact:
{Artifact}
'Artifact'
name=EString;
Widget returns Widget:
{Widget}
'Widget'
name=EString
':'
artifact=[Artifact]
;
Module returns Module:
{Module}
'Module'
name=EString
'{'
(artifacts+=Artifact | widgets+=Widget | modules+=Module)*
'}';
The underlying EMF model is imported, but can be inferred from the grammar.
My runtime module is as follows:
class MySandboxDslRuntimeModule extends AbstractMySandboxDslRuntimeModule
{
override bindIGlobalScopeProvider() { ImportUriGlobalScopeProvider }
}
And my scope provider is this:
class MySandboxDslScopeProvider extends AbstractMySandboxDslScopeProvider
{
@Inject IGlobalScopeProvider gsp
override IScope getScope(EObject context, EReference reference)
{
switch context {
Widget case reference == SandboxPackage.Literals.WIDGET__ARTIFACT :
{
return gsp.getScope(context.eResource, reference, Predicates.alwaysTrue)
}
}
return super.getScope(context, reference);
}
}
Now, I have two separate files:
// a.sandsl
System S1
{
Artifact A1
Artifact A2
}
and
// b.sandsl
System S2
{
import uri "platform:/resource/a/a.sandsl"
Widget W1 :
}
When running the editor, content-assist fails: typing Ctrl-Space after "Widget : " doesn't do anything, it doesn't show any proposals, and there are no exceptions shown in the console.
However, when I step-through in the debugger, I see that when I click Ctrl-Space, the getScope method above does get invokes and continues in AbstractJavaBasedContentProposalProvider, line 133, but a few calls later, after filtering, when applying the 'wrappedFactory' before passing it to the 'acceptor', it fails in like 95 invoking valueConverter.toString(proposal). In particular the exception is raised by assertToken in class AbstractLexerBasedConverter<T>.
The exception says "org.eclipse.xtext.conversion.ValueConverterException: ID 'S1.A2' contains invalid characters: '.' (0x2e)" and it's sent to the log as a debug message and then swallowed.
Before the exception is thrown the list of candidate IEObjectDescriptions are correct, so I don't know what's going on.
The exception suggests that there is a problem with qualified names, but these are being computed by the framework, not me.
Am I doing something wrong or is this a bug?
Thanks.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03262 seconds