Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] Problem Creating JvmTypeReference to Existing Classes
[Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758393] Wed, 23 November 2011 05:32 Go to next message
Boris Pfahringer is currently offline Boris PfahringerFriend
Messages: 7
Registered: November 2011
Junior Member
Hey,

I'm trying to have all the classes I generate implement a specific interface. For simplicity let me demonstrate what I want to with the "Five simple steps to your JVM language" Tutorial as a basis.

I want all my classes to implement one interface, IEntity (just a dummy for demonstration):
package org.eclipse.xtext.example.domainmodel.runtime
public interface IEntity {}

I'm trying to do this by adding the interface to the list of superclasses of all the classes I generate like so (in DomainmodelJvmModelInferrer.xtend):
[...]
import org.eclipse.xtext.example.domainmodel.runtime.IEntity
[...]
def dispatch infer(Entity e, IAcceptor<JvmDeclaredType> acceptor, boolean prelinkingPhase) {
		acceptor.accept(
			e.toClass( e.fullyQualifiedName ) [
				// Always returns null :(
				superTypes += e.newTypeRef(typeof(IEntity))
[...]

Which always throws an AssertionError Sad
What am I doing wrong? Is ``newTypeRef()'' the wrong function to use?
Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758407 is a reply to message #758393] Wed, 23 November 2011 07:23 Go to previous messageGo to next message
rjarana Missing name is currently offline rjarana Missing nameFriend
Messages: 12
Registered: November 2011
Junior Member
Are you adding the interface IEntity to the classpath of the project? You have to add this interface (or any other class) to both the plug-in project and the model project.
Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758610 is a reply to message #758407] Wed, 23 November 2011 21:08 Go to previous messageGo to next message
Boris Pfahringer is currently offline Boris PfahringerFriend
Messages: 7
Registered: November 2011
Junior Member
Currently IEntity is in the org.eclipse.xtext.example.domainmodel.runtime package inside the domainmodel plugin. The manifest of domainmodel is set to export org.eclipse.xtext.example.domainmodel.runtime:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xtext Domainmodel Example
Bundle-Vendor: Eclipse Modeling Project
Bundle-Version: 2.2.0.qualifier
Bundle-SymbolicName: org.eclipse.xtext.example.domainmodel; singleton:=true
[...]
Export-Package: org.eclipse.xtext.example.domainmodel,
 org.eclipse.xtext.example.domainmodel.runtime,
[...]

The domainmodel.ui plugin requires the domainmodel plugin:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xtext Domainmodel Example UI
Bundle-Vendor: Eclipse Modeling Project
Bundle-Version: 2.2.0.qualifier
Bundle-SymbolicName: org.eclipse.xtext.example.domainmodel.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext.example.domainmodel;bundle-version="2.0.0",
[...]

Is that what you mean by adding it to the classpath?
Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758612 is a reply to message #758610] Wed, 23 November 2011 21:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

as you have to add xbase.lib to the classpath of the project the model file is contained you have to add the plugin that contains your IEntity as well

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758620 is a reply to message #758612] Wed, 23 November 2011 22:47 Go to previous messageGo to next message
Boris Pfahringer is currently offline Boris PfahringerFriend
Messages: 7
Registered: November 2011
Junior Member
Hi Christian,

IEntity.java is already in the same plugin as the model file (Domainmodel.xtext)

~Boris
Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758650 is a reply to message #758620] Thu, 24 November 2011 06:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
I am talking about the model (blablabla.dmodel) and not the grammar

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 24 November 2011 06:17]

Report message to a moderator

Re: [Xtend2] Problem Creating JvmTypeReference to Existing Classes [message #758871 is a reply to message #758650] Thu, 24 November 2011 21:10 Go to previous message
Boris Pfahringer is currently offline Boris PfahringerFriend
Messages: 7
Registered: November 2011
Junior Member
Wow, that was blindingly obvious in hindsight. Thank you so much for your patience and promptness.

Vielen Dank,
Boris
Previous Topic:Use/migrate grammar of ANTLR3 in xtext, is possible?
Next Topic:[Xtext 2.1] property databinding in own dsl
Goto Forum:
  


Current Time: Fri Mar 29 11:58:40 GMT 2024

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

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

Back to the top