Skip to main content



      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 12:22 Go to next message
Eclipse UserFriend
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 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

have a look at DerivedMemberAwareEditorOpener
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 08:58 Go to previous messageGo to next message
Eclipse UserFriend
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 09:02 Go to previous messageGo to next message
Eclipse UserFriend
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
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 09:04 Go to previous messageGo to next message
Eclipse UserFriend
P.S: you may have a look at XbaseHyperLinkHelper as well
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 09:19 Go to previous messageGo to next message
Eclipse UserFriend
Btw the xtend editor in 280 has ab action to get to the generated code. You may digg into that as well
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 09:25 Go to previous messageGo to next message
Eclipse UserFriend
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 09:41 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 17:26:19 EDT 2025

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

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

Back to the top