Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Proxy Resolution issue (ResoureSet related? IResourceSetProvider how to?)
Proxy Resolution issue (ResoureSet related? IResourceSetProvider how to?) [message #965035] Wed, 31 October 2012 00:36 Go to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Hello,

How do ResoureSets work in Xtext, and what can cause / where to look if cross resource reference resolution does not work from code outside Xtext (but works in the Xtext Editor), and one suspects it might have something to do with incorrect ResoureSet creation outside of Xtext?

We have legacy code using some sort of helper infrastructure which, given an IProject, can return a ResourceSet; this and code using it predates the introduction of Xtext in our product. There are problems which we traced to the Resources returned by the ResourceSet returned by this helper infrastructure not resolving cross-resource proxies. [Pure Xtext, in an XtextEditor which does not use the legacy helper, appears to resolve cross references just fine, e.g. we CAN F3/Ctrl-Click on references to navigate between resources in the Editor, and the Navigate > Open Model Element (Ctrl-Shift-F3) shows that indexing worked.]

Now, this helper originally associated a (non Xtext) ResourceSetImpl with an IProject. This ResourceSet was created only once and then fixed for the IProject. The new ResourceSetImpl() seemed wrong, so we replaced it with a "new SynchronizedXtextResourceSet()", still created new once per IProject, but this still doesn't fix the unresolved proxy resolution problem... I saw the org.eclipse.xtext.ui.resource.IResourceSetProvider which looks kind of suitable in this context, but..

a) from what I can tell and understand of Guice, this ultimately won't do anything different than a new SynchronizedXtextResourceSet(), as the get() on Provider<XtextResourceSet> in XtextResourceSetProvider will just return a new XtextResourceSet implementation, as defined in the org.eclipse.xtext.service.DefaultRuntimeModule? As XtextResourceSetProvider doesn't get anything else than XtextResourceSet @Inject'd, what is so different if you create it yourself? I'm probably missing something here - apologies if this outs me as a Guice ignoramus! Wink

b) if I misunderstand this and really should use an injected IResourceSetProvider to get to the ResourceSet from an IProject in that legacy helper, then... how? I understand you can get an Injector from an Activator, BUT that infrastructure is not specific to any Xtext language (there are several in this product) and is "lower" in our architecture than the language bundles... how would you look up "the" (language agnostic) IResourceSetProvider?

c) Minor: IResourceSetProvider is in xtext.ui, while this should work headless for us as well.

Appreciate any help - thanks a lot!
Re: Proxy Resolution issue (ResoureSet related? IResourceSetProvider how to?) [message #965456 is a reply to message #965035] Wed, 31 October 2012 08:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

are you running in IDE or Standalone ?
if you are in the ide you have for (a) to feed the resourceset with all resources yourself.
if you are not you have to do it anyway.

for b:

you could build an activator / execxutablextensionfactory (this is used to inject things in views, handlers etc - i have no idea what you are actually doing)
http://kthoms.wordpress.com/2011/09/28/moving-an-xtend-generator-into-its-own-plugin/ might give some hints.



for c:

still the question: standalone or ui - maybe you have to find two solutions.

and dont forget:
never call the standalone setup from OSGi environment


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Proxy Resolution issue (ResoureSet related? IResourceSetProvider how to?) [message #965666 is a reply to message #965456] Wed, 31 October 2012 12:16 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Hi,

This is in-IDE (focus for now, it also needs to work standalone once complete; but that's a separate product build which we configure differently). I know what you mean, we did have problems with accidentally using standalone setup from the IDE, but I'm reasonably confident that's not the case anymore in the problems faced now.

Would you be able to elaborate a little re. "you have for (a) to feed the ResourceSet with all resources yourself" ? Surely there is some Hogwarts magic Wink in place which, if correctly configured and plumbed together by Guice, resolves references across Resources by looking up their QualifiedName in the global index etc. From the little I understand of Xtext's internals, that "magic" is what org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(String) & org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(EObject, EReference, INode) and the whole Scope stuff is for?

If that's not the way it works then we completely misunderstood how the lazy loading works... if that were the case, how do you know upfront which Resources to add to the ResourceSet?! After all, the Xtext Editor can resolve and F3/Ctrl-Click on references to navigate between resources - without ALL resources having been added to the ResourceSet somewhere - right?

Thanks for the pointer to /moving-an-xtend-generator-into-its-own-plugin/ - I... kind of see how you could use this to get an Injector, but Sven's comment on http://kthoms.wordpress.com/2011/09/28/moving-an-xtend-generator-into-its-own-plugin/#comment-659 ("... means that singletons will exist twice...") has me concerns if the lookup of stuff in the Index would work like this?

Much appreciate if anybody has further thoughts how we may able to progress towards solving this!
Re: Proxy Resolution issue (ResoureSet related? IResourceSetProvider how to?) [message #965673 is a reply to message #965666] Wed, 31 October 2012 12:20 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

is short: in eclipse the global scope in done on Projects. thus you need the IResourceSetProvider.
you can ask guice for it. karsten showed how to build an ExecutableExtensionFactory. this is needed if you want to use guice in an eclipse environment.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Standalone Xtend2
Next Topic:Bringing Xtext (or parts of it) to the web
Goto Forum:
  


Current Time: Fri Apr 19 13:43:59 GMT 2024

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

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

Back to the top