Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error in Xtext/Xbase tutorial(Couldn't resolve reference to JvmIdentifiableElement 'name')
Error in Xtext/Xbase tutorial [message #1270366] Wed, 12 March 2014 23:08 Go to next message
JJ Mising name is currently offline JJ Mising nameFriend
Messages: 12
Registered: November 2010
Junior Member
I have tried to run the simple Xbase example in the Xtext 2.5 documentation and I ran into what seems to be a recurrent problem: it could not recognize the entity properties in the operation's body. Each time you try to reference a property you get an error of the type "Couldn't resolve reference to JvmIdentifiableElement 'xxx'", where xxx is the property.

I did google the problem, and found that in general people had forgotten to add the Xtend library with the xbase.lib jar, but this was not the case for me, it was in the build path. I also tried a Java and Plugin project, both yielded the same error.

I resulted to try to run the MongoBeans example and found that it was running just fine. So I tried to fix the Domain Model DSL using the MongoBeans example and eventually got it to run by changing the way the accessor methods get generated in the DomainmodelJvmModelInferrer.xtend file.

Before:
          Property : {
            members += feature.toField(feature.name, feature.type)
            members += feature.toGetter(feature.name, feature.type)
            members += feature.toSetter(feature.name, feature.type)
            }



After:
...
import org.eclipse.xtext.common.types.JvmDeclaredType

...
          Property : {
 	    addDelegateAccessors(feature)
          }

...

 	def protected addDelegateAccessors(JvmDeclaredType inferredType, Property property) {
		inferredType.members += property.toMethod('get' + property.name.toFirstUpper, property.jvmType) [
			documentation = property.documentation
			body = '''
					return «property.name» ;
			'''
		]
		inferredType.members += property.toMethod('set' + property.name.toFirstUpper, 
                        property.newTypeRef(Void.TYPE)) [
			documentation = property.documentation
			parameters += toParameter(property.name.toFirstUpper, property.jvmType)
			body = '''
					«property.name» = «property.name.toFirstUpper» ;
			'''
		]
	}
  
  	def protected getJvmType(Property property) {	
			property.type
	}




[Updated on: Thu, 13 March 2014 23:30]

Report message to a moderator

Re: Error in Xtext/Xbase tutorial [message #1270544 is a reply to message #1270366] Thu, 13 March 2014 05:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot reproduce your problem. maybe i did not understand it...
i dont get any compile errors in the xtend file...
did you try to modify/import the domain model example as which the tutorial ships with xtext and can be instantiated with new project wizard

i think the problem is some missing/wrong imports


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Error in Xtext/Xbase tutorial [message #1270957 is a reply to message #1270544] Thu, 13 March 2014 23:29 Go to previous message
JJ Mising name is currently offline JJ Mising nameFriend
Messages: 12
Registered: November 2010
Junior Member
Yes, I tried the tutorial step by step.

>> i think the problem is some missing/wrong imports
It's possible, but I simply pasted the code from the documentation

It's not too important, at a minimum, if people reach the same point I reached, they can find a way out of it.

JJ-
Previous Topic:API to serialize types in bodies of inferred methods
Next Topic:Loading XText resources in eclipse plugin does not resolve proxies
Goto Forum:
  


Current Time: Thu Apr 25 06:56:06 GMT 2024

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

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

Back to the top