Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » (Xtext) 15 Minute Tutorial needs to be updated for version 2.2
(Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #778796] Fri, 13 January 2012 21:12 Go to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
The existing 15 minute tutorial - extended for Xtext appears to still be at the 2.1 level. It includes references to the deprecated class org.eclipse.xtext.xtend2.lib.ResourceExtensions. From looking through other posts and searching the net, this appears to have been replaced by org.eclipse.xtext.xbase.lib.IteratorExtensions.

Using IteratorExtensions produces the error: Couldn't resolve reference to JvmType 'org.eclipse.xtext.xbase.lib.IteratorExtensions'.

This is in the first step of the tutorial and renders it useless for this release of Xtext.

http://www.eclipse.org/Xtext/documentation/2_1_0/040-first-code-generator.php
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #778810 is a reply to message #778796] Fri, 13 January 2012 22:02 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
After restarting Eclipse, the error for IteratorExtensions has gone away and the editor is now able to resolve the reference to it. I'm now able to continue with the tutorial by simply replacing the

import static extension org.eclipse.xtext.xtend2.lib.ResourceExtensions.*


with
import static extension org.eclipse.xtext.xbase.lib.IteratorExtensions.*
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #780333 is a reply to message #778796] Tue, 17 January 2012 16:08 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi David,

please open a bug report. This would get lost in the forum otherwise.

Regards,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #833527 is a reply to message #778796] Sat, 31 March 2012 16:47 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 1
Registered: March 2012
Junior Member
I had to do this, to work:

package com.diegogusava.generator

import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IGenerator
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.naming.IQualifiedNameProvider
import com.google.inject.Inject
import com.diegogusava.myDsl.Entity
import com.diegogusava.myDsl.Feature

class MyDslGenerator implements IGenerator {
	
	@Inject extension IQualifiedNameProvider nameProvider 
	
	override doGenerate(Resource resource, IFileSystemAccess fsa) {
	
		for(e: resource.allContents.toList().filter(typeof(Entity))) {
			 fsa.generateFile(
                e.fullyQualifiedName.toString.replace(".", "/") + ".java",
                e.compile)
		}
	
	}
	
	def compile(Entity e) ''' 
        «IF e.eContainer != null»
            package «e.eContainer.fullyQualifiedName»;
        «ENDIF»
        
        public class «e.name» «IF e.superType != null
                        »extends «e.superType.fullyQualifiedName» «ENDIF»{
            «FOR f:e.features»
                «f.compile»
            «ENDFOR»
        }
    '''
    
    def compile(Feature f) '''
        private «f.type.fullyQualifiedName» «f.name»;
        
        public «f.type.fullyQualifiedName» get«f.name.toFirstUpper»() {
            return «f.name»;
        }
        
        public void set«f.name.toFirstUpper»(«f.type.fullyQualifiedName» «f.name») {
            this.«f.name» = «f.name»;
        }
    '''
	
}


Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #873117 is a reply to message #833527] Thu, 17 May 2012 14:14 Go to previous message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Thanks, thanks a lot...
Previous Topic:java.lang.OutOfMemoryError: PermGen space
Next Topic:Autocomplete import example
Goto Forum:
  


Current Time: Wed Apr 24 21:12:20 GMT 2024

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

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

Back to the top