Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xbase][Eclipse] Open Type on generated source link to the DSL source
[Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1659001] Sun, 08 March 2015 16:22 Go to next message
Anthony Ferrando is currently offline Anthony FerrandoFriend
Messages: 4
Registered: March 2015
Junior Member
Hi,

I am working on a project using Xbase, the generated plugins are used in the Eclipse IDE.

In this particular project, one DSL generates multiple java sources (5 - 50) that are then used by other non-generated java sources.
I would like to link to the generated java sources instead of the DSL when I follow an hyperlink (ctrl+click on a class/method in a java source), Open Type (ctrl+shift+T), debug, etc...

It seems that sources generated with IFileSystemAccess#generateFile() link properly, but all the sources that are generated with the JvmModelInferrer link to the DSL.

Is there a way to disable this feature and always link to the generated java sources?

Thank you for your help,
Anthony
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1661149 is a reply to message #1659001] Mon, 09 March 2015 13:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
Hi,

have a look at DerivedMemberAwareEditorOpener


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671069 is a reply to message #1661149] Fri, 13 March 2015 12:58 Go to previous messageGo to next message
Anthony Ferrando is currently offline Anthony FerrandoFriend
Messages: 4
Registered: March 2015
Junior Member
Thanks!

I tried to bind IURIEditorOpener to my subclass of DerivedMemberAwareEditorOpener, but none of the methods in there gets called.

It seems that it fails before that:
I generate java classes from a DSL located in different project (my projects are the following: xxx.project.dsl, xxx.project.client, xxx.project.server, xxx.project.common), all the DSLs are in the dsl project and generate classes in the common, client and server project.
When I try to access a generated class (via Open Type or ctrl+click on a link), it fails because eclipse is trying to look for the DSL in the project of the generated class rather than in the DSL project.

Somehow it fails before event calling IURIEditorOpener (even if my bindIURIEditorOpener () method is called)...

It looks like the binding to the URI of the DSL is done before, i assume I should update this?

Thanks a lot for your help,
Anthony
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671079 is a reply to message #1671069] Fri, 13 March 2015 13:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
HI,

this makes no sense to me at all. here is the code xbase uses by default (taken from xtext 2.8.0)

public class DerivedMemberAwareEditorOpener extends LanguageSpecificURIEditorOpener implements IDerivedMemberAwareEditorOpener{

	@Inject
	private IJvmModelAssociations associations;
	
	@Override
	public IEditorPart open(URI uri, IMember member, boolean select) {
		if (member != null) {
			URI memberURI = new TypeURIHelper().getFullURI(member);
			String identifier = memberURI.fragment();
			URI uriWithQuery = uri.appendQuery(identifier);
			super.open(uriWithQuery, select);
		}
		return open(uri, select);
	}
	
	@Override
	protected EObject findEObjectByURI(URI uri, XtextResource resource) {
		if (uri.query() != null) {
			String identifier = uri.query();
			TreeIterator<EObject> contents = EcoreUtil.<EObject>getAllContents(resource, true);
			while(contents.hasNext()) {
				EObject content = contents.next();
				if (content instanceof JvmMember) {
					String identifierFromResource = ((JvmIdentifiableElement) content).getIdentifier();
					if (identifier.equals(identifierFromResource)) {
						EObject sourceElement = associations.getPrimarySourceElement(content);
						return sourceElement;
					}
				}
			}
		}
		return super.findEObjectByURI(uri, resource);
	}

}


it is bound like

public void configureLanguageSpecificURIEditorOpener(com.google.inject.Binder binder) {
		if (org.eclipse.ui.PlatformUI.isWorkbenchRunning()) { 
			binder.bind(org.eclipse.xtext.ui.editor.IURIEditorOpener.class).annotatedWith(org.eclipse.xtext.ui.LanguageSpecific.class).to(org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener.class); 
			binder.bind(org.eclipse.xtext.common.types.ui.navigation.IDerivedMemberAwareEditorOpener.class).to(org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener.class); 
		};
	}



this method should be overriden in the XXXUiModule


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671080 is a reply to message #1671079] Fri, 13 March 2015 13:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
P.S: you may have a look at XbaseHyperLinkHelper as well

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671112 is a reply to message #1671080] Fri, 13 March 2015 13:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
Btw the xtend editor in 280 has ab action to get to the generated code. You may digg into that as well

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671126 is a reply to message #1671112] Fri, 13 March 2015 13:25 Go to previous messageGo to next message
Anthony Ferrando is currently offline Anthony FerrandoFriend
Messages: 4
Registered: March 2015
Junior Member
Thank you,

I am still running on xtext 2.7.3, I will try to update it now, maybe this code has been changed in the meanwhile...

I will also have a look at your other suggestions and see if I can understand how all of this works.

Thanks for your help,
Anthony
Re: [Xbase][Eclipse] Open Type on generated source link to the DSL source [message #1671166 is a reply to message #1671126] Fri, 13 March 2015 13:41 Go to previous message
Anthony Ferrando is currently offline Anthony FerrandoFriend
Messages: 4
Registered: March 2015
Junior Member
Hi,

Updating to 2.8.0 actually solved the problem without the need to override DerivedMemberAwareEditorOpener!

Thanks a lot for your help.
Anthony
Previous Topic:Xtext Java Grammar
Next Topic:Minimizing dependencies when deploying
Goto Forum:
  


Current Time: Tue Apr 13 20:59:49 GMT 2021

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

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

Back to the top