Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to handle two different scoping providers?
How to handle two different scoping providers? [message #783557] Thu, 26 January 2012 00:18 Go to next message
J. S. Pam is currently offline J. S. PamFriend
Messages: 3
Registered: January 2012
Junior Member
Hi all,

I am currently writing a debugger for an Xtext language. To be able to evaluate expressions, I need two different scoping providers:

- one normal scoping provider (MyDslScopeProvider) for the language in the IDE
- one debug scoping provider (MyDslDebugScopeProvider) which provides the scope for the variable references mentioned in the watch expressions. Their scope is simply the list of variables available in the current execution context (which I get from the interpreter).

So how do I tell Xtext to use my DebugScopeProvider? I have tried the following:

private Expression parseExpressionString(final String expressionText) throws DebugException {
		// Create a new program that contains the expression evaluation.
		String expressionProgramText = "__eval " + expressionText;

		// Obtain an injector and create an Xtext resource
		Injector guiceInjector = new MyDslDebuggerStandaloneSetup(this).createInjector();
		XtextResourceSet resourceSet = guiceInjector.getInstance(XtextResourceSet.class);
		...


where MyDslDebuggerStandaloneSetup has

@Override
	public final Injector createInjector() {
		return Guice.createInjector(new MyDslDebuggerRuntimeModule(this.debugTarget));
	}


and MyDslDebuggerRuntimeModule has

@Override
	public final Class<? extends IScopeProvider> bindIScopeProvider() {
		return MyDslDebugScopeProvider.class;
	}


This code is placed in the debugger plugin, which is separate from the UI plugin.

However, when the above code runs, the bindIScopeProvider() method of the debugger runtime module is never called. Instead, the existing scope provider is called.

How can I tell Xtext (or maybe Guice) to explicitly use my debug scope provider?

Thanks in advance for any hints.
Re: How to handle two different scoping providers? [message #783734 is a reply to message #783557] Thu, 26 January 2012 10:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

you should never and under no circumstances use a standalone setup when
running in Eclipse. This will corrupt the emf registries and is likely
to have all sorts of unpredicatable side effects. That's why it's called
'StandaloneSetup' ;-)

For now, the easiest way would be to have second language that extends
the first one and uses a dedicated file extension etc.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.01.12 01:18, schrieb J. S. Pam:
> Hi all,
>
> I am currently writing a debugger for an Xtext language. To be able to
> evaluate expressions, I need two different scoping providers:
>
> - one normal scoping provider (MyDslScopeProvider) for the language in
> the IDE
> - one debug scoping provider (MyDslDebugScopeProvider) which provides
> the scope for the variable references mentioned in the watch
> expressions. Their scope is simply the list of variables available in
> the current execution context (which I get from the interpreter).
>
> So how do I tell Xtext to use my DebugScopeProvider? I have tried the
> following:
>
> private Expression parseExpressionString(final String expressionText)
> throws DebugException {
> // Create a new program that contains the expression evaluation.
> String expressionProgramText = "__eval " + expressionText;
>
> // Obtain an injector and create an Xtext resource
> Injector guiceInjector = new
> MyDslDebuggerStandaloneSetup(this).createInjector();
> XtextResourceSet resourceSet =
> guiceInjector.getInstance(XtextResourceSet.class);
> ...
>
> where MyDslDebuggerStandaloneSetup has
>
> @Override
> public final Injector createInjector() {
> return Guice.createInjector(new
> MyDslDebuggerRuntimeModule(this.debugTarget));
> }
>
> and MyDslDebuggerRuntimeModule has
>
> @Override
> public final Class<? extends IScopeProvider> bindIScopeProvider() {
> return MyDslDebugScopeProvider.class;
> }
>
> This code is placed in the debugger plugin, which is separate from the
> UI plugin.
>
> However, when the above code runs, the bindIScopeProvider() method of
> the debugger runtime module is never called. Instead, the existing scope
> provider is called.
>
> How can I tell Xtext (or maybe Guice) to explicitly use my debug scope
> provider?
>
> Thanks in advance for any hints.
Re: How to handle two different scoping providers? [message #783743 is a reply to message #783734] Thu, 26 January 2012 11:11 Go to previous message
J. S. Pam is currently offline J. S. PamFriend
Messages: 3
Registered: January 2012
Junior Member
Hi,

Sebastian Zarnekow wrote on Thu, 26 January 2012 05:42
Hi,

you should never and under no circumstances use a standalone setup when
running in Eclipse. This will corrupt the emf registries and is likely
to have all sorts of unpredicatable side effects. That's why it's called
'StandaloneSetup' Wink


You're right, I should have known that Wink

Sebastian Zarnekow wrote on Thu, 26 January 2012 05:42

For now, the easiest way would be to have second language that extends
the first one and uses a dedicated file extension etc.


That looks like a great solution; I didn't think of that at all. I'll look into it, thanks!
Previous Topic:Scoping vs. (Validation + Content assist)
Next Topic:Using declarative formatter with Assignment objects
Goto Forum:
  


Current Time: Fri Apr 26 15:44:20 GMT 2024

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

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

Back to the top