Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » F3 linking(Problem with opening another file with F3)
F3 linking [message #644669] Mon, 13 December 2010 17:22 Go to next message
Eisfeld Andrej is currently offline Eisfeld AndrejFriend
Messages: 3
Registered: December 2010
Junior Member
Heyy guys,

I'm new to Xtext and try to achieve the following:

Can I have a cross-reference to another file like in C++ and open it by pressing F3.
I've read a lot of postings in this forum but didn't find anything which could help me with this issue. My files:

test.abc:
#include <referenced.abc>
signal GROUND 0


referenced.abc:
signal VDD 5



My grammar so far:
QualifiedName:
	ID ('.' ID)*;

IncludeDirective:
	'#include' ( ( '<' importURI=QualifiedName '>' ) | ( importURI=STRING ) );
Signal:
        'signal' name=ID voltage=INT;


Xtext recognizes that there is a file called "referenced.abc" but if I press F3 nothing happens Confused
I can't use the usual reference mechanism ( [...] ) because ( I think ) there is no EObject for a file.

Can I somehow solve the problem with the importURI or is there another mechanism
( write an own Hyperlinker, introduce somehow an EObject for files ... )

Any idea??

kind regards

Andy
Re: F3 linking [message #644759 is a reply to message #644669] Tue, 14 December 2010 07:28 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Andy,

you may want to look at
HyperlinkHelper.createHyperlinksByOffset(XtextResource, int,
IHyperlinkAcceptor) and provide an hyperlink that navigates to the
referenced file.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 13.12.10 18:22, schrieb Eisfeld Andrej:
> Heyy guys,
>
> I'm new to Xtext and try to achieve the following:
>
> Can I have a cross-reference to another file like in C++ and open it by
> pressing F3.
> I've read a lot of postings in this forum but didn't find anything which
> could help me with this issue. My files:
>
> test.abc:
>
> #include <referenced.abc>
> signal GROUND 0
>
>
> referenced.abc:
>
> signal VDD 5
>
>
>
> My grammar so far:
>
> QualifiedName:
> ID ('.' ID)*;
>
> IncludeDirective:
> '#include' ( ( '<' importURI=QualifiedName '>' ) | ( importURI=STRING ) );
> Signal:
> 'signal' name=ID voltage=INT;
>
>
> Xtext recognizes that there is a file called "referenced.abc" but if I
> press F3 nothing happens :? I can't use the usual reference mechanism (
> [...] ) because ( I think ) there is no EObject for a file.
>
> Can I somehow solve the problem with the importURI or is there another
> mechanism
> ( write an own Hyperlinker, introduce somehow an EObject for files ... )
>
> Any idea??
>
> kind regards
>
> Andy
Re: F3 linking [message #644772 is a reply to message #644759] Tue, 14 December 2010 08:27 Go to previous message
Eisfeld Andrej is currently offline Eisfeld AndrejFriend
Messages: 3
Registered: December 2010
Junior Member
Hi Sebastian,

Thank you for your quick answer. I also tried this but ran into two problems.

Is there a node for the file in the parseTree and if yes how can I get the URI of this file ( do I need the URI for a hyperlink?? ).

The other thing is how can I get the importURI attribute from the IncludeDirective.
I have the EObject but can't call the getter-method of this attribute directly ( do I need the attribute to find the file?? )

public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
	TextLocation textLocation = new TextLocation();
	EObject eObject = EObjectAtOffsetHelper.resolveElementAt(resource,  offset, textLocation);

        if ( eObject instanceof IncludeDirective ) {
                // get the importURI
                // navigate through the parseTree		
	        if (eObject != null /*&& !eObject.eIsProxy()*/) {
		       Region region = new Region(textLocation.getOffset(), textLocation.getLength());
		       createHyperlinksTo(resource, region, eObject, acceptor);
                }
	}
}

[Updated on: Tue, 14 December 2010 09:18]

Report message to a moderator

Previous Topic:newbie question
Next Topic:JavaValidator isn't called in mwe workflow
Goto Forum:
  


Current Time: Fri Apr 26 13:37:38 GMT 2024

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

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

Back to the top