Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » navigating through an importURI statement
navigating through an importURI statement [message #676828] Mon, 06 June 2011 16:32 Go to next message
Daniel Le Berre is currently offline Daniel Le BerreFriend
Messages: 82
Registered: July 2009
Member
I really like the navigation available in the editor produced by Xtext.

There is however one thing that I miss: the possibility to access directly a file pointed out by an importURI statement.

i.e. I have one statement like

open path/to/my/file

that is managed in our grammar using an importURI,
and I would like to be able to click on it to open that file.

Is it possible with Xtext 1.0.2?
Re: navigating through an importURI statement [message #676876 is a reply to message #676828] Mon, 06 June 2011 19:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Daniel, you have to Implement a custom HyperlinkHelper.
	@Override
	public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
		super.createHyperlinksByOffset(resource, offset, acceptor);
		TextLocation loc = new TextLocation();
		EObject eObject = EObjectAtOffsetHelper.resolveElementAt(resource, offset, loc);
//check if eObject is an Import
//get the uri
//create the hyperlink
}

Let you inspire by the code of
org.eclipse.xtext.example.ui.navigation.DomainmodelHyperlinkHelper
org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: navigating through an importURI statement [message #676880 is a reply to message #676876] Mon, 06 June 2011 20:06 Go to previous messageGo to next message
Daniel Le Berre is currently offline Daniel Le BerreFriend
Messages: 82
Registered: July 2009
Member
Thanks for the tip Christian.

We will take a look at it.

Looks like you guys thought about everything Smile
Re: navigating through an importURI statement [message #677157 is a reply to message #676880] Tue, 07 June 2011 18:20 Go to previous message
Daniel Le Berre is currently offline Daniel Le BerreFriend
Messages: 82
Registered: July 2009
Member
Hi Christian,

We got it working:
http://code.google.com/p/alloy4eclipse/source/detail?r=1067

The editor is so nice now Smile

Thanks again for your help.

Daniel
Previous Topic:Inheritance in XText
Next Topic:Problem generating in Xtext 2.0
Goto Forum:
  


Current Time: Thu Apr 18 05:04:21 GMT 2024

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

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

Back to the top