Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportUriGlobalScopeProvider: bug?
ImportUriGlobalScopeProvider: bug? [message #1719773] Mon, 11 January 2016 22:10 Go to next message
Ernesto Posse is currently offline Ernesto PosseFriend
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.

Re: ImportUriGlobalScopeProvider: bug? [message #1719789 is a reply to message #1719773] Tue, 12 January 2016 05:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
a=[B] is short for a=[B|ID] which means reference a B using ID. ID does not allow dots (the exception you get) so you might actually mean a=[B|QualifiedName]

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ImportUriGlobalScopeProvider: bug? [message #1719859 is a reply to message #1719773] Tue, 12 January 2016 16:13 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Aha! Yes, that's it.

Now, if I wanted to implement something that allowed me to use unqualified ids from imported models, what should I provide? an IQualifiedNameProvider? An IValueConverter? An ITokenToStringConverter? Something else?

Thanks.
Re: ImportUriGlobalScopeProvider: bug? [message #1719874 is a reply to message #1719859] Tue, 12 January 2016 19:07 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
If the things are globally unique use iqualifiednameprovider to index them under simple name

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Detecting language files
Next Topic:How to get index of the variable in the text of DSL program?
Goto Forum:
  


Current Time: Wed Apr 24 19:41:55 GMT 2024

Powered by FUDForum. Page generated in 0.03262 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top