Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » is it possible to add link for EObject in XtextBuilderParticipant class(is it possible to add link for EObject in XtextBuilderParticipant class)
is it possible to add link for EObject in XtextBuilderParticipant class [message #1712748] Tue, 27 October 2015 21:23 Go to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Grammer :

alias returns XTAlias:
------------------------------------------------
declaration returns XTDeclaration:
'declaration' decl=[XTAlias]
'end' 'declaration;'
;
------------------------------------------------

This is what i wrote in the editor :
in File1
-------------
declaration ABC
end declaration;
-----------------------
in File2
-----------
alias ABC;
-----------------------
lets say that declaration "ABC" is not linked (i dont want to link it through scoping class) and i'd like to link it in XtextBuilderParticipant class.

I have EOBject represents the declaration and another EObject represents the alias.

Then i used the code below to perform this task
XTAlias alias;
XTDeclaration decl;
decl.setAlias(alias);
-------------------------------------------------------
But it did not work, as i still have error in the editor on declaration "ABC"

is it possible to add the link in XtextBuilderParticipant , and if its possible how could i achieve this?



Thanks
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712770 is a reply to message #1712748] Wed, 28 October 2015 08:04 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Kimi,

I don't understand why you don't want to create the link through linking/scoping. Could you please elaborate on that?

Just calling a setter in the builder participant won't do anything. The builder participant is called for code generation only.
Cheers,
Stefan

[Updated on: Wed, 28 October 2015 08:10]

Report message to a moderator

Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712787 is a reply to message #1712770] Wed, 28 October 2015 09:21 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hi Stefan,

I just want to link the EOBject after having complete view on files in the project, if i created the link in scoping phase, i would still dont have the complete view.
i just want to link certain EObjects in a step after passing through all my files and create links.

Example:
If we have 3 files
file1 : contains declaration ABC end declaration;
file2 : contains alias ABC;
file3 : contains alias ABC;
I want to choose which alias i will create a link with, and to be able to do that i should finished scoping phase for all those files then start to link the declaration ABC with one of the two aliases based on my conditions

Thanks

[Updated on: Wed, 28 October 2015 09:22]

Report message to a moderator

Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712792 is a reply to message #1712787] Wed, 28 October 2015 09:48 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Kimi,

what do you mean by "complete view on the files"? The indexing is done when your scope provider is called, so you can access index information about all elements.

You can put the information you need in the index and use it for your scope provider rules.

Cheers,
Stefan
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712795 is a reply to message #1712792] Wed, 28 October 2015 10:17 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
After finish scoping and linking on all my files, i want to go over unresolved EOBjects in some files and link them manually
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712796 is a reply to message #1712795] Wed, 28 October 2015 10:19 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Why don't you implement the scoping logic so that it works in the first place?
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712799 is a reply to message #1712796] Wed, 28 October 2015 10:34 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
i do implement scoping logic but the issue is that i want to make another loop over unresolved objects and link them after finishing scoping phase
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712803 is a reply to message #1712799] Wed, 28 October 2015 10:55 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Those lines also does not fix the problem :
DeclarationR.eSetDeliver(false);
DeclarationR.eSet(DSLPackage.eINSTANCE.getXTDeclaration_AliasName(), alias);
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712812 is a reply to message #1712803] Wed, 28 October 2015 12:21 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Why do you want another loop? What is your use case? Please explain why you can't do it in the scope provider.
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712840 is a reply to message #1712812] Wed, 28 October 2015 16:32 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
if file1 depends on objects in file2 and file3 , are we sure that file 2 and file3 objects will be linked in scoping before file1 ?
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712890 is a reply to message #1712840] Thu, 29 October 2015 08:35 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Linking works lazily as you traverse the model. But you generally shouldn't traverse other models, as that will lead to costly IO.

Instead, put the necessary information in the Index (IDefaultResourceDescriptionStrategy) and then use that information in the scope provider.
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712912 is a reply to message #1712890] Thu, 29 October 2015 10:19 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hi Stefan,
What you are saying is that before start scoping phase, all objects in all files which may be used in cross reference are stored in IDefaultResourceDescriptionStrategy to be used in scoping phase
right ?
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712917 is a reply to message #1712912] Thu, 29 October 2015 10:48 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Kimi,

not the objects themselves, but so called EObjectDescriptions. You can attach additional information to these descriptions in the ResourceDescriptionStrategy.

Have a look at the scoping chapter in the documentation for more pointers: https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping

Cheers,
Stefan
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712955 is a reply to message #1712917] Thu, 29 October 2015 14:43 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hi Stefan,
Thanks for your recommendations
Moving on your steps will require a lot of checks to be done to finish what i exactly need.
So is it possible to handling some linking of eobjects in a place after finish linking on all the available resources?

Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712958 is a reply to message #1712955] Thu, 29 October 2015 14:57 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Kimi,

Xtext does not load your whole workspace into memory. That would be a huge performance problem. Xtext only loads the current resource you are editing and the resources that you link to. If you want to ask questions about "the world", you do so via the Xtext index.

From what I understand, you need some information about the aliases in the index. Then you can use that information to make your decisions in the scope provider.

If that is not accurate, please explain your use case in more detail.

Cheers,
Stefan

[Updated on: Thu, 29 October 2015 14:58]

Report message to a moderator

Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712969 is a reply to message #1712958] Thu, 29 October 2015 16:47 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
i am not asking about the "world"
Index info will not help me, i just want to add a link to EObject and get reflect this change on Node model, may be in ClusteringBuilderState or in another location after resolving all the files.
So the question is , is it possible?
if Yes then how ?
Thanks
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712972 is a reply to message #1712969] Thu, 29 October 2015 17:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
hi,

can you please explain your usecase by an example grammar and model what you actually want to do.
it is hard to help without knowing the usecase.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1712999 is a reply to message #1712972] Thu, 29 October 2015 18:44 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
-------------- Grammar ----------------------
container_rule returns XTContainer:
'container' name=ID
'declaration' decl=[XTTarget]
'end;'
;

alias_rule returns XTAlias:
'alias' name=ID 'belongto' container=[XTContainer] 'is'
'bind' declaration=[XTDeclaration] target=[XTTarget]
'end;'
;

target_rule returns XTTarget:
'target' name=ID
'end;'
;
-----------------------------------------------

example :
-----------------
File 1:
-----------
target tar1
end;

target tar2
end;
-----------------
File 2:
-----------
container cont
declaration decl1;
end;
------------------
File 3:
-----------
alias dAlias1 belongto cont is
bind decl1 tar1;
end;

alias dAlias2 belongto cont is
bind decl1 tar2;
end;
-------------------

In this example i am trying to bind decl1 to (tar1 or tar2) using the aliases, of course i will bind it to only one of them based on which one of aliases i will use, and the selection of the alias will be based on the alphabet of the aliases (i mean only one alias will win and i will use it in binding)
My thoughts was finish scoping phase for file1 and file2 and file3 without binding declaration "decl1" to anything, after that try to bind it in later step, after resolving all links in the other files, as i will be able to get aliases of "cont" and choose between them, then bind declaration "decl1".
I think this is the easiest way to solve this problem

Note : currently i put all those components to exported objects to be able to use them in linking
Hope that the problem is clear now
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713000 is a reply to message #1712999] Thu, 29 October 2015 18:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
and where do you use the aliases?
and which is there reference you want to scope?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713002 is a reply to message #1713000] Thu, 29 October 2015 19:09 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
i use alias in file3 as in the example.
Aliases are used to find reference for declaration in container "cont"
As in the example i have two aliases for container "cont"
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713003 is a reply to message #1713002] Thu, 29 October 2015 19:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
but i dont get the semantics?

is it about this reference?

container_rule returns XTContainer:
'container' name=ID
'declaration' decl=[XTTarget]
'end;'
;

but if there are two bindings named decl1 which one wins?

besides this

if you index the binding you can encode container name, decl name and target name to the index.
this information you can use to query the visible targets from the global scope
and give them aliases


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713004 is a reply to message #1713003] Thu, 29 October 2015 19:28 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Aliases are used to bind declarations to targets
each contains should select only one alias as a winner.

"decl1" will be bound based on the info in the winner alias

what do you mean by "you can encode container name, decl name and target name to the index".
Do you mean to add them to exported objects from the resource?
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713006 is a reply to message #1713004] Thu, 29 October 2015 19:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Sry i dont get your semantics so stick with your current solution

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713007 is a reply to message #1713006] Thu, 29 October 2015 19:43 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
my current solution as i said is updating the emf after scoping phase, but updating the emf doesnot reflect on node model

[Updated on: Thu, 29 October 2015 19:43]

Report message to a moderator

Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713009 is a reply to message #1713007] Thu, 29 October 2015 19:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
you can adapt your defaultresourcedescription strategy to add stuff to the user data of the eobjectdescriptions.
you can obtain the stuff without relying on the linked model using nodemodelutils.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713010 is a reply to message #1713009] Thu, 29 October 2015 19:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
and still the question: your example model has two aliases for the same cont.
which one will win


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713011 is a reply to message #1713010] Thu, 29 October 2015 19:53 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
the winner will be based on the name of the alias (alphabetically)
example
Alias xyz
Alias abc
abc will win.
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713013 is a reply to message #1713011] Thu, 29 October 2015 19:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
ok that should work then

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713014 is a reply to message #1713013] Thu, 29 October 2015 19:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
p.s. simply play around with naming and or userdata of the eobjectdescriptions for XTAlias

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713015 is a reply to message #1713013] Thu, 29 October 2015 20:00 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
sorry i did not get your answer
Re: is it possible to add link for EObject in XtextBuilderParticipant class [message #1713017 is a reply to message #1713015] Thu, 29 October 2015 20:14 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
sry i dont have the time to do your task.

imagine the following can can ask the index for aliases an get this list:

(user data way)
- dAlias1 [cont:cont,decl=decl1,target=tar1]
- dAlias2 [cont:cont,decl=decl1,target=tar2]
(name way)
- dAlias1.cont.decl1.tar1
- dAlias2.cont.decl1.tar2

based on this information you know you query the index for target tar2 and give it the alias decl1


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Updating emf does not reflect on Node model
Next Topic:Strange editor redraw problem
Goto Forum:
  


Current Time: Mon Sep 23 18:24:49 GMT 2024

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

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

Back to the top