Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross Reference(Lazy linking)
Cross Reference(Lazy linking) [message #902942] Tue, 21 August 2012 10:43 Go to next message
Necip Karakas is currently offline Necip KarakasFriend
Messages: 4
Registered: March 2012
Junior Member
Hi,
In my dsl I have a cross reference between files and the references between files are sometimes not working. The Lazy linking doesn't return "sometimes" the objects on demand, therefore I have to explicitly resolve the proxy in scopeprovider. Is there another way to solve this problem?

List<Composite> composites = new ArrayList<Composite>();
if (context.getScreenType().eIsProxy()) {
EObject e = EcoreUtil2.resolve(context.getScreenType(), new ResourceSetImpl());
composites = EcoreUtil2.eAllOfType(e, Composite.class);
}
IScope result1 = MapBasedScope.createScope(IScope.NULLSCOPE, Scopes.scopedElementsFor(composites));
return result1;


And my dsl looks like:
Model:
(screenType=ScreenType | fbType=FbType);

ScreenType:
"screenType" name=ID
screen=Screen;

Screen:
"screen" name=STRING "{"
(rootComposite=Composite)?
"}";
Composite:
{Composite}
"composite" (name=ID)? "{"
composites+=Composite*
"}";
FbType:
(faceplateInstances+=FaceplateInstance)*;

FaceplateInstance:
"faceplateInstance" name=STRING "{"
"on screenType" screenType=[ScreenType|QualifiedName]
"in composite" composite=[Composite|QualifiedName]
Re: Cross Reference(Lazy linking) [message #903000 is a reply to message #902942] Tue, 21 August 2012 15:02 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
It is not a good idea to resolve proxies as this is a heavy operation
that may involve loading/parsing/linking resources - and you may end up
with everything referencesable in memory.

It is far better to work with the index / resource descriptions; make
sure everything you want to reference is in the index, and look up using
names/types and EObjectDescriptions.

It seems you want to find all Composite instances inside a ScreenType
and you do have a reference to the screen type in some other resource.
Armed with the proxy you should be able to get the ResourceDescription
of the target, and there are several "getExportedBy..." methods in
IResourceDescriptions that should be able to help you.

Regards
- henrik

On 2012-21-08 12:43, Necip Karakas wrote:
> Hi,
> In my dsl I have a cross reference between files and the references
> between files are sometimes not working. The Lazy linking doesn't return
> "sometimes" the objects on demand, therefore I have to explicitly
> resolve the proxy in scopeprovider. Is there another way to solve this
> problem?
>
> List<Composite> composites = new ArrayList<Composite>();
> if (context.getScreenType().eIsProxy()) {
> EObject e = EcoreUtil2.resolve(context.getScreenType(), new
> ResourceSetImpl());
> composites = EcoreUtil2.eAllOfType(e, Composite.class);
> }
> IScope result1 = MapBasedScope.createScope(IScope.NULLSCOPE,
> Scopes.scopedElementsFor(composites));
> return result1;
>
> And my dsl looks like:
> Model:
> (screenType=ScreenType | fbType=FbType);
>
> ScreenType:
> "screenType" name=ID
> screen=Screen;
>
> Screen:
> "screen" name=STRING "{"
> (rootComposite=Composite)?
> "}";
> Composite:
> {Composite}
> "composite" (name=ID)? "{"
> composites+=Composite*
> "}";
> FbType:
> (faceplateInstances+=FaceplateInstance)*;
>
> FaceplateInstance:
> "faceplateInstance" name=STRING "{"
> "on screenType" screenType=[ScreenType|QualifiedName] "in
> composite" composite=[Composite|QualifiedName]
>
Re: Cross Reference(Lazy linking) [message #903009 is a reply to message #903000] Tue, 21 August 2012 15:32 Go to previous messageGo to next message
Necip Karakas is currently offline Necip KarakasFriend
Messages: 4
Registered: March 2012
Junior Member
Hi Henrik,
Thanks for your help. You are right about what I am trying to do.
But my main problem is, even if I dont resolve the proxies heavily as I mentioned, it kind of resolves the references(it appears no problem in Eclipse) but the content assist not working and sometimes it is working completely.
I do not understand the inconsistency of Xtext at resolving proxies. Therefore I thought that something is missing in my grammar.
Re: Cross Reference(Lazy linking) [message #903035 is a reply to message #903009] Tue, 21 August 2012 17:32 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-21-08 17:32, Necip Karakas wrote:
> Hi Henrik,
> Thanks for your help. You are right about what I am trying to do. But my
> main problem is, even if I dont resolve the proxies heavily as I
> mentioned, it kind of resolves the references(it appears no problem in
> Eclipse) but the content assist not working and sometimes it is working
> completely. I do not understand the inconsistency of Xtext at resolving
> proxies. Therefore I thought that something is missing in my grammar.

Nope, it depends on build order, caches, units of work executed, lazy
linking, if you are looking at a possibly dirty resource (in the
editor), if the other resource is dirty, or not etc.

Use of index should be good for this kind of thing.

- henrik
Previous Topic:How can I customize the Preference Pages?
Next Topic:Use Xtend instead of Java in more places in the generated DSL implementation
Goto Forum:
  


Current Time: Thu Apr 25 06:49:44 GMT 2024

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

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

Back to the top