Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » scoping.ImportURIScopingFragment in new generator?
scoping.ImportURIScopingFragment in new generator? [message #1760330] Wed, 26 April 2017 01:51 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I need to add an import statement to my grammar so I can import an ecore model and make cross references to it from my DSL. Google results show I need to use the importURI "magic string" and include scoping.ImportURIScopingFragment in my generator.

I have made "old generator" examples work at home (modifying fowler DSL), now I'm ready to take my experience into the real world at work... but.... (record needle scratching sound)

1) I can't figure out how to do fragment = scoping.ImportURIScopingFragement in the new generator. I have imported org.eclipse.xtext.generator.scoping, the old one, but it doesn't seem to resolve.
2) The Xtext book doesn't mention importURI anywhere. Either version.
3) I can't seem to find a search hit on importURI on the online Xtext documentation
4) Docs I've been able to find on the new generator say "use autocomplete to find your way".

So I'm left with a "new generator" project that doesn't understand the magic importURI string in my grammar.

How does one do this? I'd rather the answer not be "convert your entire project to the old generator".

Is there a new way to do this in 2.10 and I'm just doing it wrong?

[Updated on: Wed, 26 April 2017 01:52]

Report message to a moderator

Re: scoping.ImportURIScopingFragment in new generator? [message #1760331 is a reply to message #1760330] Wed, 26 April 2017 02:24 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Darn. I think you've answer it here: https://www.eclipse.org/forums/index.php?t=msg&th=1078818&goto=1736351&#msg_1736351

The old way was so simple even an idiot like myself could understand it and make it work. That thread linked above hurts my head.
Re: scoping.ImportURIScopingFragment in new generator? [message #1760332 is a reply to message #1760331] Wed, 26 April 2017 02:37 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
This worked on the home example (taken from the linked example above which was extracted from a bugzilla referenced in that thread):

fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
fragment = org.eclipse.xtext.generator.scoping.ImportURIScopingFragment {}
}

I'll try it at work tomorrow. Initially it doesn't seem to mark errors on the import statement the way the results from the old generator did if the import statement can't find the file (which was helpful).
Re: scoping.ImportURIScopingFragment in new generator? [message #1760338 is a reply to message #1760332] Wed, 26 April 2017 05:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Have a look at

https://bugs.eclipse.org/bugs/show_bug.cgi?id=491110

Regarding the second question
There is no magic. You have to tell Xtext to validate the Uris

composedCheck = "org.eclipse.xtext.validation.ImportUriValidator


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: scoping.ImportURIScopingFragment in new generator? [message #1760519 is a reply to message #1760338] Fri, 28 April 2017 03:17 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Thanks Christian. I got the basic importURI stuff working with you helpful link and I tested it with files from my DSL and it seems to work as expected.

I'm now moving onto my next part which is importing a file that is an EMF model stored in an XML file. For this task, I've run into the IResourceServiceProvider issue. I see you've documented an example of how to solve this issue here: https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/

I've implemented most of that example, but I think I'm missing something in the proper registration of my newly created stuff, because my first attempt isn't working just yet. The example uml link specifies several additions to the mwe workflow using the old style. Is there also a simple conversion of your old style mwe additions for the new style mwe generator? The lengthy uriMap stuff and the registerGeneratedEPackage, I'm assuming these have been replaced with referencedResource = style in the new generator. But this assumption may be key to why things aren't working for me yet.

Re: scoping.ImportURIScopingFragment in new generator? [message #1760526 is a reply to message #1760519] Fri, 28 April 2017 06:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
i cannot answer this question without any error messages or anything.

Ususally just having

referencedResource="platform:/resource/project/path/xxx.genmodel"

should be fine

depending on the contents you may need additinally a uri mapping with standalonesetup


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: scoping.ImportURIScopingFragment in new generator? [message #1760580 is a reply to message #1760526] Fri, 28 April 2017 15:11 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Oh... I'm having some basic issue with finding the IResourceServiceProvider I've made based on your link.

I've traced through all my company.app.ui.ipx stuff that was copied from your link and it all seems to be working, but ultimately, once I import my *.xml file, I get the dreaded:

java.lang.IllegalStateException: No IResourceServiceProvider found in registry for uri myOtherModel.xml,

Somehow I'm continuing to get a null IResourceServiceProvider. I've done something stupid somewhere. I'm just having trouble debugging it because it looks like all the company.app.ui.ipx stuff is being called: Activator, guice injector etc... but when it counts, a null IResourceServiceProvider is being returned and that just breaks everything the moment I uncomment my xml import.

I think I see the binder working because I see this in the list:

But I do see an error:

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.eclipse.jface.viewers.ILabelProvider annotated with @org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider() was bound.
while locating org.eclipse.jface.viewers.ILabelProvider annotated with @org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider()
for field at org.eclipse.xtext.ui.resource.DefaultResourceUIServiceProvider.descriptionLabelProvider(Unknown Source)
while locating org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider

1 error

1 error ExtensionFactory: company.app.ui.ipx.ExecutableExtensionFactory

Re: scoping.ImportURIScopingFragment in new generator? [message #1760581 is a reply to message #1760580] Fri, 28 April 2017 15:14 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
One thing I don't understand about the Runtime module I've created is what getLanguageName() is doing. In your example, it looks like you're returning an editor name:

@Override
protected String getLanguageName() {
return "org.eclipse.uml2.uml.editor.presentation.UMLEditorID";
}

For the moment I'm just trying to tie in the default text editor for my imported xml file. But I don't understand why getLanguageName would return the name of an editor?
Re: scoping.ImportURIScopingFragment in new generator? [message #1760583 is a reply to message #1760581] Fri, 28 April 2017 15:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Cause there is some magic in downstream components

*UriEditorOpener that make use of this id


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: scoping.ImportURIScopingFragment in new generator? [message #1760586 is a reply to message #1760583] Fri, 28 April 2017 15:40 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
So I've tried to return the default ecore reflective editor in place of my getLanguageName(). I seemed to get much further - i.e. I had to trace through a bunch of code I'd never seen up to this point, but ultimately, I wind up with the same error:

1 [Worker-10] ERROR company.app.ui.ipx.ExecutableExtensionFactory - Guice configuration errors:

1) No implementation for org.eclipse.jface.viewers.ILabelProvider annotated with @org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider() was bound.
while locating org.eclipse.jface.viewers.ILabelProvider annotated with @org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider()
for field at org.eclipse.xtext.ui.resource.DefaultResourceUIServiceProvider.descriptionLabelProvider(Unknown Source)
while locating org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider

@Override
protected String getLanguageName() {
return "org.eclipse.emf.ecore.presentation.ReflectiveEditorID";
}


FWIW, I'm able to open my XML file with the "Sample Reflective Ecore Model Editor" and that would be fine for my purposes.
Re: scoping.ImportURIScopingFragment in new generator? [message #1760593 is a reply to message #1760586] Fri, 28 April 2017 17:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
well that wont work =>

mmmm vgl org.eclipse.xtext.ui.resource.generic.EmfUiModule

public void configureResourceUIServiceLabelProvider(com.google.inject.Binder binder) {
binder.bind(org.eclipse.jface.viewers.ILabelProvider.class).annotatedWith(org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider.class).to(AdapterFactoryDescriptionLabelProvider.class);
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: scoping.ImportURIScopingFragment in new generator? [message #1760601 is a reply to message #1760586] Fri, 28 April 2017 18:41 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I think I just got it working. Somehow in my IpxUiModule, I had overridden an extra method: I was supposed to just @Override configureLanguageSpecificURIEditorOpener, but by accident I was also @Overridding configure(Binder binder) {. Once I commented out that extra override, it worked!

Thanks so much for your helpful blog and your response to others on similar threads.

[Updated on: Fri, 28 April 2017 20:18]

Report message to a moderator

Previous Topic:Xtext templates
Next Topic:Parsing Problem: Colon and negative number
Goto Forum:
  


Current Time: Tue Dec 10 05:23:57 GMT 2024

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

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

Back to the top