Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How could we get XtextResource objects of the files which already opened in the editor?(How could we get XtextResource objects of the files which already opened in the editor?)
How could we get XtextResource objects of the files which already opened in the editor? [message #1700177] Tue, 30 June 2015 13:33 Go to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
How could we get XtextResource objects of the files which already opened in the editor?

What i mean is, how could we get Xtextresources after parsing them successfully, to be used in various parts in eclipse
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700178 is a reply to message #1700177] Tue, 30 June 2015 13:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
XtextEditor gives you access to xtextdocument gives you readonly (iunitofwork)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700181 is a reply to message #1700178] Tue, 30 June 2015 13:52 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Thanks for your quick reply.
Sorry i was not clear in my question.
have added group of files which were parsed successfully, My question is that i need is to pick up the Model and to use methods like Resource.getAllContents() and Resource.getErrors() , even if no files are opened in the editor
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700183 is a reply to message #1700181] Tue, 30 June 2015 14:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hI,
you said "which already opened in the editor"

what is the exact context you are executing this.

you can always load whatever you want to a resourseset org.eclipse.xtext.ui.resource.IResourceSetProvider.get(IProject)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700197 is a reply to message #1700183] Tue, 30 June 2015 15:41 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hi,
In XtextBuilder method doBuild() , this line resourceSet.getResources().clear();, which means that all the resources will be cleared after the build directly, so we will not be able to pickup the resources from the resource set, am i right?


Here is the code i tried to pick up them with

ICommand command = getCommand(project, "org.eclipse.xtext.ui.shared.xtextBuilder");
IBuildConfiguration config = project.getActiveBuildConfig();
InternalBuilder internalBuilder = ((BuildCommand) command).getBuilder(config);
IncrementalProjectBuilder incrementalProjectBuilder = (IncrementalProjectBuilder) internalBuilder;
XtextBuilder xTextBuilder = (XtextBuilder) incrementalProjectBuilder;

IResourceSetProvider provide = xTextBuilder.getResourceSetProvider();
ResourceSet resouarceSet = provide.get(project);
EList<Resource> res = resouarceSet.getResources();
int kk = res.size();

[Updated on: Tue, 30 June 2015 15:46]

Report message to a moderator

Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700199 is a reply to message #1700197] Tue, 30 June 2015 15:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Yes but why is this a problem for you. Whatdo you actually want to do

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700216 is a reply to message #1700199] Tue, 30 June 2015 20:51 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
I am trying to get the model of each file which was created by xtext after importing them inside the project, even if they are not opened in the editor
What do you think?
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700231 is a reply to message #1700216] Wed, 01 July 2015 03:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
but what do you want to do with the model?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700261 is a reply to message #1700231] Wed, 01 July 2015 10:02 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
In the project browser,I'd like to add some nodes under each file resource which represents the content of this file resource.
As an example in eclipse, by expanding the file node you will be able to see the class in this file and the functions inside this class
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700265 is a reply to message #1700261] Wed, 01 July 2015 10:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

this is not that easy since the only thing eclpse persistenly keeps are the index contents.
if all your stuff is in the index (have a look at the open model element dialog) you could use that.
if not you have to reparse


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700270 is a reply to message #1700265] Wed, 01 July 2015 11:36 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hi,
Do you think that we have another way to avoid reparse?
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1700271 is a reply to message #1700270] Wed, 01 July 2015 11:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you could use the builder (e.g. a builderparticipant) to write the infos you need as persistent properties to the ifile. and read it from there

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1702090 is a reply to message #1700271] Sun, 19 July 2015 12:31 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
So what you are saying now is that XText delete the model and resourceSet after parsing the files inside the project, and we dont have a way to extract the models of the files which got parsed

So we can not get notified after XText finished parsing the files inside the project, and can not get the model which created.
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1702091 is a reply to message #1702090] Sun, 19 July 2015 12:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi,

still the point. it depends on the usecase. if you write a builderparticipant you have access to the model.
but as long as you do not specifically tell what you want to do
i cannot give you any advice


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1702333 is a reply to message #1702091] Tue, 21 July 2015 15:31 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Here you are what i want to do specifically.
I need to be notified by xtext when it finish parsing the whole files in the project, not only that but also i need xtext to provide me with the models of the files.
Why i need all of that? , i will show the content of those files in the project browser, as an example i will show the declaration in each file in the project browser, so to perform this task i need to pick up the model and start my processing
I need to get it at the end of the build to perform my processing only one time.
is it evident now?
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1702337 is a reply to message #1702333] Tue, 21 July 2015 15:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
So why not implement this in the igenerator or an ixtextbuilderparticipant

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could we get XtextResource objects of the files which already opened in the editor? [message #1702339 is a reply to message #1702337] Tue, 21 July 2015 15:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Another option would be to use in information in the xtext index only and do not use parsed files at all

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to compile the dsl source code?
Next Topic:Dispatch methods for the label provider
Goto Forum:
  


Current Time: Tue Mar 19 03:43:26 GMT 2024

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

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

Back to the top