Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting an Editor instance/ Resource for a Validator
Getting an Editor instance/ Resource for a Validator [message #690534] Wed, 29 June 2011 16:33 Go to next message
Timotei Mising name is currently offline Timotei Mising nameFriend
Messages: 89
Registered: March 2010
Member
Hi!

My code has some quirks, and it needs either an instance to my xtext editor or to the underlining file (as resource or string - path). Is there any way to get such information in a Validator Context? (AbstractDeclarativeValidator)

Thanks,
Re: Getting an Editor instance/ Resource for a Validator [message #690572 is a reply to message #690534] Wed, 29 June 2011 18:15 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you can ask any EObject for its Resource (along with its URI). Usually that is a good way to get at the file. Note that the validator is intended to run without the UI as well, so you there need not be an editor around.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Getting an Editor instance/ Resource for a Validator [message #691580 is a reply to message #690572] Fri, 01 July 2011 19:06 Go to previous message
Timotei Mising name is currently offline Timotei Mising nameFriend
Messages: 89
Registered: March 2010
Member
Thanks a lot.

Calling:
Resource resource = getCurrentObject().eResource();

was the thing I was searching for.

Also, if other will read this, to convert that Resource to an Eclipse IFile/IResource thingy, take a look here: http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_map_between_an_EMF_Resource_and_an_Eclipse_IFile.3F
Previous Topic:[XPAND] complexe SEPARATOR use
Next Topic:Beginner problems with simple grammar using the eclipse plugin
Goto Forum:
  


Current Time: Sat Apr 20 00:22:28 GMT 2024

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

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

Back to the top