Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing XText project classes from the runtime eclipse
Accessing XText project classes from the runtime eclipse [message #1719444] Fri, 08 January 2016 00:56 Go to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I am struggling with allowing my DSL-generated-code to access classes which are written in my XText Xbase project. Specifically, I'm having this issue while trying to program a project with my dsl's xtext nature, in runtime eclipse.

For example, let's say this class is in my XText project:

package org.xtext.mydsl;

public class SuperEntity {
   public SuperEntity() {...}
}


Now let's say my jvmModelInferrer includes something like:

	def dispatch void infer(Entity entity, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {

		acceptor.accept(entity.toClass(entity.name)) [
			superTypes += typeRef(org.xtext.mydsl.SuperEntity)
		]


How can I properly export the SuperEntity class (or ideally its containing package), so that the generated source will properly compile in runtime eclipse? Is there a way to do this via the xtext project's manifest? Ideally, I'd be able to reference the package directly vs. having to build a jar.

Thanks (yet again!).

[Updated on: Fri, 08 January 2016 08:41]

Report message to a moderator

Re: Accessing XText project classes from the runtime [message #1719455 is a reply to message #1719444] Fri, 08 January 2016 07:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi i dont Unterstand this. Put the SuperEntity on the classpath of the mydsl file and you are done

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing XText project classes from the runtime [message #1719467 is a reply to message #1719455] Fri, 08 January 2016 08:47 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Sorry, I've edited the original question in an attempt to clarify.

I am specifically talking about accessing code from my xtext project while using my dsl in runtime eclipse (via run as->eclipse application).

For example, using the code above, imagine I've created a new project in runtime eclipse, with my xtext nature. As soon as I complete a valid "Entity" in a .mydsl file, xtext will generate source code with a reference to org.xtext.mydsl.SuperEntity.

So, I'm trying to figure out how to make that SuperEntity class accessible to the project in the eclipse runtime project so it can compile.

Obviously, I could manually import the project into that workspace and add it to the buildpath of my dsl project, but I assumed there would be a way to automatically include packages for projects that will use my dsl. Maybe that's an incorrect assumption?

Hopefully that makes more sense!
Re: Accessing XText project classes from the runtime [message #1719469 is a reply to message #1719467] Fri, 08 January 2016 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

- the project in the runtime eclipse has to be a java project with xtext nature
- the project need a jar containing org.xtext.mydsl.SuperEntity on the classpath (e.g. in a libary jar)
- if you use xbase expressions it needs xbase.lib on the classpath as well

if you want this "putting on the classpath" beeing happening automatically you have to build this yourself.
(xtend does this by having a quickfix)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing XText project classes from the runtime [message #1719562 is a reply to message #1719469] Fri, 08 January 2016 21:01 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Ah, ok, thanks for clarifying.

I thought there might be some way to bundle the library with xtext nature or plugin, so that any new project using the DSL would automatically have it on the classpath.

I'll just do it manually for the time being.

Do you possibly have a pointer to the quickfix you implemented for XTend to handle this?

Thanks!
Re: Accessing XText project classes from the runtime [message #1719564 is a reply to message #1719562] Fri, 08 January 2016 21:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
https://github.com/eclipse/xtext/blob/1669ffb483886897d7d9e0d662f4597b8370f5aa/plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/quickfix/XtendQuickfixProvider.java

Please note there are
Other files involved as well
The validation
The plugin xmi and the classes that provider the library class path variable etc.
You have to digg into that yourself


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing XText project classes from the runtime [message #1719566 is a reply to message #1719564] Fri, 08 January 2016 21:50 Go to previous message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Very cool, this is a great example of how to accomplish what I'm looking for. Thanks very much!
Previous Topic:NoClassDefFoundError for INameEnvironment
Next Topic:How objects are referenced in text
Goto Forum:
  


Current Time: Thu Apr 18 15:35:54 GMT 2024

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

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

Back to the top